Skip to content

Removed the extra dereference of __top_of_ram in the GNU ARMv8-A low-level initialization, so _tx_initialize_unused_memory now holds the first free address instead of garbage - #726

Open
fdesbiens wants to merge 1 commit into
eclipse-threadx:devfrom
fdesbiens:fix/issue-435

Conversation

@fdesbiens

Copy link
Copy Markdown
Contributor

Fixes #435.

__top_of_ram is defined in the linker script as __top_of_ram = .;, so it is a linker-defined symbol whose address is the value of interest. LDR x1, =__top_of_ram therefore already loads the top of RAM into x1. The LDR x1, [x1] that followed dereferenced that address and read whatever happened to be stored at the top of RAM, so _tx_initialize_unused_memory was set to garbage. The startup code in the same example builds gets this right: ldr x5, =__top_of_ram with no dereference.

The Arm Compiler ports are not affected. They load zi_limit / heap_limit, which are literal pool entries declared as .quad (Image$$TOP_OF_RAM$$Base), so the extra dereference is correct there. The GNU ports appear to have inherited the instruction sequence without adjusting it for the different symbol.

The SMP GNU ports already have the correct form, which is what the fixed ports now match. This change removes the offending instruction from the 13 non-SMP GNU Cortex-A ports, from the ARMv8-A architecture source they are generated from, and from the two Cortex-A35 module example builds. That is every remaining occurrence in the tree.

scripts/check_ports.sh passes. The gnu CI job assembles the AArch64 ports with the Arm GNU toolchain, so the change is build-verified there. It has not been run on hardware.

…level initialization, so _tx_initialize_unused_memory now holds the first free address instead of garbage

__top_of_ram is a linker-defined symbol whose address is the value of
interest, so LDR x1, =__top_of_ram already loads the top of RAM. The
following LDR x1, [x1] read whatever happened to be stored there and
handed that garbage to _tx_initialize_unused_memory.

The Arm Compiler ports are not affected: they load a literal .quad that
holds the address, so the dereference is correct there. The SMP GNU
ports already had the correct form; this aligns the remaining GNU ports
with them.

Assisted-by: Copilot (Opus 5) <noreply@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant