Skip to content

ports: add ARMv7-A SMP Linux build scripts(A5,A7,A9) - #674

Open
prashit-vora wants to merge 9 commits into
eclipse-threadx:devfrom
prashit-vora:armv7-smp-linux-build-scripts
Open

ports: add ARMv7-A SMP Linux build scripts(A5,A7,A9)#674
prashit-vora wants to merge 9 commits into
eclipse-threadx:devfrom
prashit-vora:armv7-smp-linux-build-scripts

Conversation

@prashit-vora

@prashit-vora prashit-vora commented Aug 26, 2026

Copy link
Copy Markdown

Summary

  • Add GNU/ATfE build scripts for the Cortex-A5, Cortex-A7, and Cortex-A9 SMP libraries and examples.
  • Handle the lowercase assembly sources that require preprocessing on Linux.
  • Add the corresponding local crt0.S to each example and link with -nostartfiles, keeping Vectors as the entry point.

Closes #605

Verification

  • GNU Arm Embedded GCC 13.2.1: build_threadx.sh and build_threadx_sample.sh completed for A5, A7, and A9; all three sample images linked.
  • ATfE 22.1.0: scripts/check_clang.sh completed with 724/724 assembly sources, all feature-macro checks, all common C profiles, and 45/45 example builds passing.
  • CMake example stage: Cortex-R52 linked 5/5 images.

Relevant output from check_clang.sh:

== Assembly sources of every Arm gnu port ==
  724 of 724 assembled

== Common C sources, one core per architecture profile ==
  cortex_m0: 185 of 185 compiled
  cortex_m4: 185 of 185 compiled
  cortex_m23: 185 of 185 compiled
  cortex_m33: 185 of 185 compiled
  cortex_m55: 185 of 185 compiled
  cortex_a7: 185 of 185 compiled
  cortex_a53: 185 of 185 compiled
  cortex_r5: 185 of 185 compiled
  cortex_r52: 185 of 185 compiled

== Example builds, linked with lld ==
  45 of 45 example builds linked

== CMake example builds, linked with lld ==
  cortex_r52: 5 of 5 images linked

All LLVM toolchain checks passed.

NOTE: These examples were link-verified only and were not run on hardware.

@prashit-vora prashit-vora changed the title ports: add ARMv7-A SMP Linux build scripts ports: add ARMv7-A SMP Linux build scripts(A5,A7,A9) Aug 26, 2026
prashit-vora and others added 9 commits August 28, 2026 10:43
Two lines named assembly sources that eclipse-threadx#672 renamed. That change moved
twenty-nine files under gnu trees from .s to .S, because GAS runs the C
preprocessor on .S and not on .s: in a .s file every # line is a comment, so a
#define is never substituted and an #if/#else pair emits both arms. Four files
were silently doing the wrong thing as a result, including
ports_smp/cortex_a7_smp/gnu/src/tx_thread_smp_unprotect.s, which ignored all
four of its own feature macros.

These scripts had worked around the same defect with -x assembler-with-cpp
rather than hitting it, which was correct when they were written. With the
rename the flag is redundant and the lowercase names no longer resolve, so
cortex_a5_smp/build_threadx.sh failed with "cc1: fatal error:
tx_initialize_low_level.s: No such file or directory". The other seven
references to those two files across these three scripts already named them
with a capital S.

Verified with the pinned Arm GNU 14.3.rel1 rather than the 13.2 that a distro
package supplies: build_threadx.sh and build_threadx_sample.sh both succeed for
a5, a7 and a9, all three link a sample_threadx.out, and scripts/check_gcc.sh
passes end to end with its example stage reading 45 of 45, up from 42.

Assisted-by: Claude Opus 5 <noreply@anthropic.com>
@fdesbiens
fdesbiens force-pushed the armv7-smp-linux-build-scripts branch from 393e064 to f4c4982 Compare August 28, 2026 14:59
@fdesbiens

Copy link
Copy Markdown
Contributor

Thanks for this — these are exactly the three ports scripts/check_gcc.sh reported as having no script driver, so it takes the GCC example-build stage from 42 to 45.

I've rebased your branch onto current dev and pushed one small commit on top of yours, so it can go through the check that was written to cover it. Your eight commits are unchanged apart from the new base; the extra commit is two lines. Details below so nothing is a surprise.

Heads up on your local clone: the rebase rewrote the commit SHAs, so before you touch the branch again you'll want

git fetch origin && git reset --hard origin/armv7-smp-linux-build-scripts

