Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test-build-aarch64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ on:
required: false
type: boolean
default: false
fips:
# Download the FIPS-ready wolfSSL tree into ../ before building, for a
# build-only FIPS=1 verification (see WOLFBOOT_LIB_WOLFSSL in make-args).
required: false
type: boolean
default: false

jobs:

Expand Down Expand Up @@ -126,6 +132,16 @@ jobs:
unsigned long psu_ddr_qos_init_data(void) { return 1UL; }
STUB

- name: Download FIPS-ready wolfSSL
if: ${{ inputs.fips }}
run: |
set -euxo pipefail
sudo apt-get install -y unzip
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/wolfssl-fips-ready.zip \
https://www.wolfssl.com/wolfssl-5.9.2-gplv3-fips-ready.zip
unzip -q /tmp/wolfssl-fips-ready.zip -d ..
test -f ../wolfssl-5.9.2-gplv3-fips-ready/wolfcrypt/src/fips.c

- name: Build wolfboot
run: |
make ${{inputs.make-args}}
16 changes: 16 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
make-args:
required: false
type: string
fips:
# Download the FIPS-ready wolfSSL tree into ../ before building.
required: false
type: boolean
default: false

jobs:

Expand Down Expand Up @@ -42,6 +47,17 @@ jobs:
run: |
make -C tools/keytools && make -C tools/bin-assemble

- name: Download FIPS-ready wolfSSL
if: ${{ inputs.fips }}
run: |
set -euxo pipefail
# Runs inside the CI container (no sudo/apt); unpack with python3,
# which is already a build dependency.
curl -fsSL --retry 3 --retry-delay 5 -o /tmp/wolfssl-fips-ready.zip \
https://www.wolfssl.com/wolfssl-5.9.2-gplv3-fips-ready.zip
python3 -m zipfile -e /tmp/wolfssl-fips-ready.zip ..
test -f ../wolfssl-5.9.2-gplv3-fips-ready/wolfcrypt/src/fips.c

- name: Build wolfboot
run: |
make ${{inputs.make-args}}
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/test-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,42 @@ jobs:
config-file: ./config/examples/raspi3-encrypted.config
make-args: wolfboot.bin CROSS_COMPILE=aarch64-linux-gnu-

cm4_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
arch: aarch64
config-file: ./config/examples/cm4.config
make-args: wolfboot.bin

cm4_sdcard_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
arch: aarch64
config-file: ./config/examples/cm4_sdcard.config
make-args: wolfboot.bin

cm4_emmc_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
arch: aarch64
config-file: ./config/examples/cm4_emmc.config
make-args: wolfboot.bin

cm4_fips_test:
uses: ./.github/workflows/test-build-aarch64.yml
with:
arch: aarch64
config-file: ./config/examples/cm4.config
make-args: wolfboot.bin FIPS=1 WOLFBOOT_LIB_WOLFSSL=../wolfssl-5.9.2-gplv3-fips-ready NO_ARM_ASM=1
fips: true

sim_fips_test:
uses: ./.github/workflows/test-build.yml
with:
arch: host
config-file: ./config/examples/sim-fips.config
fips: true

sim_tfm_smallstack_test:
uses: ./.github/workflows/test-build.yml
with:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,9 @@ sdcard.img

# wolfHSM STM32H5 TZ demo build output
port/stmicro/stm32h5-tz-wolfhsm/out/

