adds smp demo as target

This commit is contained in:
2026-03-12 15:57:28 +01:00
parent 1da9671197
commit c390c4b8db

View File

@@ -15,6 +15,9 @@ target_link_libraries(c PUBLIC gcc)
set(THREADX_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/threadx) set(THREADX_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/threadx)
add_subdirectory(third-party/threadx) add_subdirectory(third-party/threadx)
target_link_libraries(threadx PUBLIC c) target_link_libraries(threadx PUBLIC c)
#Adds threadx_smp
add_subdirectory(port/threadx_smp)
target_link_libraries(threadx_smp PUBLIC c)
# Adds netxduo # Adds netxduo
set(NETXDUO_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/threadx) set(NETXDUO_CUSTOM_PORT ${CMAKE_CURRENT_LIST_DIR}/port/threadx)
set(NXD_ENABLE_FILE_SERVERS OFF) set(NXD_ENABLE_FILE_SERVERS OFF)
@@ -30,12 +33,12 @@ endif()
############################################################################### ###############################################################################
project(threadx_demo C ASM) project(threadx_demo C ASM)
option(NX_DEBUG "compile netxduo debug output in" OFF) option(NX_DEBUG "compile netxduo debug output in" OFF)
set(TARGET_MEM "ram" CACHE STRING "memory map to use" ) set(TARGET_MEM "ram" CACHE STRING "memory map to use")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
function(setup_target TARGET) function(setup_target TARGET)
set(options) set(options)
set(oneValueArgs) # none for now set(oneValueArgs) # none for now
set(multiValueArgs LIBRARIES SOURCES) set(multiValueArgs LIBRARIES SOURCES)
cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(ST_UNPARSED_ARGUMENTS) if(ST_UNPARSED_ARGUMENTS)
@@ -43,13 +46,13 @@ function(setup_target TARGET)
endif() endif()
add_executable(${TARGET}) add_executable(${TARGET})
target_sources(${TARGET} PRIVATE target_sources(${TARGET} PRIVATE
port/picolibc/port.c port/picolibc/port.c
port/moonlight/bootup.c port/moonlight/bootup.c
port/moonlight/board.c port/moonlight/board.c
port/moonlight/trap_non_vectored.c port/moonlight/trap_non_vectored.c
port/moonlight/exception.c port/moonlight/exception.c
port/moonlight/vector_table.c port/moonlight/vector_table.c
) )
if("netxduo" IN_LIST ST_LIBRARIES) if("netxduo" IN_LIST ST_LIBRARIES)
target_sources(${TARGET} PRIVATE port/moonlight/mnrs_network_driver.c) target_sources(${TARGET} PRIVATE port/moonlight/mnrs_network_driver.c)
@@ -67,7 +70,7 @@ function(setup_target TARGET)
-ffunction-sections -ffunction-sections
) )
if(NX_DEBUG) if(NX_DEBUG)
target_compile_definitions(${TARGET} PRIVATE NX_DEBUG NX_DEBUG_PACKET) target_compile_definitions(${TARGET} PRIVATE NX_DEBUG NX_DEBUG_PACKET)
endif() endif()
target_link_directories(${TARGET} PRIVATE src) # needed for linker script includes target_link_directories(${TARGET} PRIVATE src) # needed for linker script includes
target_link_options(${TARGET} PRIVATE target_link_options(${TARGET} PRIVATE
@@ -80,19 +83,16 @@ function(setup_target TARGET)
if(ST_LIBRARIES) if(ST_LIBRARIES)
target_link_libraries(${TARGET} PRIVATE ${ST_LIBRARIES}) target_link_libraries(${TARGET} PRIVATE ${ST_LIBRARIES})
endif() endif()
target_link_libraries(${TARGET} PRIVATE threadx)
add_custom_command(TARGET ${TARGET} POST_BUILD add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${OBJCOPY} -O ihex $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.hex COMMAND ${OBJCOPY} -O ihex $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.hex
COMMAND ${OBJCOPY} -O binary $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.bin COMMAND ${OBJCOPY} -O binary $<TARGET_FILE:${TARGET}> ${CMAKE_BINARY_DIR}/${TARGET}.bin
COMMAND ${SIZE} $<TARGET_FILE:${TARGET}> COMMAND ${SIZE} $<TARGET_FILE:${TARGET}>
COMMAND ${OBJDUMP} -S $<TARGET_FILE:${TARGET}> > ${TARGET}.dis COMMAND ${OBJDUMP} -S $<TARGET_FILE:${TARGET}> > ${TARGET}.dis
COMMENT "Creating collateral for ${TARGET}" COMMENT "Creating collateral for ${TARGET}"
) )
endfunction() endfunction()
setup_target(thread_demo SOURCES src/thread_demo/main.c) setup_target(thread_demo LIBRARIES threadx SOURCES src/thread_demo/main.c)
setup_target(tcp_demo setup_target(tcp_demo LIBRARIES threadx netxduo SOURCES src/tcp_demo/main.c)
LIBRARIES netxduo setup_target(smp_demo LIBRARIES threadx_smp SOURCES src/thread_demo/main.c)
SOURCES src/tcp_demo/main.c
)