Skip to content

Added Cortex-M55 ThreadX module ports for GNU and IAR - #810

Open
rahmanih wants to merge 6 commits into
devfrom
feature/add-cm55-threadx-modules
Open

rahmanih wants to merge 6 commits into
devfrom
feature/add-cm55-threadx-modules

Conversation

@rahmanih

@rahmanih rahmanih commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

ThreadX Modules lacked a Cortex-M55 port for GNU and IAR. The port needs to build in C99 and preserve the secure stack and context save checks used by the maintained Armv8-M ports.

Added the GNU and IAR module ports, corrected GNU assembly preprocessing and shared MPU limit encoding, and carried forward the maintained checks. The module port initializes secure stacks at startup, validates thread handles, and clears the active Secure stack registers before release. The GNU module harness covers secure-only and dual-state operation on QEMU's AN547 machine. A Linux test exercises the Secure stack guards with simulated registers and CMSE decisions.

GCC 14 passed 26/26 QEMU tests and 14/14 Linux Module Manager tests. The MPU limit and secure stack startup regressions failed before their fixes. The exhaustion regression detected a lost context after Secure heap allocation failed. GNU M55 manager C coverage reached 97/97 lines and 39/39 branch outcomes in secure-only QEMU and 216/232 lines and 101/121 branch outcomes in dual-state QEMU. Combined with the Linux guard test, dual-state coverage reached 232/232 lines and 121/121 branch outcomes. The contributor reported STM32N6 tests with GNU and IAR. The follow-ups ran locally with GNU.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Test Results FreeRTOS

3 tests  ±0   3 ✅ ±0   0s ⏱️ -1s
1 suites ±0   0 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 3fa8630. ± Comparison against base commit 584516a.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Test Results RISC-V

1 194 tests  ±0   1 194 ✅ ±0   6m 32s ⏱️ -1s
   12 suites ±0       0 💤 ±0 
   12 files   ±0       0 ❌ ±0 

Results for commit 3fa8630. ± Comparison against base commit 584516a.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Test Results SMP

605 tests  ±0   605 ✅ ±0   5m 15s ⏱️ +8s
  5 suites ±0     0 💤 ±0 
  5 files   ±0     0 ❌ ±0 

Results for commit 3fa8630. ± Comparison against base commit 584516a.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
common_smp.src 100% 81% ➖
Summary 100% (5576 / 5585) 81% (3135 / 3872) ➖

Minimum allowed line rate is 99%

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Test Results ThreadX

  7 files  ±0    7 suites  ±0   3m 20s ⏱️ -5s
842 tests +5  842 ✅ +5  0 💤 ±0  0 ❌ ±0 
878 runs  +5  878 ✅ +5  0 💤 ±0  0 ❌ ±0 

Results for commit 3fa8630. ± Comparison against base commit 584516a.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Code Coverage

Package Line Rate Branch Rate Health
common.src 99% 78% ➖
Summary 99% (4773 / 4802) 78% (2691 / 3458) ➖

Minimum allowed line rate is 99%

@rahmanih
rahmanih changed the base branch from master to dev October 17, 2026 17:31
The new Cortex-M55 port required GNU C extensions to build. Several
assembly files also needed preprocessing, and the port lacked the current
secure stack and context save checks used by the maintained ports. Shared
memory limits mixed address and MPU attribute bits.

Used C99-compatible GNU assembly syntax and preprocessed the mode-specific
sources. Applied the maintained checks to GNU and IAR, corrected the MPU
limit encoding, and ran the GNU module manager in secure-only mode on the
AN547 QEMU machine. Inline CMSE register access retains the existing
MISRA C:2023 Rule 1.2 and Directive 4.3 deviations for hardware access.

GCC 14 built the dual-state GNU archives in C99 mode. QEMU passed 4/4 on M3,
4/4 on M4, and 3/3 on M55 with PRIMASK and with BASEPRI plus WFI. The M55
MPU limit regression failed before the encoding fix. Secure-only QEMU
covered 90/97 executable lines and 30/39 branch outcomes in M55 manager C.
IAR and STM32N6 were not run locally.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
@fdesbiens fdesbiens changed the title feat(ports_module): Add Cortex-M55 GNU and IAR ThreadX module ports Added Cortex-M55 ThreadX module ports for GNU and IAR Nov 25, 2026
The M55 module SVC handler skipped secure stack initialization, and the
dispatcher validated thread arguments by size. Releasing an active stack left
its address in the Secure stack registers.

