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__>) 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( set_property(
TARGET nuttx TARGET nuttx
APPEND APPEND

View file

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