From 38bcb40fc0e74aab83bd4ca66f2c3214466c2b2b Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Thu, 11 Mar 2021 21:26:51 +0100 Subject: [PATCH 1/2] ports: cortex_m33: Add CMakeLists.txt This commit adds a CMakeLists.txt file for Arm Cortex-M33. Signed-off-by: Kevin Townsend Signed-off-by: Jimmy Brisson --- cmake/cortex_m33.cmake | 14 ++++++++++++++ ports/cortex_m33/gnu/CMakeLists.txt | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 cmake/cortex_m33.cmake create mode 100644 ports/cortex_m33/gnu/CMakeLists.txt diff --git a/cmake/cortex_m33.cmake b/cmake/cortex_m33.cmake new file mode 100644 index 000000000..da5e7569e --- /dev/null +++ b/cmake/cortex_m33.cmake @@ -0,0 +1,14 @@ + +# Name of the target +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR cortex-m33) + +set(THREADX_ARCH "cortex_m33") +set(THREADX_TOOLCHAIN "gnu") + +set(MCPU_FLAGS "-mthumb -mcpu=cortex-m33+nodsp+nofp") +set(VFP_FLAGS "-mfloat-abi=softfp") +set(SPEC_FLAGS "--specs=nosys.specs") +# set(LD_FLAGS "-nostartfiles") + +include(${CMAKE_CURRENT_LIST_DIR}/arm-none-eabi.cmake) diff --git a/ports/cortex_m33/gnu/CMakeLists.txt b/ports/cortex_m33/gnu/CMakeLists.txt new file mode 100644 index 000000000..0e4a85248 --- /dev/null +++ b/ports/cortex_m33/gnu/CMakeLists.txt @@ -0,0 +1,26 @@ + +target_sources(${PROJECT_NAME} PRIVATE + # {{BEGIN_TARGET_SOURCES}} + ${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_secure_stack_allocate.c + ${CMAKE_CURRENT_LIST_DIR}/src/txe_thread_secure_stack_free.c + ${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_low_level.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_restore.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_save.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_control.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_disable.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_restore.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_schedule.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_secure_stack.c + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_secure_stack_allocate.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_secure_stack_free.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_build.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_error_handler.c + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_error_notify.c + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S + ${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.S + # {{END_TARGET_SOURCES}} +) + +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_CURRENT_LIST_DIR}/inc +) From c5474e6b1f5d8b15e61c2dfa251aab813d9a9d3a Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Fri, 12 Mar 2021 14:06:50 -0600 Subject: [PATCH 2/2] Skip VFP access for Cortex-M33 without FP There exist some platforms, such as the MPS3-AN524, that are Cortex-M33 and do not have any floating point unit. Previously, the assembler would error on these targets. Signed-off-by: Jimmy Brisson --- cmake/arm-none-eabi.cmake | 2 +- ports/cortex_m33/gnu/src/tx_thread_schedule.S | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/arm-none-eabi.cmake b/cmake/arm-none-eabi.cmake index 147ce7a25..85311ae5c 100644 --- a/cmake/arm-none-eabi.cmake +++ b/cmake/arm-none-eabi.cmake @@ -17,7 +17,7 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) set(CMAKE_C_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} ${SPEC_FLAGS} -fdata-sections -ffunction-sections -mlong-calls" CACHE INTERNAL "c compiler flags") set(CMAKE_CXX_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -fdata-sections -ffunction-sections -fno-rtti -fno-exceptions -mlong-calls" CACHE INTERNAL "cxx compiler flags") -set(CMAKE_ASM_FLAGS "${MCPU_FLAGS} -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags") +set(CMAKE_ASM_FLAGS "${MCPU_FLAGS} ${VFP_FLAGS} -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags") set(CMAKE_EXE_LINKER_FLAGS "${MCPU_FLAGS} ${LD_FLAGS} -Wl,--gc-sections" CACHE INTERNAL "exe link flags") SET(CMAKE_C_FLAGS_DEBUG "-Og -g -ggdb3" CACHE INTERNAL "c debug compiler flags") diff --git a/ports/cortex_m33/gnu/src/tx_thread_schedule.S b/ports/cortex_m33/gnu/src/tx_thread_schedule.S index 31da6fc89..29a5c81b5 100644 --- a/ports/cortex_m33/gnu/src/tx_thread_schedule.S +++ b/ports/cortex_m33/gnu/src/tx_thread_schedule.S @@ -345,6 +345,8 @@ _tx_svc_secure_init: .thumb_func .type _tx_vfp_access, function _tx_vfp_access: +#if TX_ENABLE_FPU_SUPPORT VMOV.F32 s0, s0 // Simply access the VFP +#endif BX lr // Return to caller .end