Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ CTestTestfile.cmake
# Local build artifacts
build_m7/
.codex
build_r52/
__pycache__/
*.pyc
build_r52_vfp/
build_r52_uart/
build_r52_mpu/
build_r52_all/
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ endif()

option(THREADX_SMP "Build ThreadX SMP version" OFF)

# Enable testing at the top level so that tests registered by ports and
# example builds further down the tree are discoverable with ctest from the
# build root. Without this, add_test() in a subdirectory still generates a
# CTestTestfile.cmake there, but the root does not reference it and
# "ctest --test-dir <build>" reports no tests at all.
enable_testing()

if(THREADX_SMP)
set(TX_PORT_DIR "ports_smp")
set(TX_COMMON_DIR "common_smp")
Expand Down
45 changes: 45 additions & 0 deletions cmake/cortex_r52.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) 2026-present Eclipse ThreadX contributors
# SPDX-License-Identifier: MIT
# Some portions generated by Claude Code (Opus 5).
#
# Toolchain file for Arm Cortex-R52 (Armv8-R, AArch32) using GNU tools.

# Name of the target
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR cortex-r52)

set(THREADX_ARCH "cortex_r52")
set(THREADX_TOOLCHAIN "gnu")

# Floating-point ABI. Cortex-R52 always implements at least a single-precision
# FPU -- GCC rejects "+nofp" for this core and offers only "+nofp.dp" (drop
# double precision). There is therefore no FPU-less R52, so the soft-float
# baseline selects the soft *ABI* rather than removing the FPU. The hard-float
# variant with lazy VFP context save arrives with AR1 milestone M5.
if(NOT DEFINED TX_R52_FLOAT_ABI)
set(TX_R52_FLOAT_ABI "soft" CACHE STRING "R52 float ABI: soft | hard")
endif()

set(MCPU_FLAGS "-marm -mcpu=cortex-r52")
if(TX_R52_FLOAT_ABI STREQUAL "hard")
set(VFP_FLAGS "-mfpu=fpv5-d16 -mfloat-abi=hard")
else()
set(VFP_FLAGS "-mfloat-abi=soft")
endif()
set(SPEC_FLAGS "--specs=nosys.specs")

include(${CMAKE_CURRENT_LIST_DIR}/arm-none-eabi.cmake)

# Pin the reference cross toolchain (see AGENTS.md, "Compiler"). Absolute paths
# are used deliberately so the build does not depend on PATH ordering. Override
# with -DARM_TOOLCHAIN_PATH=<dir containing arm-none-eabi-gcc> to build with a
# different compiler -- for example the advisory newest-compiler lane.
if(NOT DEFINED ARM_TOOLCHAIN_PATH)
set(ARM_TOOLCHAIN_PATH
"$ENV{HOME}/toolchains/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi/bin")
endif()
if(EXISTS "${ARM_TOOLCHAIN_PATH}/arm-none-eabi-gcc")
set(CMAKE_C_COMPILER "${ARM_TOOLCHAIN_PATH}/arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "${ARM_TOOLCHAIN_PATH}/arm-none-eabi-g++")
set(CMAKE_ASM_COMPILER "${ARM_TOOLCHAIN_PATH}/arm-none-eabi-gcc")
endif()
77 changes: 77 additions & 0 deletions ports/cortex_r52/gnu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright (c) 2026-present Eclipse ThreadX contributors
# SPDX-License-Identifier: MIT
# Some portions generated by Claude Code (Opus 5).

target_sources(${PROJECT_NAME}
PRIVATE
# {{BEGIN_TARGET_SOURCES}}
${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_fiq_context_restore.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_fiq_context_save.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_fiq_nesting_end.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_fiq_nesting_start.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_irq_nesting_end.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_irq_nesting_start.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_schedule.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_build.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_vectored_context_save.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.S
${CMAKE_CURRENT_LIST_DIR}/src/tx_port_offset_check.c
# {{END_TARGET_SOURCES}}
)

target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)

# Lazy floating-point context save and restore. PUBLIC because the assembly
# in the library and the application must agree: the flag changes which
# registers the context switch saves, so a mismatched application would either
# lose floating-point state or misread the thread control block. Requires a
# floating-point ABI, so pair it with -DTX_R52_FLOAT_ABI=hard.
option(TX_R52_ENABLE_VFP "Build with lazy VFP context save/restore" OFF)

# FIQ support and interrupt nesting. These change which registers the
# assembly saves and what tx_port.h reports in TX_PORT_SPECIFIC_BUILD_OPTIONS,
# so like the VFP flag they must be PUBLIC: library and application have to
# agree. FIQ nesting additionally requires FIQ support.
option(TX_R52_ENABLE_FIQ "Build with FIQ support" OFF)
option(TX_R52_ENABLE_IRQ_NESTING "Build with nested IRQ support" OFF)
option(TX_R52_ENABLE_FIQ_NESTING "Build with nested FIQ support" OFF)

if(TX_R52_ENABLE_FIQ)
target_compile_definitions(${PROJECT_NAME} PUBLIC TX_ENABLE_FIQ_SUPPORT)
endif()
if(TX_R52_ENABLE_IRQ_NESTING)
target_compile_definitions(${PROJECT_NAME} PUBLIC TX_ENABLE_IRQ_NESTING)
endif()
if(TX_R52_ENABLE_FIQ_NESTING)
if(NOT TX_R52_ENABLE_FIQ)
message(FATAL_ERROR
"TX_R52_ENABLE_FIQ_NESTING requires TX_R52_ENABLE_FIQ: nested FIQ "
"handling is meaningless without FIQ support compiled in.")
endif()
target_compile_definitions(${PROJECT_NAME} PUBLIC TX_ENABLE_FIQ_NESTING)
endif()
if(TX_R52_ENABLE_VFP)
target_compile_definitions(${PROJECT_NAME} PUBLIC TX_ENABLE_VFP_SUPPORT)
if(NOT TX_R52_FLOAT_ABI STREQUAL "hard")
message(WARNING
"TX_R52_ENABLE_VFP is on but TX_R52_FLOAT_ABI is '${TX_R52_FLOAT_ABI}'. "
"The compiler will not emit floating-point instructions, so the VFP "
"context path will never be exercised. Use -DTX_R52_FLOAT_ABI=hard.")
endif()
endif()

# Armv8-R AEM FVP example builds (boot check now, kernel demo from AR1/M2).
# Off by default so the default build stays a pure static-library build.
option(TX_R52_BUILD_FVP_EXAMPLE "Build the Armv8-R AEM FVP example targets" OFF)
if(TX_R52_BUILD_FVP_EXAMPLE)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/example_build/fvp_baser_aemv8r)
endif()
Loading