Skip to content

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

Merged
night1rider merged 1 commit into
wolfSSL:masterfrom
dgarske:s32g2_hse
Dec 3, 2026
Merged

night1rider merged 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.
    • Switches the fuse programming power supply off once HSE is running and provisioning has read it, early in hal_init(), with a second switch-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, tools/unit-tests/unit-s32g2-mkimage.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.
    • Adds a test of the image builder's HSE options: reads back the IVT, application header, signature block, HSE firmware placement and lowest system image offset the way the Boot ROM, HSE and hal/s32g2.c read them, and checks the option combinations it must refuse.
  • 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 a step-2 style image (fuse supply on, --hse-sysimg --hse-efuse): the supply is switched off right after the HSE report and Linux boots; the anti-rollback counter is unchanged.
    • 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

@night1rider night1rider 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.

Some items from skoll that caught my eye.

Comment thread hal/s32g2.c Resolved
Comment thread hal/s32g2.c Resolved
Comment thread hal/s32g2.c Resolved
Comment thread hal/s32g2.c Resolved
Comment thread hal/nxp_hse.c Resolved
Comment thread hal/s32g2.c Resolved
@dgarske dgarske self-assigned this Nov 30, 2026
Copilot AI balanced review requested due to automatic review settings December 1, 2026 00:20

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.

🟡 Changes recommended

Provisioning can erase appended HSE firmware needed at reset, and console-disabled builds fail because logging-only variables trigger warnings treated as errors.

4 open issues
What changed in this PR

Adds hardware-backed verification of wolfBoot on the S32G2 GoldBox, extending the existing boot chain so NXP HSE verifies wolfBoot before the Cortex-A53 executes it.

Changes:

  • Adds an HSE host driver and S32G2 provisioning, status reporting, and fuse-supply shutdown.
  • Extends image generation for HSE firmware, signatures, system images, and secure boot; adds optional PCIe PHY initialization.
  • Adds provisioning documentation, host tests for both address layouts, and CI build coverage.
File Description
tools/​unit-tests/​unit-nxp-hse.c Tests MU communication and HSE request layouts.
tools/​unit-tests/​Makefile Builds tests for 32-bit and 64-bit address layouts.
tools/​scripts/​s32g2/​s32g2_mkimage.py Adds HSE image packaging and signing options.
hal/​s32g2.h Defines HSE, fuse-supply, and SerDes hardware constants.
hal/​s32g2.c Integrates provisioning, reporting, supply shutdown, and optional PCIe setup.
hal/​nxp_hse.h Defines the HSE host interface and constants.
hal/​nxp_hse.c Implements HSE communication and secure-boot services.
docs/​Targets.md Summarizes HSE support and optional SerDes initialization.
docs/​README.md Links the HSE guide.
docs/​NXP_HSE.md Documents provisioning, permanent effects, recovery, and limitations.
arch.mk Adds HSE and SerDes build options.
.gitignore Ignores generated HSE test binaries.
.github/​workflows/​test-configs.yml Adds reporting, provisioning, and rehearsal build jobs.

Review effort: Balanced

Comment thread hal/nxp_hse.c Resolved
Comment thread hal/s32g2.c Resolved
Comment thread hal/s32g2.c Resolved
Comment thread arch.mk Resolved
@dgarske
dgarske force-pushed the s32g2_hse branch 2 times, most recently from 20dbb9f to 7206ea8 Compare December 1, 2026 15:09
@dgarske
dgarske requested a review from night1rider December 1, 2026 18:11
@dgarske dgarske removed their assignment Dec 1, 2026

@night1rider night1rider 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.

Some more finds

Comment thread hal/nxp_hse.c Resolved
Comment thread hal/nxp_hse.c Resolved
Comment thread hal/s32g2.c Resolved
@night1rider
night1rider merged commit 2723377 into wolfSSL:master Dec 3, 2026
581 of 582 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