Skip to content

Add Nuvoton NuMaker M2354 Cortex-M23 target with TrustZone - #884

Merged
danielinux merged 2 commits into
wolfSSL:masterfrom
dgarske:nuvoton_m2354
Sep 14, 2026
Merged

danielinux merged 2 commits into
wolfSSL:masterfrom
dgarske:nuvoton_m2354

Conversation

@dgarske

@dgarske dgarske commented Sep 9, 2026

Copy link
Copy Markdown
Member

Summary

Adds support for the Nuvoton NuMaker-M2354 (Cortex-M23), introducing wolfBoot's first ARMv8-M baseline architecture target (CORTEX_M23). Includes a bare-metal HAL without BSP dependencies, necessary shared boot_arm.c fixes for ARMv8-M baseline support, updated build configs, unit tests, and emulator integration.

Key Changes

  • HAL & Target Support (hal/m2354.*, arch.mk, config/examples/m2354*): Added bare-metal driver for FMC ISP flash, clock tree, UART0 console (PA6/PA7), and SAU/SCU TrustZone setup. Includes linker scripts and build configurations for TZ/non-TZ mode.
  • ARMv8-M Boot Fixes (src/boot_arm.c):
    • Fixed do_boot() logic so ARMv8-M baseline targets perform secure-to-non-secure handoff instead of falling through to ARMv6/v7.
    • Replaced wide Thumb-2 encoding (bic.w) with C masking for BLXNS compatibility.
    • Sized vector table for 116 external interrupts; set IMAGE_HEADER_SIZE to 1024 for proper VTOR alignment.
  • Crypto Math (sp_armthumb.o): Configured CORTEX_M23 to use Thumb-1 SP assembly (NO_ASM=0), dropping boot time from 2619 ms to 623 ms.
  • Tooling & Tests: Added NSCBA provisioning script (set-m2354-nscba.sh), host flash unit tests, and m33mu emulator backend updates.

Hardware & Test Status

  • NuMaker-M2354 Hardware: Tested both Non-TZ and TZ configurations (pyOCD/CMSIS-DAP). Validated image signature verification, secure-to-non-secure handoff via BLXNS, gateway veneers, swap updates, and rollback logic.
  • Regression Check: Verified M33 code generation unchanged; confirmed handoff on STM32U585 (TZEN=1).
  • CI Integration: Full update scenarios (factory boot, UART update, swap, fallback) passing on m33mu CI emulator workflow. Host unit tests pass for FMC flash driver.

Technical & Design Notes

  • Memory Constraints: Only SRAM bank 0 is enabled at reset. wolfBoot links entirely within bank 0 so stack is valid prior to hal_init() enabling additional banks.
  • Flash Aliases: Secure base is standard; NS view is offset by +0x10000000. Images are flashed separately due to non-contiguous address space under TZEN=1.
  • Flash Optimization: hal_flash_erase() skips pre-erased pages to optimize update speed; hal_flash_write() uses 16-byte multi-word ISP programming.
  • TrustZone Hardware Guard: hal_init() verifies SCU->FNSADDR against expected build bounds and panics on mismatch.

Out of Scope / Deferred

  • TRNG & WOLFCRYPT_TZ: Non-secure crypto service deferred; HAL currently omits TRNG.
  • CRPT Hardware Accelerator: Belongs in wolfCrypt port (weak isr_crpt alias included for future hookup).
  • Key Store Root of Trust: Blocked due to upstream hardware/driver issue with M2354 Key Store ECC signature generation.

@dgarske dgarske self-assigned this Sep 9, 2026
Copilot AI lite review requested due to automatic review settings September 9, 2026 23:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Adds a new Nuvoton NuMaker-M2354 (Cortex-M23 / ARMv8-M baseline) target, including a self-contained HAL plus TrustZone support and host-side unit tests for the flash ISP driver.

Changes:

  • Introduces M2354 HAL (flash ISP, clocks, UART0, TrustZone attribution) and linker scripts/configs for TZ and non-TZ builds
  • Updates shared ARM boot path to support ARMv8-M baseline (Cortex-M23) handoff semantics
  • Adds unit tests + CI build configs + provisioning script for the TrustZone flash boundary (NSCBA)

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tools/unit-tests/unit-flash-m2354.c New host unit tests for M2354 flash write/erase behavior and alias masking
tools/unit-tests/Makefile Adds the new M2354 unit test target to the unit-test build
tools/scripts/set-m2354-nscba.sh Provisioning helper script to program NSCBA via pyOCD
tools/config.mk Adds CORTEX_M23 config knob into the shared config variable list
test-app/app_m2354.c Adds a simple UART test application for update/confirm flows (TZ + non-TZ)
test-app/Makefile Adds build flags/linker scripts for M2354 test app, including TZ non-secure build handling
test-app/ARM-m2354.ld Linker script for secure/non-TZ M2354 test application
test-app/ARM-m2354-ns.ld Linker script for non-secure (TZ) M2354 test application
src/boot_arm.c Extends ARMv8-M boot procedure to include Cortex-M23 + adds M2354 IRQ vector mapping
hal/m2354.ld Secure/TZ linker script for wolfBoot on M2354 (includes NSC veneers region)
hal/m2354.h New M2354 register/geometry definitions (including NS alias conventions)
hal/m2354.c New M2354 HAL implementation (flash ISP, clocks, UART, TrustZone setup)
hal/m2354-ns.ld Non-TZ linker script variant for wolfBoot on M2354
docs/Targets.md Documents M2354 target build/flash/TZ provisioning details
config/examples/m2354.config Example config for non-TZ M2354 build
config/examples/m2354-tz.config Example config for TrustZone M2354 build
arch.mk Adds M2354 target wiring + Cortex-M23 toolchain flags + SP math selection
Makefile Adjusts main target outputs for M2354 in TZ mode (non-contiguous images)
.github/workflows/test-configs.yml Adds CI build jobs for M2354 configs

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/boot_arm.c Outdated
Comment thread tools/scripts/set-m2354-nscba.sh
Comment thread hal/m2354-ns.ld
Comment thread hal/m2354.ld
Comment thread hal/m2354.ld
Comment thread tools/unit-tests/unit-flash-m2354.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #884

Scan targets checked: wolfboot-src, wolfboot-bugs

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread hal/m2354.c Outdated
Comment thread hal/m2354.c
@danielinux
danielinux merged commit 0ca05cf into wolfSSL:master Sep 14, 2026
448 of 450 checks passed
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.

5 participants