From e204a9fe9c88b3cc9dfa3d4ec85b6aa6bac5dfb1 Mon Sep 17 00:00:00 2001 From: Dev10-sys Date: Sat, 28 Nov 2026 22:34:54 +0530 Subject: [PATCH] Exclude sample low-level initialization from module manager builds CMake support for module manager kernels uses file(GLOB ...) to collect port sources under ${TX_PORT_PATH}/module_manager/src/. In Cortex-M33, Cortex-M23, and Cortex-A35 SMP ports, sample tx_initialize_low_level.S files were placed inside module_manager/src/ rather than example_build/. This caused the sample startup file to be compiled into libthreadx.a, exporting hardcoded clock constants, memory symbols, and exception vector handlers (SysTick_Handler, HardFault_Handler, etc.) which led to multiple-definition linker collisions when linked with applications. Move tx_initialize_low_level.S to example_build/ across affected ports, delete the redundant copy in rxv2/iar/module_manager/src/, and update the Cortex-M23 GNU assembly file to reference the standard GNU linker symbol __RAM_segment_used_end__. Additionally, add a regex filter in CMakeLists.txt to exclude any tx_initialize_low_level files from TX_PORT_SOURCES during module manager builds as a permanent build-level safeguard. Fixes #852 Signed-off-by: Dev10-sys --- CMakeLists.txt | 1 + .../tx_initialize_low_level.S | 0 .../tx_initialize_low_level.S | 0 .../tx_initialize_low_level.S | 2 +- .../tx_initialize_low_level.S | 0 .../src/tx_initialize_low_level.s | 94 ------------------- 6 files changed, 2 insertions(+), 95 deletions(-) rename ports_module/cortex_a35_smp/ac6/{module_manager/src => example_build/sample_threadx_module_manager}/tx_initialize_low_level.S (100%) rename ports_module/cortex_a35_smp/gnu/{module_manager/src => example_build/sample_threadx_module_manager}/tx_initialize_low_level.S (100%) rename ports_module/cortex_m23/gnu/{module_manager/src => example_build}/tx_initialize_low_level.S (99%) rename ports_module/cortex_m33/gnu/{module_manager/src => example_build}/tx_initialize_low_level.S (100%) delete mode 100644 ports_module/rxv2/iar/module_manager/src/tx_initialize_low_level.s diff --git a/CMakeLists.txt b/CMakeLists.txt index 05784383a..0fdb01656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,7 @@ elseif(THREADX_MODULE_MANAGER) "${TX_PORT_PATH}/module_manager/src/*.S" "${TX_PORT_PATH}/module_manager/src/*.s" ) + list(FILTER TX_PORT_SOURCES EXCLUDE REGEX "tx_initialize_low_level\\.[Ss]") if(THREADX_ARCH STREQUAL "cortex_r52") file(GLOB TX_R52_BASE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/ports/cortex_r52/gnu/src/tx_thread_fiq_*.S" diff --git a/ports_module/cortex_a35_smp/ac6/module_manager/src/tx_initialize_low_level.S b/ports_module/cortex_a35_smp/ac6/example_build/sample_threadx_module_manager/tx_initialize_low_level.S similarity index 100% rename from ports_module/cortex_a35_smp/ac6/module_manager/src/tx_initialize_low_level.S rename to ports_module/cortex_a35_smp/ac6/example_build/sample_threadx_module_manager/tx_initialize_low_level.S diff --git a/ports_module/cortex_a35_smp/gnu/module_manager/src/tx_initialize_low_level.S b/ports_module/cortex_a35_smp/gnu/example_build/sample_threadx_module_manager/tx_initialize_low_level.S similarity index 100% rename from ports_module/cortex_a35_smp/gnu/module_manager/src/tx_initialize_low_level.S rename to ports_module/cortex_a35_smp/gnu/example_build/sample_threadx_module_manager/tx_initialize_low_level.S diff --git a/ports_module/cortex_m23/gnu/module_manager/src/tx_initialize_low_level.S b/ports_module/cortex_m23/gnu/example_build/tx_initialize_low_level.S similarity index 99% rename from ports_module/cortex_m23/gnu/module_manager/src/tx_initialize_low_level.S rename to ports_module/cortex_m23/gnu/example_build/tx_initialize_low_level.S index 7e73dc96a..91309e1da 100644 --- a/ports_module/cortex_m23/gnu/module_manager/src/tx_initialize_low_level.S +++ b/ports_module/cortex_m23/gnu/example_build/tx_initialize_low_level.S @@ -83,7 +83,7 @@ _tx_initialize_low_level: /* Set base of available memory to end of non-initialised RAM area. */ LDR r0, =_tx_initialize_unused_memory // Build address of unused memory pointer - LDR r1, =Image$$ARM_LIB_STACK$$ZI$$Limit // Build first free address + LDR r1, =__RAM_segment_used_end__ // Build first free address ADDS r1, r1, #4 // STR r1, [r0] // Setup first unused memory pointer diff --git a/ports_module/cortex_m33/gnu/module_manager/src/tx_initialize_low_level.S b/ports_module/cortex_m33/gnu/example_build/tx_initialize_low_level.S similarity index 100% rename from ports_module/cortex_m33/gnu/module_manager/src/tx_initialize_low_level.S rename to ports_module/cortex_m33/gnu/example_build/tx_initialize_low_level.S diff --git a/ports_module/rxv2/iar/module_manager/src/tx_initialize_low_level.s b/ports_module/rxv2/iar/module_manager/src/tx_initialize_low_level.s deleted file mode 100644 index 3faf9bc95..000000000 --- a/ports_module/rxv2/iar/module_manager/src/tx_initialize_low_level.s +++ /dev/null @@ -1,94 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2024 Microsoft Corporation - * Copyright (c) 2026-present Eclipse ThreadX contributors - * - * This program and the accompanying materials are made available under the - * terms of the MIT License which is available at - * https://opensource.org/licenses/MIT. - * - * SPDX-License-Identifier: MIT - **************************************************************************/ - - -/**************************************************************************/ -/**************************************************************************/ -/** */ -/** ThreadX Component */ -/** */ -/** Initialize */ -/** */ -/**************************************************************************/ -/**************************************************************************/ - - extern __tx_initialize_unused_memory - - section .text:CODE:ROOT - -/**************************************************************************/ -/* */ -/* FUNCTION RELEASE */ -/* */ -/* _tx_initialize_low_level RXv2/IAR */ -/* 6.1.10 */ -/* AUTHOR */ -/* */ -/* William E. Lamie, Microsoft Corporation */ -/* */ -/* DESCRIPTION */ -/* */ -/* This function is responsible for any low-level processor */ -/* initialization, including setting up interrupt vectors, setting */ -/* up a periodic timer interrupt source, saving the system stack */ -/* pointer for use in ISR processing later, and finding the first */ -/* available RAM memory address for tx_application_define. */ -/* */ -/* INPUT */ -/* */ -/* None */ -/* */ -/* OUTPUT */ -/* */ -/* None */ -/* */ -/* CALLS */ -/* */ -/* None */ -/* */ -/* CALLED BY */ -/* */ -/* _tx_initialize_kernel_enter ThreadX entry function */ -/**************************************************************************/ - public __tx_initialize_low_level - -__tx_initialize_low_level: - - /* Save the first available memory address. */ - // _tx_initialize_unused_memory = (VOID_PTR) &free_mem_start; - - MOV.L #__tx_free_memory_start, R1 // Pick up unused memory address - MOV.L #__tx_initialize_unused_memory,R2 - MOV.L R1,[R2] // Save first free memory address - - /* Set priority of SWINT to 1. */ - MOV.L #0x87303, r1 - MOV.L #1, r2 - MOV.B r2, [r1] - - /* Enable SWINT. */ - MOV.L #0x87203, r1 - MOV.B [r1], r2 - OR #(1 << 3), r2 - MOV.B r2, [r1] - - /* Enable SWINT2. */ - OR #(1 << 2), r2 - MOV.B r2, [r1] - - RTS - - section FREEMEM:DATA - public __tx_free_memory_start -__tx_free_memory_start - DS32 4 - - END