rather than pulling, or git will try to merge the old and new histories together.


What the extra commit changes, and why

Two lines used -x assembler-with-cpp to preprocess a lowercase .s source. That was the right call when you wrote it. In the meantime #672 landed, and it fixes the underlying problem by renaming rather than by working around it:

file was now
cortex_a5_smp/…/build_threadx.sh -x assembler-with-cpp tx_initialize_low_level.s tx_initialize_low_level.S
cortex_a7_smp/…/build_threadx.sh -x assembler-with-cpp ../src/tx_thread_smp_unprotect.s ../src/tx_thread_smp_unprotect.S

The reason for the rename is that GAS runs the C preprocessor on .S and not on .s. In a .s file every # line is a comment, so a #define is never substituted and an #if/#else pair emits both arms. Twenty-nine files under gnu trees were on the wrong side of that and only three of them failed to assemble — the rest just quietly did the wrong thing. The worst was ports_smp/cortex_a7_smp/gnu/src/tx_thread_smp_unprotect.s, one of the two files your scripts name: it ignored all four of its own feature macros, wrote the caller's LR into the protection structure on every unprotect, sent an unconditional SEV, disabled FIQ regardless of TX_ENABLE_FIQ_SUPPORT, and returned twice.

So after #672 the extension carries the preprocessing and no caller has to remember the flag — and the lowercase names no longer resolve at all. Unmodified on the new base, cortex_a5_smp/build_threadx.sh failed with cc1: fatal error: tx_initialize_low_level.s: No such file or directory. Those were the only two lines affected; the other seven references to the same two files across your three scripts already named them with a capital S.

The rebase itself was clean — no conflicts, and the nine files you add are untouched.

Verified rather than assumed

With the pinned Arm GNU 14.3.rel1 toolchain, on the rebased branch:

  • build_threadx.sh and build_threadx_sample.sh both succeed for a5, a7 and a9, and all three link a sample_threadx.out.
  • scripts/check_gcc.sh passes end to end — 840 of 840 assembly sources, 185 C sources across nine core profiles, and 45 of 45 example builds linked, up from 42.
  • scripts/check_clang.sh (ATfE 22.1.0) agrees at 45 of 45.
  • scripts/check_ports.sh passes, including its new section asserting that no .s file under a gnu tree uses the preprocessor.

Your crt0.S with -nostartfiles is the same shape as a defect #673 has just fixed for the AArch64 samples, where -nostartfiles was paired with --specs=rdimon.specs and newlib's startup then referenced _init/_fini that nothing linked. You are using --specs=nosys.specs, which never reaches __libc_init_array, and the three links above confirm these ports are unaffected. Good instinct.

Two things about the checks, neither of them your fault

Nothing had actually run on this PR before now. The checks list showed only eclipsefdn/eca, but clang_check, ports_arch_check and regression_test all had runs sitting at action_required — GitHub holds workflow runs on fork pull requests until a maintainer approves them, and nobody had. That is on us. They are approved now, and the hold comes back on every push, so ping us if the list ever looks empty again.

gcc_check / gnu could not have run on the old base at all. For a pull_request event GitHub decides which workflows run from the head branch's copy of the workflow files, and that workflow only landed on dev this morning in #675. Rebasing is the only thing that makes it appear — closing and reopening does not. It has now run, and passed in 4m37s, so these three example builds are gated by the check written for them rather than merged past it. Its log reads 840 of 840 assembled and 45 of 45 example builds linked, against 42 before this PR — matching what I measured locally, and with the pinned 14.3.rel1 on both drivers.

One last note, purely informational: your verification used GCC 13.2.1, which is what the distro arm-none-eabi-gcc package usually is. The project pins Arm GNU 14.3.rel1, and it is an easy one to pick up without noticing — everything above was re-run against 14.3.rel1. In the same vein, the check_clang.sh output in the description reports 724 of 724 assembly sources; that number is 840 after #672, which corrected a glob that had been silently matching nothing, so 116 files across nine module ports had been assembled by no check at all. Nothing wrong on your side in either case.

All seven checks are green and the PR is ready to merge. Please do give the extra commit a look first, and shout if you'd rather it were done differently.

@prashit-vora

Copy link
Copy Markdown
Author

Thanks for updating the branch and explaining everything. I checked the extra commit and understand the .S changes after #672. I also noted the GCC 14.3 version and the updated assembly count of 840. Thanks for rerunning the checks.

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.

2 participants