Closed BenBE closed 2 years ago
I believe application-specific stuff like inflating a bootloader can be easily handled by the application itself, so IMHO it's not necessary to add more complexity here. See below for a rough example how I did it in a similar project.
Agree about TARGET_FILE_BIN
though - would you be willing to write a PR?
add_executable(application ....)
add_executable(bootloader ....)
...
add_custom_target(bootloader_padded
COMMAND "${CMAKE_OBJCOPY}" -O binary --pad-to 0x00010000 --gap-fill 0xff
bootloader.elf
bootloader_padded.bin
BYPRODUCTS bootloader_padded.bin
COMMENT "Generating padded bootloader file"
DEPENDS bootloader
)
add_custom_target(firmware_bundle ALL
COMMAND cat "bootloader_padded.bin" "application.bin" > "application_bundle.bin"
DEPENDS bootloader_padded
DEPENDS application
BYPRODUCTS "application_bundle.bin"
COMMENT "Generating bundle.bin"
)
ACK, this can be easily solved by an extra custom target. Yet I think the cleaner solution would be just one arg IMG_BIN_FLAGS
defaulting to "" which is passed to those img util functions. Otherwise you'd effectively extract the binary image twice.
Will take a look at doing a PR for defining custom target properties for the target files.
Ok, I had another look and the added complexity to cubemx.cmake seems not as bad. See https://github.com/patrislav1/cubemx.cmake/commit/51b7e1e44b7b79f8e38688b7116a3d7a66bf4bfe
When building multi-part binary bundles it's necessary to inflate the generated
.bin
file for some targets (e.g. when creating a bootloader). Currently there's no direct option to pass additional arguments for themcu_elf2bin
such that additional arguments like--pad-to 0x8008000 --gap-fill 0xff
can be passed.Also it'd be nice to have the various target files available as
TARGET_PROPERTIES
so they can be referenced in generator expressions for dependent targets: