Skip to content

Commit 5fabd36

Browse files
duynguyenxakartben
authored andcommitted
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 <[email protected]>
1 parent bca4c17 commit 5fabd36

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

CMakeLists.txt

+22
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,28 @@ if(CONFIG_BUILD_OUTPUT_BIN AND CONFIG_BUILD_OUTPUT_UF2)
18491849
set(BYPRODUCT_KERNEL_UF2_NAME "${PROJECT_BINARY_DIR}/${KERNEL_UF2_NAME}" CACHE FILEPATH "Kernel uf2 file" FORCE)
18501850
endif()
18511851

1852+
if(CONFIG_BUILD_OUTPUT_MOT)
1853+
get_property(elfconvert_formats TARGET bintools PROPERTY elfconvert_formats)
1854+
if(srec IN_LIST elfconvert_formats)
1855+
list(APPEND
1856+
post_build_commands
1857+
COMMAND $<TARGET_PROPERTY:bintools,elfconvert_command>
1858+
$<TARGET_PROPERTY:bintools,elfconvert_flag>
1859+
${GAP_FILL}
1860+
$<TARGET_PROPERTY:bintools,elfconvert_flag_outtarget>srec
1861+
$<TARGET_PROPERTY:bintools,elfconvert_flag_intarget>${OUTPUT_FORMAT}
1862+
$<TARGET_PROPERTY:bintools,elfconvert_flag_infile>${KERNEL_ELF_NAME}
1863+
$<TARGET_PROPERTY:bintools,elfconvert_flag_outfile>${KERNEL_MOT_NAME}
1864+
$<TARGET_PROPERTY:bintools,elfconvert_flag_final>
1865+
)
1866+
list(APPEND
1867+
post_build_byproducts
1868+
${KERNEL_MOT_NAME}
1869+
)
1870+
set(BYPRODUCT_KERNEL_MOT_NAME "${PROJECT_BINARY_DIR}/${KERNEL_MOT_NAME}" CACHE FILEPATH "Kernel mot file" FORCE)
1871+
endif()
1872+
endif()
1873+
18521874
set(KERNEL_META_PATH ${PROJECT_BINARY_DIR}/${KERNEL_META_NAME} CACHE INTERNAL "")
18531875
if(CONFIG_BUILD_OUTPUT_META)
18541876
list(APPEND

Kconfig.zephyr

+6
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,12 @@ config BUILD_OUTPUT_UF2
785785
Build a UF2 binary zephyr/zephyr.uf2 in the build directory.
786786
The name of this file can be customized with CONFIG_KERNEL_BIN_NAME.
787787

788+
config BUILD_OUTPUT_MOT
789+
bool "Build a binary in MOT format"
790+
help
791+
Build a MOT binary zephyr/zephyr.mot in the build directory.
792+
The name of this file can be customized with CONFIG_KERNEL_BIN_NAME.
793+
788794
if BUILD_OUTPUT_UF2
789795

790796
config BUILD_OUTPUT_UF2_FAMILY_ID

cmake/bintools/gnu/target_bintools.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
set_property(TARGET bintools PROPERTY elfconvert_command ${CMAKE_OBJCOPY})
2828

2929
# List of format the tool supports for converting, for example,
30-
# GNU tools uses objectcopy, which supports the following: ihex, srec, binary
31-
set_property(TARGET bintools PROPERTY elfconvert_formats ihex srec binary)
30+
# GNU tools uses objectcopy, which supports the following: ihex, srec, binary, mot
31+
set_property(TARGET bintools PROPERTY elfconvert_formats ihex srec binary mot)
3232

3333
set_property(TARGET bintools PROPERTY elfconvert_flag "")
3434
set_property(TARGET bintools PROPERTY elfconvert_flag_final "")

cmake/flash/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ function(runners_yaml_append_config)
6060
get_runners_prop(uf2_file uf2 "${KERNEL_UF2_NAME}")
6161
runners_yaml_append(" uf2_file: ${uf2}")
6262
endif()
63+
if(CONFIG_BUILD_OUTPUT_MOT)
64+
get_runners_prop(mot_file mot "${KERNEL_MOT_NAME}")
65+
runners_yaml_append(" mot_file: ${mot}")
66+
endif()
6367

6468
zephyr_get(OPENOCD)
6569
zephyr_get(OPENOCD_DEFAULT_PATH)

cmake/modules/kernel.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ add_custom_target(code_data_relocation_target)
7878
# bin_file "zephyr.bin" file for flashing
7979
# hex_file "zephyr.hex" file for flashing
8080
# elf_file "zephyr.elf" file for flashing or debugging
81+
# mot_file "zephyr.mot" file for flashing
8182
# yaml_contents generated contents of runners.yaml
8283
#
8384
# Note: there are quotes around "zephyr.bin" etc. because the actual
@@ -170,6 +171,7 @@ set(KERNEL_EXE_NAME ${KERNEL_NAME}.exe)
170171
set(KERNEL_STAT_NAME ${KERNEL_NAME}.stat)
171172
set(KERNEL_STRIP_NAME ${KERNEL_NAME}.strip)
172173
set(KERNEL_META_NAME ${KERNEL_NAME}.meta)
174+
set(KERNEL_MOT_NAME ${KERNEL_NAME}.mot)
173175
set(KERNEL_SYMBOLS_NAME ${KERNEL_NAME}.symbols)
174176

175177
# Enable dynamic library support when required by LLEXT.

0 commit comments

Comments
 (0)