tasking/cmake: Provide better .hex and .srec gen for tasking compiler

Provide better hex and srec generation for tasking compiler, without relying
on freeware tricore-elf-objcopy.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
This commit is contained in:
wangchengdong 2025-09-17 10:17:52 +08:00 committed by archer
parent 7f407476f9
commit 34ca49b6f5
2 changed files with 26 additions and 12 deletions

View file

@ -555,6 +555,16 @@ add_definitions(-D__NuttX__)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-D__ASSEMBLY__>)
if(CONFIG_ARCH_TOOLCHAIN_TASKING)
if(CONFIG_INTELHEX_BINARY)
add_link_options(-Wl-onuttx.hex:IHEX:4 --hex-format=s)
endif()
if(CONFIG_MOTOROLA_SREC)
add_link_options(-Wl-onuttx.srec:SREC:4)
endif()
endif()
set_property(
TARGET nuttx
APPEND

View file

@ -22,22 +22,26 @@
function(nuttx_generate_outputs target)
if(CONFIG_INTELHEX_BINARY)
add_custom_command(
OUTPUT ${target}.hex
COMMAND ${CMAKE_OBJCOPY} -O ihex ${target} ${target}.hex
DEPENDS ${target})
add_custom_target(${target}-hex ALL DEPENDS ${target}.hex)
add_dependencies(nuttx_post ${target}-hex)
if(NOT CONFIG_ARCH_TOOLCHAIN_TASKING)
add_custom_command(
OUTPUT ${target}.hex
COMMAND ${CMAKE_OBJCOPY} -O ihex ${target} ${target}.hex
DEPENDS ${target})
add_custom_target(${target}-hex ALL DEPENDS ${target}.hex)
add_dependencies(nuttx_post ${target}-hex)
endif()
file(APPEND ${CMAKE_BINARY_DIR}/nuttx.manifest "${target}.hex\n")
endif()
if(CONFIG_MOTOROLA_SREC)
add_custom_command(
OUTPUT ${target}.srec
COMMAND ${CMAKE_OBJCOPY} -O srec ${target} ${target}.srec
DEPENDS ${target})
add_custom_target(${target}-srec ALL DEPENDS ${target}.srec)
add_dependencies(nuttx_post ${target}-srec)
if(NOT CONFIG_ARCH_TOOLCHAIN_TASKING)
add_custom_command(
OUTPUT ${target}.srec
COMMAND ${CMAKE_OBJCOPY} -O srec ${target} ${target}.srec
DEPENDS ${target})
add_custom_target(${target}-srec ALL DEPENDS ${target}.srec)
add_dependencies(nuttx_post ${target}-srec)
endif()
file(APPEND ${CMAKE_BINARY_DIR}/nuttx.manifest "${target}.srec\n")
endif()