trezor-firmware icon indicating copy to clipboard operation
trezor-firmware copied to clipboard

improve flexibility of combine script

Open TychoVrahe opened this issue 1 year ago • 3 comments

Also, combine_fw makefile target is added.

closes #3123

[no changelog]

TychoVrahe avatar Feb 23 '24 11:02 TychoVrahe

It's flexible alright but doesn't work for my usecase anymore, namely, pick arbitrary build artifacts from arbitrary historic versions and/or Notion archives and combine them for the factory blob -- at least not without memorizing some ugly constants.

could we do something like, put the memory layouts into separate files and make the call look like combine.py --layout u5.layout boardloader.bin bootloader.bin [firmware.bin [firmware.p2.bin ...]] ?

matejcik avatar Feb 23 '24 12:02 matejcik

Actually, that specific usecase was broken already - for MCUs different than STM32F4.

So here is more complex proposal: https://github.com/trezor/trezor-firmware/commit/e22248f725968131bc4d34762c2b11dd172c1dd0

Using core/embed/models/model_XXXX.h as a source of truth, makefile and combine script are using it via new layout_parser script. The parser script is quite naive so it prevents using preprocessor features, but upside is that we duplicate these constants one less time (some of them are still duplicated in linker scripts)

TychoVrahe avatar Feb 23 '24 16:02 TychoVrahe

the usage requires for every passed binary to specify the name of the binary, so that the layout parser knows what to look for, e.g. -b BOOTLOADER ./build/bootloader/bootloader.bin

TychoVrahe avatar Feb 23 '24 16:02 TychoVrahe

the PR is now broken, it seems to include all of U5 changes

matejcik avatar Mar 04 '24 11:03 matejcik

rebased.

TychoVrahe avatar Mar 04 '24 12:03 TychoVrahe