CMake: Add support for .mot binary file format

The Renesas RX support flashing .mot file for binary image
This commit target to add the .mot file output for build and
flash script

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
This commit is contained in:
Duy Nguyen 2025-03-31 11:51:44 +07:00 committed by Benjamin Cabé
parent bca4c17da3
commit 5fabd3634a
5 changed files with 36 additions and 2 deletions

View File

@ -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 $<TARGET_PROPERTY:bintools,elfconvert_command>
$<TARGET_PROPERTY:bintools,elfconvert_flag>
${GAP_FILL}
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>srec
$<TARGET_PROPERTY:bintools,elfconvert_flag_intarget>${OUTPUT_FORMAT}
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_MOT_NAME}
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
)
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

View File

@ -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

View File

@ -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 "")

View File

@ -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)

View File

@ -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.