# CM4 disk-boot test artifacts (fetched RPi firmware, built/signed payloads)
tools/scripts/cm4/fw/
tools/scripts/cm4/*.elf
tools/scripts/cm4/*.bin
tools/scripts/cm4/linux/
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ ifeq ($(TARGET),raspi3)
MAIN_TARGET:=wolfboot.bin
endif

ifeq ($(TARGET),cm4)
MAIN_TARGET:=wolfboot.bin
endif

ifeq ($(TARGET),sim)
CFLAGS+=-fno-pie
LDFLAGS+=-no-pie
Expand Down
16 changes: 15 additions & 1 deletion arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,21 @@ ifeq ($(ARCH),AARCH64)
SPI_TARGET=nxp
endif

# Default ARM ASM setting for unrecognized AARCH64 targets
ifeq ($(TARGET),cm4)
# Raspberry Pi Compute Module 4 - Broadcom BCM2711, Cortex-A72
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
# -mstrict-align: the plain RAM-boot config runs with the MMU off (simple
# startup), where all memory is Device-nGnRnE and unaligned access faults.
# The FIPS / disk configs bring up an identity MMU first (CM4_USE_MMU in
# hal/cm4.c). cm4 defaults to NO_ARM_ASM=1 (portable C, no NEON structure
# loads), so -mstrict-align keeps every config safe either way.
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72 -mstrict-align
endif

# Default ARM ASM setting for unrecognized AARCH64 targets. cm4 is excluded
# from the asm path (defaults NO_ARM_ASM=1): the plain config runs MMU-off
# where NEON multi-register loads would fault, and the FIPS path mandates
# portable-C crypto anyway.
ifeq ($(filter zynq versal nxp_ls1028a,$(TARGET)),)
NO_ARM_ASM?=1
endif
Expand Down
28 changes: 28 additions & 0 deletions config/examples/cm4.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Raspberry Pi CM4 (BCM2711) - RAM-boot authenticated boot.
#
# For wolfCrypt FIPS 140-3, build with FIPS=1 pointing at a FIPS / FIPS-ready
# wolfSSL tree. The FIPS module uses portable-C crypto, so NO_ARM_ASM is
# required. Entropy comes from the BCM2711 RNG200 hardware TRNG (hal/cm4.c).
# See docs/FIPS.md for the in-core hash-seal procedure (done on-target). e.g.:
# make FIPS=1 WOLFBOOT_LIB_WOLFSSL=../wolfssl-5.9.2-gplv3-fips-ready NO_ARM_ASM=1
#FIPS?=1
#WOLFBOOT_LIB_WOLFSSL?=../wolfssl-5.9.2-gplv3-fips-ready
#NO_ARM_ASM?=1
ARCH?=AARCH64
TARGET?=cm4
SIGN?=ECC384
HASH?=SHA384
DEBUG?=1
VTOR?=1
SPMATH?=1
IMAGE_HEADER_SIZE?=1024
PKA?=0
WOLFTPM?=0
DEBUG_UART?=0
NO_XIP?=1
NO_QNX?=1
WOLFBOOT_SECTOR_SIZE=0x400
WOLFBOOT_NO_PARTITIONS=1
WOLFBOOT_RAMBOOT_MAX_SIZE=0x20000000
WOLFBOOT_LOAD_ADDRESS?=0x3080000
WOLFBOOT_LOAD_DTS_ADDRESS?=0x400000
54 changes: 54 additions & 0 deletions config/examples/cm4_emmc.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Raspberry Pi CM4 (BCM2711) - onboard eMMC A/B disk boot.
#
# wolfBoot drives the BCM2711 EMMC2 controller (Arasan SDHCI v3.0 @ 0xFE340000)
# to read GPT A/B image partitions from the onboard eMMC via update_disk.c, and
# boots the highest valid version with rollback.
#
# Transfer mode: SDHCI_SDMA_DISABLED forces PIO. The BCM2711 EMMC2 SDMA
# boundary-restart and cache coherency are not yet validated (same Arasan
# family as the Versal quirk); DISK_EMMC compiles in the PIO BRR-race
# workaround in src/sdhci.c. SDHCI_FORCE_CARD_DETECT: the onboard eMMC has no
# routed card-detect line.
#
# Bring-up: uncomment DEBUG_SDHCI (+ DEBUG_DISK / DEBUG_GPT) for verbose
# controller/partition tracing over the mini-UART console.
#
# For wolfCrypt FIPS 140-3, build with FIPS=1 pointing at a FIPS / FIPS-ready
# wolfSSL tree (NO_ARM_ASM required; entropy from the RNG200 TRNG). See
# docs/FIPS.md. e.g.:
# make FIPS=1 WOLFBOOT_LIB_WOLFSSL=../wolfssl-5.9.2-gplv3-fips-ready NO_ARM_ASM=1
#FIPS?=1
#WOLFBOOT_LIB_WOLFSSL?=../wolfssl-5.9.2-gplv3-fips-ready
#NO_ARM_ASM?=1
ARCH?=AARCH64
TARGET?=cm4
SIGN?=ECC384
HASH?=SHA384
IMAGE_HEADER_SIZE?=1024
DEBUG?=0
DEBUG_UART?=1
DISK_SDCARD?=0
DISK_EMMC?=1
CFLAGS_EXTRA+=-DSDHCI_FORCE_CARD_DETECT
CFLAGS_EXTRA+=-DSDHCI_SDMA_DISABLED
#CFLAGS_EXTRA+=-DDEBUG_SDHCI
#CFLAGS_EXTRA+=-DDEBUG_DISK
#CFLAGS_EXTRA+=-DDEBUG_GPT
EXT_FLASH?=0
NO_XIP=1
NO_QNX?=1
ELF?=1
VTOR?=1
SPMATH?=1
PKA?=0
WOLFTPM?=0
WOLFBOOT_NO_PARTITIONS=1
CFLAGS_EXTRA+=-DBOOT_PART_A=1
CFLAGS_EXTRA+=-DBOOT_PART_B=2
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x80000
WOLFBOOT_LOAD_ADDRESS?=0x10000000
WOLFBOOT_RAMBOOT_MAX_SIZE=0x2BC00000
WOLFBOOT_LOAD_DTS_ADDRESS?=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80200000
WOLFBOOT_PARTITION_SIZE=0x4000000
WOLFBOOT_SECTOR_SIZE=0x1000
87 changes: 87 additions & 0 deletions config/examples/cm4_emmc_linux.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Raspberry Pi CM4 (BCM2711) - onboard eMMC A/B disk boot of a REAL Linux kernel
# (FIT), as opposed to cm4_emmc.config which boots the disk_app prove-out stub.
#
# Chain: RPi VideoCore firmware -> wolfBoot (kernel8.img @ 0x200000) -> reads a
# signed FIT (hal/cm4.its: kernel + bcm2711-rpi-cm4.dtb) from the eMMC A/B image
# partition -> verifies the outer ECDSA384/SHA384 signature -> loads + gzip-
# decompresses the kernel to 0x10000000, copies the DTB to WOLFBOOT_LOAD_DTS_
# ADDRESS -> drops EL2->EL1 (el2_to_el1_boot) handing the DTB in x0 -> Linux.
# The kernel mounts its rootfs from a separate eMMC ext4 partition (root= on the
# cmdline, injected via the FIT bootargs / hal_dts_fixup).
#
# Target: GCX "iron-butterfly" Yocto Scarthgap, kernel 6.6.63, raspberrypi4-64.
# GCX's UBOOT_LOADADDRESS is also 0x10000000, so their kernel loads identically.
#
# DRAFT: not yet HW-validated. The disk-driver half is identical to the proven
# cm4_emmc.config; the Linux-handoff half (EL1 entry, FIT kernel, DTB placement,
# partition sizing) needs bring-up with real GCX artifacts. Items marked VERIFY
# are the known unknowns.
ARCH?=AARCH64
TARGET?=cm4
SIGN?=ECC384
HASH?=SHA384
IMAGE_HEADER_SIZE?=1024
DEBUG?=0
DEBUG_UART?=1

# --- eMMC disk driver (identical to the validated cm4_emmc.config) -----------
DISK_SDCARD?=0
DISK_EMMC?=1
CFLAGS_EXTRA+=-DSDHCI_FORCE_CARD_DETECT
CFLAGS_EXTRA+=-DSDHCI_SDMA_DISABLED
#CFLAGS_EXTRA+=-DDEBUG_SDHCI
#CFLAGS_EXTRA+=-DDEBUG_DISK
#CFLAGS_EXTRA+=-DDEBUG_GPT
EXT_FLASH?=0
NO_XIP=1
NO_QNX?=1
ELF?=1
VTOR?=1
SPMATH?=1
PKA?=0
WOLFTPM?=0
WOLFBOOT_NO_PARTITIONS=1
CFLAGS_EXTRA+=-DBOOT_PART_A=1
CFLAGS_EXTRA+=-DBOOT_PART_B=2
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x80000

# --- Linux boot additions ----------------------------------------------------
# gzip-decompress the FIT kernel subimage at load time (kernel = Image.gz).
GZIP?=1
# Enter the kernel at EL2 (the RPi firmware brings the secondary CPUs up at EL2,
# so the primary must match or Linux warns "CPUs started in inconsistent modes"
# and KVM is unavailable). This is the default cm4 EL2 direct-jump handoff, which
# already passes the DTB in x0 - so we do NOT define BOOT_EL1/EL2_HYPERVISOR here.
# Console UART: the Linux mini-UART (bcm2835-aux) fails to register cleanly on
# this DTB, so use dtoverlay=disable-bt (routes the PL011 onto GPIO14/15) and
# build wolfBoot for the PL011. See hal/cm4.c (CM4_UART_PL011) and the config.txt
# generated by tools/scripts/cm4/prepare_emmc_linux.sh (adds disable-bt).
CFLAGS_EXTRA+=-DCM4_UART_PL011
# Use the RPi firmware's fully-patched DTB (RAM size, mini-UART clock, serial
# no.) for the kernel-only FIT, and inject the kernel command line. wolfBoot
# captures the firmware DTB pointer at _cm4_entry (x0). See hal/cm4.c
# hal_get_boot_dts(). Scoped here so the stub/FIPS builds are unaffected.
CFLAGS_EXTRA+=-DCM4_FIRMWARE_DTB
# Rootfs partition for the simple first-boot layout (p3). Overrides the
# LINUX_BOOTARGS_ROOT default in hal/cm4.c. With CM4_UART_PL011 the full cmdline is:
# earlycon=pl011,mmio32,0xfe201000 console=ttyAMA0,115200 root=/dev/mmcblk0p3 ...
CFLAGS_EXTRA+=-DLINUX_BOOTARGS_ROOT=\"/dev/mmcblk0p3\"

# Stage the signed FIT here (NOT 0x10000000): the FIT's kernel subimage has
# load=0x10000000, and a gzip kernel decompresses FIT-data -> 0x10000000. If the
# FIT itself were also at 0x10000000 the decompression output would overwrite its
# own compressed input mid-stream (observed: "FIT gunzip failed rc=-4"). 0x18000000
# (384MB) sits above the decompressed kernel (0x10000000 + ~30MB) with margin.
WOLFBOOT_LOAD_ADDRESS?=0x18000000
WOLFBOOT_RAMBOOT_MAX_SIZE=0x2BC00000
# VERIFY: DTB landing zone. 0x1000 (the stub config value) is too low for a real
# kernel; 0x08000000 (128 MB) sits below the kernel (256 MB) and above wolfBoot
# (2 MB). Confirm no collision with RPi low-memory reservations / kernel early
# use on HW.
WOLFBOOT_LOAD_DTS_ADDRESS?=0x08000000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80200000
# VERIFY: partition size must hold the FIT (kernel Image.gz ~10-15 MB + DTB).
# 0x4000000 (64 MB) is ample; the separate ext4 rootfs partition is sized in the
# eMMC-layout script, not here.
WOLFBOOT_PARTITION_SIZE=0x4000000
WOLFBOOT_SECTOR_SIZE=0x1000
52 changes: 52 additions & 0 deletions config/examples/cm4_sdcard.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Raspberry Pi CM4 (BCM2711) - eMMC/SD A/B disk boot.
#
# Boots from the BCM2711 EMMC2 controller (Arasan SDHCI @ 0xFE340000), which
# drives the onboard eMMC (eMMC variants) or the microSD (CM4 Lite). wolfBoot
# reads GPT A/B image partitions via update_disk.c and boots the highest valid
# version with rollback.
#
# The EMMC2 glue in hal/cm4.c is hardware-validated on the onboard eMMC
# (see cm4_emmc.config). The microSD path uses the same driver but needs a CM4
# Lite - an eMMC module disables the carrier's microSD slot. Use
# SDHCI_FORCE_CARD_DETECT for media with no routed card-detect line.
#
# For wolfCrypt FIPS 140-3, build with FIPS=1 pointing at a FIPS / FIPS-ready
# wolfSSL tree. The FIPS module uses portable-C crypto, so NO_ARM_ASM is
# required. Entropy comes from the BCM2711 RNG200 hardware TRNG (hal/cm4.c).
# See docs/FIPS.md for the in-core hash-seal procedure (done on-target). e.g.:
# make FIPS=1 WOLFBOOT_LIB_WOLFSSL=../wolfssl-5.9.2-gplv3-fips-ready NO_ARM_ASM=1
#FIPS?=1
#WOLFBOOT_LIB_WOLFSSL?=../wolfssl-5.9.2-gplv3-fips-ready
#NO_ARM_ASM?=1
ARCH?=AARCH64
TARGET?=cm4
SIGN?=ECC384
HASH?=SHA384
IMAGE_HEADER_SIZE?=1024
DEBUG?=0
DEBUG_UART?=1
DISK_SDCARD?=1
DISK_EMMC?=0
CFLAGS_EXTRA+=-DSDHCI_FORCE_CARD_DETECT
# Force PIO: the BCM2711 EMMC2 SDMA path is unvalidated and hal/cm4.c provides no
# DMA cache-maintenance hooks, while the disk configs run with the D-cache on
# (CM4_USE_MMU), so SDMA could hash/verify stale DDR. Matches cm4_emmc.config.
CFLAGS_EXTRA+=-DSDHCI_SDMA_DISABLED
EXT_FLASH?=0
NO_XIP=1
NO_QNX?=1
ELF?=1
VTOR?=1
SPMATH?=1
PKA?=0
WOLFTPM?=0
WOLFBOOT_NO_PARTITIONS=1
CFLAGS_EXTRA+=-DBOOT_PART_A=1
CFLAGS_EXTRA+=-DBOOT_PART_B=2
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x80000
WOLFBOOT_LOAD_ADDRESS?=0x10000000
WOLFBOOT_RAMBOOT_MAX_SIZE=0x2BC00000
WOLFBOOT_LOAD_DTS_ADDRESS?=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80200000
WOLFBOOT_PARTITION_SIZE=0x4000000
WOLFBOOT_SECTOR_SIZE=0x1000
22 changes: 22 additions & 0 deletions config/examples/sim-fips.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# wolfBoot simulator build using the wolfCrypt FIPS 140-3 module.
Comment thread
dgarske marked this conversation as resolved.
# Point WOLFBOOT_LIB_WOLFSSL at an unpacked FIPS (or FIPS-ready) wolfSSL tree.
# Prototype target for the CM4 FIPS integration (see docs/FIPS.md).
ARCH=sim
TARGET=sim
SIGN?=ECC384
HASH?=SHA384
FIPS?=1
WOLFBOOT_LIB_WOLFSSL?=../wolfssl-5.9.2-gplv3-fips-ready
WOLFBOOT_SMALL_STACK?=0
SPI_FLASH=0
DEBUG=1

# sizes should be multiple of system page size
WOLFBOOT_PARTITION_SIZE=0x40000
WOLFBOOT_SECTOR_SIZE=0x1000
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80000
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x100000
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x180000

# required for keytools
WOLFBOOT_FIXED_PARTITIONS=1
Loading