Dispatch the startup SVC by its return address, authenticate live thread
objects, and clear the active stack registers and context ownership on
release. GNU register access uses MISRA C:2023 Rule 1.2 and Directive 4.3
deviations for hardware access. Rule 11.6 applies to comparing a stack limit
address with the register value.

QEMU passed 4/4 on M3, 4/4 on M4, and 3/3 in each M55 secure-only and
dual-state interrupt configuration. The startup regression failed before
the fix. GCC covered 97/97 lines and 39/39 branch outcomes in secure-only
GNU M55 manager C and 206/232 lines and 92/121 branch outcomes in dual-state
manager C. IAR and STM32N6 testing of this follow-up remains outstanding.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
Signed-off-by: Frédéric Desbiens <frederic.desbiens@eclipse-foundation.org>
The dual-state module tests exercised secure stack allocation and release
with room in the allocator and the context pool. They left the startup and
interrupt caller checks in the public APIs partly untested.

Bounded the QEMU Secure heap and added a regression that exhausts both
resources, retries after a release, and calls the public APIs during startup
and from timer callbacks. The fixture documents its MISRA C:2023 deviations
for the heap's alignment and the newlib system-call interface.

GCC 14 and QEMU passed 26/26 across seven Cortex-M configurations. The test
failed when allocation stopped returning a context after malloc failure.
Combined M55 dual-state manager C coverage reached 216/232 lines and
101/121 branch outcomes. Both secure stack API wrappers reached full line
and branch coverage.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
Signed-off-by: Frédéric Desbiens <frederic.desbiens@eclipse-foundation.org>
The dual-state QEMU tests covered normal secure stack operations, resource
exhaustion, and timer callers. Secure-side rejection paths remained uncovered.

Moved register access into GNU port macros and added a Linux regression that
compiles the port source with a simulated register bank and CMSE decisions.
The Cortex-M55 object retained identical instructions and relocations.

GCC 14 passed 26/26 QEMU tests and 14/14 Linux Module Manager tests. QEMU
exercised 216/232 GNU dual-state manager C lines and 101/121 branch outcomes.
Combined with the Linux guard test, coverage reached 232/232 lines and
121/121 branch outcomes.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
Signed-off-by: Frédéric Desbiens <frederic.desbiens@eclipse-foundation.org>
@fdesbiens

Copy link
Copy Markdown
Contributor

@rahmanih Could you build the updated PR head (1c1bf502) with IAR and test it on STM32N6 in secure-only and dual-state modes? Please verify that a protected module can load, start, use its granted shared memory, stop, and unload in both modes. In dual-state mode, please also check that secure stacks initialize at boot and that a worker can allocate a secure stack, keep it across context switches, and release it.

Please share the IAR version, configurations tested, and results here.

@rahmanih

rahmanih commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Hello @fdesbiens,

tested using the EWARM IAR 9.70.4 against the 1c1bf502 and below the results:

  • ThreadX Module : Secure Only
Tx_MPU startup: NUCLEO-N657X0-Q Cortex-M55
Tx_MPU Secure ThreadX module manager, TX_SINGLE_MODE_SECURE
Tx_MPU manager: start unprivileged module
Tx_MPU module: write shared read/write memory (progress=88)
Tx_MPU module: read shared read/write memory (progress=66)
Tx_MPU module: read shared read-only memory (progress=55)
Tx_MPU module: attempt protected write (expect MPU fault) (progress=77)
Tx_MPU expected MPU fault: CFSR=0x00000082 MMFAR=0x341ff000, owner verified
Tx_MPU XIP verified: faulting instruction PC=0x70100190 in external flash
Tx_MPU shared memory: RO preserved, RW verified
Tx_MPU manager: stop and unload module
Tx_MPU PASS: 4 messages, one expected MPU fault, stop/unload OK
  • ThreadX Module: Non Secure Only
Tx_MPU startup: NUCLEO-N657X0-Q Cortex-M55
Tx_MPU Non-secure ThreadX module manager, TX_SINGLE_MODE_NON_SECURE
Module: code=0x241069E0 RO=0x241FF000 RW=0x241FF100
Module progress 1: write RW (message=88)
Module progress 2: read RW (message=66)
Module progress 3: read RO (message=55)
Module progress 4: attempt write to RO (message=77)
Non-secure fault: CFSR=0x00000082 MMFAR=0x241FF000 PC=0x24106B70 owner=1
Tx_MPU PASS: 4 messages, one expected MPU fault, sentinels verified, module stopped and unloaded
  • ThreadX Module: Dual Mode
