-
Notifications
You must be signed in to change notification settings - Fork 2.1k
make -j flash fails due to missing make dependencies or make flash-only rebuilds the .elf #16385
Description
Description
Many boards have FLASHFILE as ELFFILE and can directly flash the FLASHFILE setting the right FFLAGS; however in some cases boards need additional files or additional conversions expressed in makefile rules.
For example:
adafruit-nrfutilbased boards likeBOARD=adafruit-clueadd the$(HEXFILE).ziptoFLASHDEPS(here) and the %.hex.zip target depends on the %.hex target as defined in that file. Also, the %.hex depends on the %.elf as defined here:
Line 655 in 73ccd1e
%.hex: %.elf
This means that some targets in FLASHDEPS (the .hex.zip file) depend on the ELFFILE. This causes make flash-only to rebuild the ELFFILE because in the Makefile.include this elf target depends on FORCE
- The
esptoolbased boards likeBOARD=esp32-wroom-32(in the CI) have a phonyesp-image-converttarget that uses the$(FLASHFILE)to generate the extra files needed for flashing which are then used by theflash-onlytarget. The issue here is thatesp-image-convertdoes not depend on$(FLASHFILE), so if you runmake flash -jfor this board one of three things can happen: a) you are lucky and theesp-image-converttarget magically runs after the build is done (unlikely), b) you are unlucky and the first time you runmake -j flashthe missing$(FLASHFILE)just makes the build fail with an error, or c) you are extra unlucky and theesp-image-convertcommand runs reading an older version of the$(FLASHFILE)because the new one is still waiting for some .o to be compiled (the common case). In this last case you are left scratching your head why your board behaves like if the change you just made and compiled fine didn't happen.
The issue here is actually one of two different issues:
- Either the files added to
FLASHDEPSdepend on$(ELFFILE)when they need to (example 1), but then theflash-onlycommand is actually building as well (example 1), or - The added
FLASHDEPSare phony targets that don't depend on$(ELFFILE)even if they use it but in that casemake flash -jcommand doesn't work.
I didn't find a way to properly set up a board so that it compiles in parallel, flashes and passes the CI.
Note that in the CI having "flash-only" rebuild can cause problems. I tried adding the ELFFILE dependency in the second example but that fails because it tries to re-link the .elf file with an error that it didn't find the eps32 g++ compiler.
Steps to reproduce the issue
Example 1:
make -C tests/od BOARD=adafruit-clue all
make -C tests/od BOARD=adafruit-clue flash-onlyExample 2:
make -C tests/od BOARD=esp32-wroom-32 all flash-only -j
Expected results
Example 1: "flash-only" command doesn't rebuild the .elf file.
Example 2: board flashes.
Actual results
Example 1: The second command (flash-only) should not rebuild the .elf
Example 2: The build very likely fails because the needed ELFFILE was not built when esp-image-convert starts running.
Versions
make: GNU Make 4.2.1