ESP-IDF V4.x with extra argements for idf.py to pass down?

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

ESP-IDF V4.x with extra argements for idf.py to pass down?

Postby zliudr » Wed Aug 26, 2020 3:23 am

[Update] The original question to pass down a -j argument seems irrelevant now that I know ninja does it automatically. Still, other crucial cpp argements need to be passed to cmake, then ninja, finally to cpp. How do I do that?

Here is the link to the relevant reply:
viewtopic.php?f=13&t=17085&p=64353#p65794

[Original]
I'm used to V3.3 and make. I can add -j option to make command to use all cores with maximal amount of jobs. With the V4.1 how do I do that with cmake? Just adding -j isn't recognized. I hope cmake isn't running on a single core. I timed hello_world to take about 1 minute 27 seconds to compile from scratch on my old machine with 4 cores. Is -j already enabled with cmake? I don't want to install 4.x on my new machine until I finish testing it with my project code on a separate machine. Thanks.

According to the help, I can invoke cmake directly so I did, after fullclean.

cmake -j .. -G Ninja
ninja -j0
It took about 1 minute 2 seconds. I wonder if I can make this ninja use all cores. Any ideas if this is the right speed for an i5 4 core 3.2GHz?
Last edited by zliudr on Sun Sep 27, 2020 7:26 pm, edited 2 times in total.

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: How do you enable -j option for ESP-IDF V4.x with cmake?

Postby ESP-Marius » Wed Aug 26, 2020 6:05 am

Ninja automatically defaults to the number of CPUs, so you shouldn't haven't to use any -jX option like you do with make.

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: How do you enable -j option for ESP-IDF V4.x with cmake?

Postby zliudr » Thu Aug 27, 2020 3:18 am

OK thanks. Then what about the cmake? I did a test running cmake without -j, with -j, and with -j0. About the same time, ~11 seconds. I guess my suspicion is rooted from ESP-IDF V3.3 with the msys32 and make. With make, you HAVE to specify -j to use all cores. It makes a huge difference once I knew the -j switch. Also processors make huge difference. With my moderate i5 3.0GHz 4-core system, a project could take 3.5 minutes to build from scratch. But with my i9 3.7GHz 10-core system, same project takes just shy of 30 seconds to build with -j. Without it, my i9 is just as helpless as i5.

ESP-Marius
Posts: 74
Joined: Wed Oct 23, 2019 1:49 am

Re: How do you enable -j option for ESP-IDF V4.x with cmake?

Postby ESP-Marius » Thu Aug 27, 2020 5:36 am

I think CMake's -j just maps to the underlying build tool, e.g. Ninja. So it shouldnt make a difference here.

Yeah, with make you definitely wanna use -j like you say.

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: How do you enable -j option for ESP-IDF V4.x with cmake?

Postby zliudr » Sun Sep 27, 2020 5:09 am

It's hard to catch the exact command but I managed to catch this cmake command when I ran idf.py and it doesn't have -j option:
Image

So if I want to have the convenience of idf.py, then how do I add -j to it, is it here?

Code: Select all

            cmake_args = [
                "cmake",
                "-G",
                args.generator,
                "-DPYTHON_DEPS_CHECKED=1",
                "-DESP_PLATFORM=1",
            ]

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: How do you enable -j option for ESP-IDF V4.x with cmake?

Postby zliudr » Sun Sep 27, 2020 5:23 am

OK I added a "-j" to the option and saw it was used"

Code: Select all

Executing "cmake -j -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 --warn-uninitialized -DWARN_UNINITIALIZED=1 -DCCACHE_ENABLE=1 c:\users\tarza\documents\hello_world"...
It didn't seem to make a difference in the compile time so I'm happy. I'll be upgrading my main computer to ESP-IDF 4.0 soon, after I make sure my project compiles on my spare machine.

wevets
Posts: 112
Joined: Sat Mar 09, 2019 2:56 am

Re: How do you enable -j option for ESP-IDF V4.x with cmake?

Postby wevets » Sun Sep 27, 2020 3:25 pm

I'm running a Win10 machine and use cmd.exe as my build environment. I'm at IDF v4.1. When I run idf.py to build my app, I use Task Manager to look at the individual utilization of the four cores in my processor, and they're all pinned at 99% utilization. So it looks like idf.py sets up cmake and ninja to do the right thing by default, at least on my machine with my setup.

I'd be interested, though, where to find cmake_args = [...] referred to in another post. How do I access that?

zliudr
Posts: 360
Joined: Thu Oct 03, 2019 5:15 am

Re: How do you enable -j option for ESP-IDF V4.x with cmake?

Postby zliudr » Sun Sep 27, 2020 7:23 pm

I'm on the same boat. I have a list of cpp arguments that needs to be passed on but idf.py doesn't seem to do it. Here is my list:

Code: Select all

'EXTRA_CPPFLAGS+=-DFIRMWARE_VER=20092501UL -DDEV_FEATURES=1 -DLATEST_AZURE=1 -DPRINT_MEMORY_DEBUG=1 -w'
I'd say that everything CAN be accomplished if I just define them in a header file EXCEPT for -w. I need to surprise warnings that are treated as errors that terminate the compile. Which post was asking about cmake_args? I think cpp argements can just be passed to cmake to be passed down to ninja and then cpp.

Who is online

Users browsing this forum: snutw_ and 105 guests