Tx_MPU startup: NUCLEO-N657X0-Q Cortex-M55
Tx_MPU: dual-state ThreadX, Non-secure module manager and Secure stack services
Module: code=0x24107E00 RO=0x241FF000 RW=0x241FF100
Module progress 1: LED thread returned from Secure PG0 toggle (message=99)
Module progress 2: write RW (message=88)
Module progress 3: read RW (message=66)
Module progress 4: read RO (message=55)
Module progress 5: attempt write to RO (message=77)
Non-secure fault: CFSR=0x00000082 MMFAR=0x241FF000 PC=0x24108034 owner=1
Tx_MPU PASS: Secure LED toggle, second thread MPU fault, sentinels verified, module stopped and unloaded

regards
Haithem.

@rahmanih

rahmanih commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

for GCC:

  • Secure Only
Tx_MPU startup: NUCLEO-N657X0-Q Cortex-M55
Tx_MPU Secure ThreadX module manager, TX_SINGLE_MODE_SECURE
Tx_MPU module: write shared read/write memory (progress=88)
Tx_MPU module: read shared read/write memory (progress=66)
Tx_MPU module: read shared read-only memory (progress=55)
Tx_MPU module: attempt protected write (expect MPU fault) (progress=77)
Tx_MPU expected MPU fault: CFSR=0x00000082 MMFAR=0x341ff000, owner verified
Tx_MPU XIP verified: faulting instruction PC=0x701004c2 in external flash
Tx_MPU shared memory: RO preserved, RW verified
Tx_MPU manager: stop and unload module
  • NonSecure
Tx_MPU startup: NUCLEO-N657X0-Q Cortex-M55
Tx_MPU: TX_SINGLE_MODE_NON_SECURE
Module progress 1: write RW (message=88)
Module progress 2: read RW (message=66)
Module progress 3: read RO (message=55)
Module progress 4: attempt write to RO (message=77)
Non-secure fault: CFSR=0x00000082 MMFAR=0x241FF000 PC=0x24109B4A owner=1
Tx_MPU PASS: Non-secure MPU fault, sentinels verified, module stopped and unloaded
  • Dual-State
Tx_MPU startup: NUCLEO-N657X0-Q Cortex-M55
Tx_MPU: dual-state ThreadX, Non-secure module manager and Secure stack services
Module: code=0x24109BC0 RO=0x241FF000 RW=0x241FF100
Module progress 1: LED thread returned from Secure PG0 toggle (message=99)
Module progress 2: write RW (message=88)
Module progress 3: read RW (message=66)
Module progress 4: read RO (message=55)
Module progress 5: attempt write to RO (message=77)
Non-secure fault: CFSR=0x00000082 MMFAR=0x241FF000 PC=0x24109E82 owner=1
Tx_MPU PASS: Secure LED toggle, second thread MPU fault, sentinels verified, module stopped and unloaded

The Cortex-M55 tests overlapped new Module Manager and pointer-context
tests on dev. The M55 shell called only scalar entries, so pointer
workers did not start when the opt-in APIs were enabled.

Preserved the Cortex-A35 tests and gave the QEMU results distinct slots.
Used the shared module entry dispatcher in the GNU and IAR M55 shells.
The QEMU workflow exercises both pointer settings across the three ports.

Arm GNU 14.2 and QEMU 10.2 passed 38/38 tests across ten configurations,
including both M55 security modes and dual-state timer ISR processing.
GCC 14 passed 136/136 Linux host tests.

Assisted-by: Codex (GPT-6.2-Sol) <noreply@openai.com>
@fdesbiens

Copy link
Copy Markdown
Contributor

Thanks for running the STM32N6 tests, @rahmanih. I resolved the merge conflicts and updated the Cortex-M55 module thread shell to support pointer-context entries.

Could you build and run 3fa8630d on the NUCLEO-N657X0-Q with IAR and TX_ENABLE_POINTER_CONTEXT enabled? Please verify that a module worker and timer callback receive their pointer arguments. In dual-state mode, please also confirm that secure stacks initialize at boot and that a worker can allocate a secure stack, retain it across context switches, and release it. Please share the IAR version, configurations tested, and results.

This branch has not been deployed

No deployments
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