diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ea00420e78..eeca1dc26a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1849,6 +1849,28 @@ if(CONFIG_BUILD_OUTPUT_BIN AND CONFIG_BUILD_OUTPUT_UF2) set(BYPRODUCT_KERNEL_UF2_NAME "${PROJECT_BINARY_DIR}/${KERNEL_UF2_NAME}" CACHE FILEPATH "Kernel uf2 file" FORCE) endif() +if(CONFIG_BUILD_OUTPUT_MOT) + get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats) + if(srec IN_LIST elfconvert_formats) + list(APPEND + post_build_commands + COMMAND $ + $ + ${GAP_FILL} + $srec + $${OUTPUT_FORMAT} + $${KERNEL_ELF_NAME} + $${KERNEL_MOT_NAME} + $ + ) + list(APPEND + post_build_byproducts + ${KERNEL_MOT_NAME} + ) + set(BYPRODUCT_KERNEL_MOT_NAME "${PROJECT_BINARY_DIR}/${KERNEL_MOT_NAME}" CACHE FILEPATH "Kernel mot file" FORCE) + endif() +endif() + set(KERNEL_META_PATH ${PROJECT_BINARY_DIR}/${KERNEL_META_NAME} CACHE INTERNAL "") if(CONFIG_BUILD_OUTPUT_META) list(APPEND diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 23f7507b432..99295612b68 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -785,6 +785,12 @@ config BUILD_OUTPUT_UF2 Build a UF2 binary zephyr/zephyr.uf2 in the build directory. The name of this file can be customized with CONFIG_KERNEL_BIN_NAME. +config BUILD_OUTPUT_MOT + bool "Build a binary in MOT format" + help + Build a MOT binary zephyr/zephyr.mot in the build directory. + The name of this file can be customized with CONFIG_KERNEL_BIN_NAME. + if BUILD_OUTPUT_UF2 config BUILD_OUTPUT_UF2_FAMILY_ID diff --git a/cmake/bintools/gnu/target_bintools.cmake b/cmake/bintools/gnu/target_bintools.cmake index 6bbe8f8a3cf..2abe7d321ab 100644 --- a/cmake/bintools/gnu/target_bintools.cmake +++ b/cmake/bintools/gnu/target_bintools.cmake @@ -27,8 +27,8 @@ set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_OBJCOPY}) # List of format the tool supports for converting, for example, -# GNU tools uses objectcopy, which supports the following: ihex, srec, binary -set_property(TARGET bintools PROPERTY elfconvert_formats ihex srec binary) +# GNU tools uses objectcopy, which supports the following: ihex, srec, binary, mot +set_property(TARGET bintools PROPERTY elfconvert_formats ihex srec binary mot) set_property(TARGET bintools PROPERTY elfconvert_flag "") set_property(TARGET bintools PROPERTY elfconvert_flag_final "") diff --git a/cmake/flash/CMakeLists.txt b/cmake/flash/CMakeLists.txt index d1f0d17da6e..8b2f17aff95 100644 --- a/cmake/flash/CMakeLists.txt +++ b/cmake/flash/CMakeLists.txt @@ -60,6 +60,10 @@ function(runners_yaml_append_config) get_runners_prop(uf2_file uf2 "${KERNEL_UF2_NAME}") runners_yaml_append(" uf2_file: ${uf2}") endif() + if(CONFIG_BUILD_OUTPUT_MOT) + get_runners_prop(mot_file mot "${KERNEL_MOT_NAME}") + runners_yaml_append(" mot_file: ${mot}") + endif() zephyr_get(OPENOCD) zephyr_get(OPENOCD_DEFAULT_PATH) diff --git a/cmake/modules/kernel.cmake b/cmake/modules/kernel.cmake index b6192b1ba78..c6319611c8c 100644 --- a/cmake/modules/kernel.cmake +++ b/cmake/modules/kernel.cmake @@ -78,6 +78,7 @@ add_custom_target(code_data_relocation_target) # bin_file "zephyr.bin" file for flashing # hex_file "zephyr.hex" file for flashing # elf_file "zephyr.elf" file for flashing or debugging +# mot_file "zephyr.mot" file for flashing # yaml_contents generated contents of runners.yaml # # Note: there are quotes around "zephyr.bin" etc. because the actual @@ -170,6 +171,7 @@ set(KERNEL_EXE_NAME ${KERNEL_NAME}.exe) set(KERNEL_STAT_NAME ${KERNEL_NAME}.stat) set(KERNEL_STRIP_NAME ${KERNEL_NAME}.strip) set(KERNEL_META_NAME ${KERNEL_NAME}.meta) +set(KERNEL_MOT_NAME ${KERNEL_NAME}.mot) set(KERNEL_SYMBOLS_NAME ${KERNEL_NAME}.symbols) # Enable dynamic library support when required by LLEXT.