Skip to content

Add NXP HSE secure boot for the S32G2 (S32G274A GoldBox) - #1003

Open
dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:s32g2_hse
Open

dgarske wants to merge 1 commit into
wolfSSL:masterfrom
dgarske:s32g2_hse

Conversation

@dgarske

@dgarske dgarske commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Description

Enables NXP's Hardware Security Engine (HSE) firmware to verify wolfBoot before the Cortex-A53 executes it, anchoring the chain of trust in hardware rather than starting at wolfBoot. While the HSE host driver is generic, the S32G2 GoldBox serves as the first supported target.

Follows #984.

What It Adds

  • hal/nxp_hse.c, hal/nxp_hse.h (Generic HSE Host Driver)
    • Implements communication over the Messaging Unit (MU) supporting attribute reads, key catalog formatting, ECC public key import, Secure Memory Region (SMR) and core reset installation, SMR verification, and system image publishing.
    • Configurable via platform headers for the MU base address, descriptor memory, and NXP_HSE_ADDR64 (supports 64-bit request addresses for S32G/S32R45, defaulting to 32-bit for targets like S32K3).
  • hal/s32g2.c (S32G2 Target Integration)
    • Adds boot reporting when NXP_HSE=1 is set.
    • Adds NXP_HSE_PROVISION=1 to provision the HSE from the NOR first stage. Defaults to a dry-run "rehearsal" mode (storing nothing persistently) unless NXP_HSE_SYSIMG_OFFSET is defined to specify the system image storage location.
    • Ensures the fuse programming power supply is switched off before handing off to the OS.
    • Adds S32G2_SERDES=1 (off by default) to bring up SerDes0 as PCIe0 root complex, for NXP BSP 27/28 kernels that expect the boot loader to prepare the PCIe PHY.
  • tools/scripts/s32g2/s32g2_mkimage.py (Image Generation Tooling)
    • Adds new CLI flags for HSE integration: --hse-fw, --hse-sign (P-256), --hse-sysimg, --hse-efuse, and --hse-boot-seq.
  • tools/unit-tests/unit-nxp-hse.c (Unit Tests)
    • Adds host-based tests covering the MU handshake and request encodings, compiled and verified for both 32-bit and 64-bit address layouts.
  • docs/NXP_HSE.md & docs/Targets.md (Documentation)
    • Documents the HSE driver architecture, porting requirements, step-by-step S32G2 setup with example console output, permanent hardware state changes, and recovery procedures.
    • Updates docs/Targets.md with a high-level summary and cross-reference.

Testing

Validated on an NXP S32G2 GoldBox (S32G274A rev 2.1, HSE Standard firmware 0.1.0.5, QuadSPI NOR boot):

  • Current Revision:
    • Verified rehearsal mode (HSE successfully authenticates wolfBoot directly from NOR flash without persistent writes).
    • Verified full secure boot chain through to Linux using the stored HSE system image.
    • Verified S32G2_SERDES=1 with the PCIe slot empty: the kernel's PCIe driver starts and registers the root port. A link to a device was not tested.
  • Earlier Revision (Same Core Logic):
    • Verified initial HSE provisioning and first-boot system image loading (confirmed anti-rollback counter decrement from 159 to 158).
    • Verified negative test case: modified a single byte in the wolfBoot binary and confirmed HSE blocks execution.
  • Regression & Host Testing:
    • Confirmed standard (non-HSE) plain images continue to boot normally from both NOR and SD card.
    • Note: The 32-bit request layout has been verified via host unit tests only.

@dgarske
dgarske requested a review from night1rider November 25, 2026 20:38
@dgarske dgarske self-assigned this Nov 25, 2026

@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 #1003

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-configs.yml, .gitignore, arch.mk, docs/NXP_HSE.md, docs/README.md, docs/Targets.md, hal/nxp_hse.h, hal/s32g2.h, tools/scripts/s32g2/s32g2_mkimage.py, tools/unit-tests/Makefile
Coverage: 2 of 3 in-scope changed file(s) opened by the reviewer; not opened: tools/unit-tests/unit-nxp-hse.c

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

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

Review tier: Max

Comment thread hal/nxp_hse.c Resolved

@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 #1003

Scan targets checked: wolfboot-src, wolfboot-bugs
Not reviewed (no scan target covers them): .github/workflows/test-configs.yml, .gitignore, arch.mk, docs/NXP_HSE.md, docs/README.md, docs/Targets.md, hal/nxp_hse.h, hal/s32g2.h, tools/scripts/s32g2/s32g2_mkimage.py, tools/unit-tests/Makefile
Coverage: 0 of 2 in-scope changed file(s) opened by the reviewer; not opened: hal/nxp_hse.c, tools/unit-tests/unit-nxp-hse.c

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

Review tier: Lite

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed their stale review November 25, 2026 21:06

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

@dgarske dgarske assigned wolfSSL-Bot and unassigned dgarske Nov 25, 2026
@dgarske
dgarske requested a review from danielinux November 25, 2026 21:22
@night1rider night1rider self-assigned this Nov 25, 2026
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.

4 participants