cmake: Add UF2 as an additional build output option.

Add ability to build a UF2 (https://github.com/Microsoft/uf2)
image as an additional output type. This leverages the code
partition offset for the UF2 base address, and a configurable
UF2 family ID.

Includes an unmodified (except for headers for licensing, pylit
disabling) version of the uf2conv.py script copied the UF2
format specification repository, used to convert the bin to UF2.

Origin: UF2 file format specification reference utilies
License: MIT
URL: https://github.com/microsoft/uf2/blob/master/utils/uf2conv.py
commit: 587abb8b909266e9b468d6284f2fbd425235d1b5
Signed-off-by: Pete Johanson <peter@peterjohanson.com>
This commit is contained in:
Pete Johanson 2020-12-31 16:51:52 -05:00 committed by Carles Cufí
commit 310a464acf
5 changed files with 358 additions and 0 deletions

View file

@ -1200,6 +1200,21 @@ if(CONFIG_BUILD_OUTPUT_BIN)
endif()
endif()
if(CONFIG_BUILD_OUTPUT_BIN AND CONFIG_BUILD_OUTPUT_UF2)
list(APPEND
post_build_commands
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/uf2conv.py
-c
-f ${CONFIG_BUILD_OUTPUT_UF2_FAMILY_ID}
-b ${CONFIG_FLASH_LOAD_OFFSET}
-o ${KERNEL_UF2_NAME}
${KERNEL_BIN_NAME}
)
list(APPEND
post_build_byproducts
${KERNEL_UF2_NAME}
)
endif()
# Cleanup intermediate files
if(CONFIG_CLEANUP_INTERMEDIATE_FILES)