Skip to content

make -j flash fails due to missing make dependencies or make flash-only rebuilds the .elf #16385

@iosabi

Description

@iosabi

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:

  1. adafruit-nrfutil based boards like BOARD=adafruit-clue add the $(HEXFILE).zip to FLASHDEPS (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:
    %.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

  1. The esptool based boards like BOARD=esp32-wroom-32 (in the CI) have a phony esp-image-convert target that uses the $(FLASHFILE) to generate the extra files needed for flashing which are then used by the flash-only target. The issue here is that esp-image-convert does not depend on $(FLASHFILE), so if you run make flash -j for this board one of three things can happen: a) you are lucky and the esp-image-convert target magically runs after the build is done (unlikely), b) you are unlucky and the first time you run make -j flash the missing $(FLASHFILE) just makes the build fail with an error, or c) you are extra unlucky and the esp-image-convert command 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:

  1. Either the files added to FLASHDEPS depend on $(ELFFILE) when they need to (example 1), but then the flash-only command is actually building as well (example 1), or
  2. The added FLASHDEPS are phony targets that don't depend on $(ELFFILE) even if they use it but in that case make flash -j command 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-only

Example 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

Metadata

Metadata

Assignees

Labels

Area: build systemArea: Build systemType: bugThe issue reports a bug / The PR fixes a bug (including spelling errors)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions