Page 1 of 1

Why make -j8 flash rebuilds the project?

Posted: Tue May 14, 2019 9:31 pm
by bonmotwang
Is there a switch for just flash without rebuilding the whole project?
I am using Eclipse.
Thanks
Paul

Re: Why make -j8 flash rebuilds the project?

Posted: Tue May 14, 2019 9:38 pm
by username
yes, All the options are in the docs.

Re: Why make -j8 flash rebuilds the project?

Posted: Wed May 15, 2019 1:49 am
by ESP_Angus
Hi Paul,

Similar to answer to your other question, make flash should only build any changed files and then flash the just-built app. If no source files have changed, it will just flash the app.

If you've changed menuconfig, the whole project is rebuilt with the new configuration.

If you only need to change the COM port for flashing, you can set the ESPPORT variable instead of editing menuconfig. ie run the command line "make -j4 flash ESPPORT=COM9". This will save an unnecessary rebuild just for the port change.

Re: Why make -j8 flash rebuilds the project?

Posted: Wed May 15, 2019 2:32 pm
by chegewara
Hi,
recently i found that changing Makefile also is causing full project rebuild.

Re: Why make -j8 flash rebuilds the project?

Posted: Wed May 15, 2019 3:25 pm
by fly135
bonmotwang wrote:
Tue May 14, 2019 9:31 pm
Is there a switch for just flash without rebuilding the whole project?
I am using Eclipse.
Thanks
Paul
Here's an example using msys32 command line...

$IDF_PATH/components/esptool_py/esptool/esptool.py --chip esp32 --port "COM3" --baud 921600 --before "default_reset" --after "hard_reset" write_flash -z --flash_mode "dio" --flash_freq "40m" --flash_size detect 0x1000 ./build/bootloader/bootloader.bin 0x10000 ./build/<application name>.bin 0x8000 ./build/<partition file name>.bin

Re: Why make -j8 flash rebuilds the project?

Posted: Thu May 16, 2019 3:23 am
by ESP_Angus
chegewara wrote:
Wed May 15, 2019 2:32 pm
Hi,
recently i found that changing Makefile also is causing full project rebuild.
It has to do this because there's no way for Make to know what you changed. For example, if the change added a compiler flag to CFLAGS for every source file compilation then it needs to rebuild every source file to get the correct build output. The exact change can be subtle, so we rebuild the whole project if any top-level makefile changes.

Re: Why make -j8 flash rebuilds the project?

Posted: Thu May 16, 2019 3:24 am
by ESP_Angus
fly135 wrote:
Wed May 15, 2019 3:25 pm
bonmotwang wrote:
Tue May 14, 2019 9:31 pm
Is there a switch for just flash without rebuilding the whole project?
I am using Eclipse.
Thanks
Paul
Here's an example using msys32 command line...

$IDF_PATH/components/esptool_py/esptool/esptool.py --chip esp32 --port "COM3" --baud 921600 --before "default_reset" --after "hard_reset" write_flash -z --flash_mode "dio" --flash_freq "40m" --flash_size detect 0x1000 ./build/bootloader/bootloader.bin 0x10000 ./build/<application name>.bin 0x8000 ./build/<partition file name>.bin
To expand on this answer, if you do a normal "make" build then the correct esptool.py flashing command is printed as the last output of the build. Running make and then running this command is the same as running "make flash".

Re: Why make -j8 flash rebuilds the project?

Posted: Thu May 16, 2019 5:40 pm
by gunar.kroeger
ESP_Angus wrote:
Thu May 16, 2019 3:23 am
chegewara wrote:
Wed May 15, 2019 2:32 pm
Hi,
recently i found that changing Makefile also is causing full project rebuild.
It has to do this because there's no way for Make to know what you changed. For example, if the change added a compiler flag to CFLAGS for every source file compilation then it needs to rebuild every source file to get the correct build output. The exact change can be subtle, so we rebuild the whole project if any top-level makefile changes.
Ok, but this behavior stopped me from being able to autoincrement the build version on each build. Is there a way of doing this without rebuilding everything?

Re: Why make -j8 flash rebuilds the project?

Posted: Fri May 17, 2019 2:03 am
by ESP_Angus
gunar.kroeger wrote:
Thu May 16, 2019 5:40 pm
Ok, but this behavior stopped me from being able to autoincrement the build version on each build. Is there a way of doing this without rebuilding everything?
Probably... put something like this in your Makefile

Code: Select all

ifndef MAKE_RESTARTS
_IGNORE := $(shell ./increment_build_number.sh)
endif
(Put it outside of any target)

Then, in your increment_build_number.sh script (can actually be a Python script or a PHP Script or a C program or whatever you like) it does the following steps:
  • Open file main/build_number.h (or similar named file with build number)
  • Parse the file to get the existing build number
  • Add one to the build number
  • Write the new file back with the new build number
This will update build_number.h each time "make" is run. The build system will rebuild only source files which include "build_number.h".

(Haven't tested this, 95% sure it will work though. Please open a new thread with your script if it's not working for you.)

EDIT PS: For what it's worth, I recommend not doing this and storing your project in git instead, with frequent commits. Knowing which git revision your project was built from (this is built-in functionality to ESP-IDF) is much more meaningful than knowing a build number.