Introduces Regression for 32 and 64 bit threadx and smp kernel in Debug, MinSizeRel and Release configuration #4

Merged
alex merged 79 commits from feature/test into main 2026-04-02 14:09:29 +01:00
2 changed files with 64 additions and 28 deletions
Showing only changes of commit ba1b9c44ee - Show all commits

View File

@@ -36,54 +36,35 @@ option(NX_DEBUG "compile netxduo debug output in" OFF)
set(TARGET_MEM "ram" CACHE STRING "memory map to use")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
add_subdirectory(port/moonlight)
function(setup_target TARGET)
set(options)
set(oneValueArgs) # none for now
set(multiValueArgs LIBRARIES SOURCES)
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(ST_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "setup_target(${target} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
message(FATAL_ERROR "setup_target(${TARGET} ...): unknown args: ${ST_UNPARSED_ARGUMENTS}")
endif()
add_executable(${TARGET})
target_sources(${TARGET} PRIVATE
${CMAKE_SOURCE_DIR}/port/picolibc/port.c
${CMAKE_SOURCE_DIR}/port/moonlight/bootup.c
${CMAKE_SOURCE_DIR}/port/moonlight/board.c
${CMAKE_SOURCE_DIR}/port/moonlight/trap_non_vectored.c
${CMAKE_SOURCE_DIR}/port/moonlight/exception.c
${CMAKE_SOURCE_DIR}/port/moonlight/vector_table.c
)
target_add_moonlight_platform(${TARGET})
if("netxduo" IN_LIST ST_LIBRARIES)
target_sources(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/port/moonlight/mnrs_network_driver.c)
target_add_moonlight_network_driver(${TARGET})
endif()
if(ST_SOURCES)
target_sources(${TARGET} PRIVATE ${ST_SOURCES})
endif()
target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/port/moonlight ${CMAKE_SOURCE_DIR}/src)
target_compile_options(${TARGET} PRIVATE
-ffreestanding
-fno-builtin
-fdata-sections
-ffunction-sections
)
if(NX_DEBUG)
target_compile_definitions(${TARGET} PRIVATE NX_DEBUG NX_DEBUG_PACKET)
endif()
target_link_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/src) # needed for linker script includes
target_link_options(${TARGET} PRIVATE
-nostartfiles
-nostdlib
-T ${CMAKE_SOURCE_DIR}/src/${TARGET_MEM}.lds
-Wl,--gc-sections
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map
)
if(ST_LIBRARIES)
target_link_libraries(${TARGET} PRIVATE ${ST_LIBRARIES})
endif()
target_link_options(${TARGET} PRIVATE
-Wl,-Map=${CMAKE_BINARY_DIR}/${TARGET}.map)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${OBJCOPY} -O ihex $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.hex
COMMAND ${OBJCOPY} -O binary $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.bin

View File

@@ -0,0 +1,55 @@
set(MOONLIGHT_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(THREADX4TGFS_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
set(MOONLIGHT_PLATFORM_SOURCES
${THREADX4TGFS_ROOT}/port/picolibc/port.c
${MOONLIGHT_ROOT}/bootup.c
${MOONLIGHT_ROOT}/board.c
${MOONLIGHT_ROOT}/trap_non_vectored.c
${MOONLIGHT_ROOT}/exception.c
${MOONLIGHT_ROOT}/vector_table.c)
add_library(moonlight_platform_defaults INTERFACE)
target_include_directories(moonlight_platform_defaults INTERFACE
${MOONLIGHT_ROOT}
${THREADX4TGFS_ROOT}/src)
target_compile_options(moonlight_platform_defaults INTERFACE
-ffreestanding
-fno-builtin
-fdata-sections
-ffunction-sections)
target_link_directories(moonlight_platform_defaults INTERFACE
${THREADX4TGFS_ROOT}/src)
target_link_options(moonlight_platform_defaults INTERFACE
-nostartfiles
-nostdlib
-T ${THREADX4TGFS_ROOT}/src/${TARGET_MEM}.lds
-Wl,--gc-sections)
if(NX_DEBUG)
target_compile_definitions(moonlight_platform_defaults INTERFACE
NX_DEBUG
NX_DEBUG_PACKET)
endif()
add_library(moonlight_platform_common OBJECT
${MOONLIGHT_PLATFORM_SOURCES})
target_link_libraries(moonlight_platform_common PUBLIC
moonlight_platform_defaults
c
threadx)
add_library(moonlight_network_driver OBJECT
${MOONLIGHT_ROOT}/mnrs_network_driver.c)
target_link_libraries(moonlight_network_driver PUBLIC
moonlight_platform_defaults
c
threadx
netxduo)
function(target_add_moonlight_platform TARGET)
target_link_libraries(${TARGET} PRIVATE moonlight_platform_common)
endfunction()
function(target_add_moonlight_network_driver TARGET)
target_link_libraries(${TARGET} PRIVATE moonlight_network_driver)
endfunction()