esptool: Allow to pass the partition table CSV.#16307
esptool: Allow to pass the partition table CSV.#16307fjmolinas merged 1 commit intoRIOT-OS:masterfrom iosabi:esp_table
Conversation
|
@gschorcht FYI |
fjmolinas
left a comment
There was a problem hiding this comment.
Seems sensible, but I dont have a BOARD to test, maybe @benpicco or @gschorcht could give it a run?
|
@kaspar030 is the esp32-wroom32 still on the ci? |
I triggered the CI to run rests on that BOARD, it should tell us if its OK. |
|
I don't have a esp32-wrom board to test this, but here's what I did (PROG_DEV=/dev/null because I don't have such device): git checkout esp_table^ # Checks out the parent commit
make -C tests/od/ BOARD=esp32-wroom-32 PROG_DEV=/dev/null RIOT_VERSION=esp32-test flash
mv tests/od/bin/esp32-wroom-32 tests/od/bin/esp32-wroom-32-headNote that in the Then, for this commit: git checkout esp_table
make -C tests/od/ BOARD=esp32-wroom-32 PROG_DEV=/dev/null RIOT_VERSION=esp32-test flash -j
mv tests/od/bin/esp32-wroom-32 tests/od/bin/esp32-wroom-32-tableThen compare the two directories with Looking at the failure and the |
makefiles/tools/esptool.inc.mk
Outdated
| # flashing only, but if they are added to FLASHDEPS instead a "flash-only" | ||
| # target would cause a rebuild of $(ELFFILE) since these files depend on it and | ||
| # ELFFILE depends on FORCE. | ||
| BUILD_FILES += $(FLASHFILE).bin $(BINDIR)/partitions.bin |
There was a problem hiding this comment.
I changed these to use BUILD_FILES instead of FLASHDEPS even if they are only needed for flashing. The real problem here is that ELFFILE depends on FORCE so we can't have FLASHDEPS depend on the ELFFILE (FLASHFILE) and not trigger a rebuild. I think ELFFILE shouldn't depend on FORCE but instead have some build config dependency on a lazysponge output or similar... but that's for another bug.
There was a problem hiding this comment.
I changed this back. Turns out this doesn't work either because the CI doesn't copy those files.
I don't see a way to set this up correctly because ELFFILE is FORCEd (not sure why). I filed #16385 to address that.
Meanwhile I implemented a somewhat hacky fix setting these as .PHONY when using flash-only. This should make the CI happy.
There was a problem hiding this comment.
Turns out this doesn't work either because the CI doesn't copy those files.
you mean when running the tests? Try adding needed files to TEST_EXTRA_FILES.
There was a problem hiding this comment.
@iosabi I took a look and I think adding to BUILD_FILES is the way to go. Simply add also a line with
TEST_EXTRA_FILES += $(FLASHFILE).bin $(BINDIR)/partitions.bin
Just below when you add to BUILD_FILES
There was a problem hiding this comment.
Adding them to TEST_EXTRA_FILES works in the CI but the following doesn't work:
make -C tests/od BOARD=esp32-wroom-32 all flash-only -j
however, the following works:
make -C tests/od BOARD=esp32-wroom-32 flash -j
which I guess is good enough. I believe that flash -j works because flash: all dependency which flash-only doesn't have, and all (well link) eventually depends on the $(BUILD_FILES).
|
@iosabi during a review process, please avoid push forcing unless asked, approved by the reviewer, it makes following your changes harder, especially if you rebase as well, you can take a look at our contributing guidelines for more add-fixup-commits-during-review. |
fjmolinas
left a comment
There was a problem hiding this comment.
I took a closer look and I think your initial approach was the correct one @iosabi, just add TEST_EXTRA_FILES as suggested by @kaspar030.
Also I think these changes would fix #13492? no?
makefiles/tools/esptool.inc.mk
Outdated
| # it will cause it to be rebuilt even in "flash-only" mode because ELFFILE is | ||
| # FORCEd. To avoid that we either add the dependency when calling make with | ||
| # "all" or "flash", or we make it a PHONY target when only doing "flash-only". | ||
| $(FLASHFILE).bin: |
There was a problem hiding this comment.
| $(FLASHFILE).bin: | |
| $(FLASHFILE).bin: $(FLASHFILE) |
Or how about sticking to ELFFILE instead?
| $(FLASHFILE).bin: | |
| $(ELFFILE).bin: $(ELFFILE) |
There was a problem hiding this comment.
Strictly speaking, I think FLASHFILE should be $(ELFFILE).bin. I made that change in a second fixup commit now.
I have an |
The last branch should do it. I added two fixup commits. Sorry to force push them earlier, you should be able to see the diff if you click on the force-pushed word in the automatic message from github if you want to see that. |
| # table setting PARTITION_TABLE_CSV. | ||
| PARTITION_TABLE_CSV ?= $(BINDIR)/partitions.csv | ||
|
|
||
| $(BINDIR)/partitions.csv: $(FLASHFILE) |
There was a problem hiding this comment.
| $(BINDIR)/partitions.csv: $(FLASHFILE) | |
| $(BINDIR)/partitions.csv: $(ELFFILE).bin |
There was a problem hiding this comment.
I believe this one is better to leave as FLASHFILE. If you are using the default partition table but want to use a different FLASHFILE you can do something like:
FLASHFILE = $(BINDIR)/myflashfile.bin
$(BINDIR)/myflashfile.bin: $(ELFFILE).bin my-extra-static-data
cat $^ > $@The FFLAGS has 0x10000 $(FLASHFILE) so the default partition table should match that. If we were to implement OTA at some point then we wouldn't be using this default partition table and this point doesn't matter; but I think this should match what FFLAGS has and using FLASHFILE gives a tiny bit more flexibility.
I changed the body of the rule to use $< to avoid writing this twice.
|
Looks good @iosabi can you address my final comment, you can squash afterwards! |
The partition table of the device in the esp8266 and esp32 based boards was set to a default table with one "factory" partition with exactly the size of the compiled firmware. This is problematic if we want to update the device on the field. This patch allows to set the `PARTITION_TABLE_CSV` variable from the Makefile to a .csv file with a custom partition table, for example this could be set to a partition table with two ota entries, or with a single factory entry but of a known fixed size.
|
@iosabi can you post some kind of results for your custom partition table test? |
Sure! First we need a custom partition table like this: Then we can run the following command: Note that the partition table is not the best, FWs are better if they start at 0x010000 and 0x110000 so you can use the same fw at either slot, but that's not working due to #16402 (larger partition tables work fine with a newer bootloader binary). |
Contribution description
The partition table of the device in the esp8266 and esp32 based boards
was set to a default table with one "factory" partition with exactly
the size of the compiled firmware. This is problematic if we want to
update the device on the field.
This patch allows to set the
PARTITION_TABLE_CSVvariable from theMakefile to a .csv file with a custom partition table, for example this
could be set to a partition table with two ota entries, or with a single
factory entry but of a known fixed size.
As a side effect of the make cleanup in this patch we now support
passing
-jto themake flashcommand so we can compile in paralleland still run the flash commands only once at the end. Before this
patch the conversion from .elf to .elf.bin was happening before the
code was recompiled when running in parallel.
Testing procedure
make BOARD=esp8266-esp-12x Q= -C tests/lwip flash -j termVerified that the compile commands at the end (after the link step) appear in the right order.
make BOARD=esp8266-esp-12x PARTITION_TABLE_CSV=mytable.csv -C tests/lwip flash -j termVerified that the
mytable.csvfile is used instead.Also:
make -C tests/od BOARD=esp32-wroom-32 all flash-only -jshould workFor ci:
make -C tests/od BOARD=esp32-wroom-32 flash-onlyCheck that murdock receives the additional flash files (Green Murdock)
Issues/PRs references
Fixes #13492 due the usage of
BUILD_FILESandTEST_EXTRA_FILESinstead ofFLASHDEPSfor both files.