Skip to content

Commit 8b7fb61

Browse files
committed
cm4: add Raspberry Pi Compute Module 4 (BCM2711 Cortex-A72) target with authenticated boot
1 parent 4308b36 commit 8b7fb61

10 files changed

Lines changed: 567 additions & 1 deletion

File tree

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ ifeq ($(TARGET),raspi3)
310310
MAIN_TARGET:=wolfboot.bin
311311
endif
312312

313+
ifeq ($(TARGET),cm4)
314+
MAIN_TARGET:=wolfboot.bin
315+
endif
316+
313317
ifeq ($(TARGET),sim)
314318
CFLAGS+=-fno-pie
315319
LDFLAGS+=-no-pie

arch.mk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,14 @@ ifeq ($(ARCH),AARCH64)
117117
SPI_TARGET=nxp
118118
endif
119119

120+
ifeq ($(TARGET),cm4)
121+
# Raspberry Pi Compute Module 4 - Broadcom BCM2711, Cortex-A72
122+
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
123+
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72
124+
endif
125+
120126
# Default ARM ASM setting for unrecognized AARCH64 targets
121-
ifeq ($(filter zynq versal nxp_ls1028a,$(TARGET)),)
127+
ifeq ($(filter zynq versal nxp_ls1028a cm4,$(TARGET)),)
122128
NO_ARM_ASM?=1
123129
endif
124130

config/examples/cm4.config

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
ARCH?=AARCH64
2+
TARGET?=cm4
3+
SIGN?=ECC384
4+
HASH?=SHA384
5+
DEBUG?=1
6+
VTOR?=1
7+
SPMATH?=1
8+
IMAGE_HEADER_SIZE?=1024
9+
PKA?=0
10+
WOLFTPM?=0
11+
DEBUG_UART?=0
12+
NO_XIP?=1
13+
NO_QNX?=1
14+
WOLFBOOT_SECTOR_SIZE=0x400
15+
WOLFBOOT_NO_PARTITIONS=1
16+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x20000000
17+
WOLFBOOT_LOAD_ADDRESS?=0x3080000
18+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x400000

config/examples/cm4_sdcard.config

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Raspberry Pi CM4 (BCM2711) - eMMC/SD A/B disk boot (Phase 2)
2+
#
3+
# Boots from the BCM2711 EMMC2 controller (Arasan SDHCI @ 0xFE340000), which
4+
# drives the onboard eMMC (eMMC variants) or the microSD (CM4 Lite). wolfBoot
5+
# reads GPT A/B image partitions via update_disk.c and boots the highest valid
6+
# version with rollback.
7+
#
8+
# NOTE: the EMMC2 platform glue in hal/cm4.c is bring-up scaffolding pending
9+
# on-hardware validation (controller clock/pinmux state left by the GPU
10+
# firmware, card-detect wiring on the carrier). Use SDHCI_FORCE_CARD_DETECT
11+
# for the embedded eMMC path.
12+
ARCH?=AARCH64
13+
TARGET?=cm4
14+
SIGN?=ECC384
15+
HASH?=SHA384
16+
IMAGE_HEADER_SIZE?=1024
17+
DEBUG?=0
18+
DEBUG_UART?=1
19+
DISK_SDCARD?=1
20+
DISK_EMMC?=0
21+
CFLAGS_EXTRA+=-DSDHCI_FORCE_CARD_DETECT
22+
EXT_FLASH?=0
23+
NO_XIP=1
24+
NO_QNX?=1
25+
ELF?=1
26+
VTOR?=1
27+
SPMATH?=1
28+
PKA?=0
29+
WOLFTPM?=0
30+
WOLFBOOT_NO_PARTITIONS=1
31+
CFLAGS_EXTRA+=-DBOOT_PART_A=1
32+
CFLAGS_EXTRA+=-DBOOT_PART_B=2
33+
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x80000
34+
WOLFBOOT_LOAD_ADDRESS?=0x10000000
35+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x2BC00000
36+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x1000
37+
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x80200000
38+
WOLFBOOT_PARTITION_SIZE=0x4000000
39+
WOLFBOOT_SECTOR_SIZE=0x1000

docs/Targets.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This README describes configuration of supported targets.
66

77
* [Simulated](#simulated)
88
* [Cortex-A53 / Raspberry PI 3](#cortex-a53--raspberry-pi-3-experimental)
9+
* [Cortex-A72 / Raspberry Pi Compute Module 4](#cortex-a72--raspberry-pi-compute-module-4-bcm2711)
910
* [Cypress PSoC-6](#cypress-psoc-6)
1011
* [Infineon AURIX TC3xx](#infineon-aurix-tc3xx)
1112
* [Intel x86-64 Intel FSP](#intel-x86_64-with-intel-fsp-support)
@@ -3694,6 +3695,75 @@ qemu-system-aarch64 -M raspi3b -m 1024 -serial stdio -kernel wolfboot_linux_rasp
36943695
```
36953696
36963697
3698+
## Cortex-A72 / Raspberry Pi Compute Module 4 (BCM2711)
3699+
3700+
wolfBoot runs on the Raspberry Pi Compute Module 4 (CM4), a Broadcom BCM2711 with a quad-core Cortex-A72 (AArch64). wolfBoot takes the place of the second-stage OS loader: the BCM2711 boot ROM loads the VideoCore firmware, the firmware loads `kernel8.img` from the boot partition, and that `kernel8.img` is wolfBoot. wolfBoot then verifies the signed application image and boots it, extending the platform root of trust into the OS.
3701+
3702+
```
3703+
BCM2711 boot ROM -> SPI EEPROM bootloader -> VideoCore firmware (start4.elf)
3704+
-> kernel8.img (wolfBoot) -> verify (ECDSA/SHA) -> application
3705+
```
3706+
3707+
On CM4 modules with onboard eMMC the boot files live on the eMMC FAT boot partition; on CM4 Lite they live on a microSD. Either way the medium hangs off the BCM2711 EMMC2 controller (a standard SDHCI v3.0 Arasan block at `0xFE340000`).
3708+
3709+
### Building
3710+
3711+
```
3712+
cp config/examples/cm4.config .config
3713+
make CROSS_COMPILE=aarch64-none-elf-
3714+
```
3715+
3716+
The example uses `SIGN=ECC384 HASH=SHA384` (both FIPS-approved). wolfBoot is entered by the firmware at `0x80000` at EL2, matching `hal/cm4.ld`. The image is loaded from RAM: wolfBoot reads the signed application at `kernel_addr` (`0x140000`), verifies it, copies it to `WOLFBOOT_LOAD_ADDRESS`, and boots.
3717+
3718+
### Signing and assembling the boot image
3719+
3720+
Sign the application, then concatenate wolfBoot and the signed image so the signed image lands at `kernel_addr` (`0x140000` = `0x80000` load + `0xC0000`):
3721+
3722+
```
3723+
make keytools
3724+
IMAGE_HEADER_SIZE=1024 ./tools/keytools/sign --ecc384 --sha384 \
3725+
app.bin wolfboot_signing_private_key.der 1
3726+
tools/bin-assemble/bin-assemble kernel8.img \
3727+
0x0 wolfboot.bin \
3728+
0xC0000 app_v1_signed.bin
3729+
```
3730+
3731+
### config.txt
3732+
3733+
The CM4 UART on GPIO14/15 defaults to the mini-UART because the PL011 is used by Bluetooth. wolfBoot drives the PL011, so route it to the header and fix a known UART clock:
3734+
3735+
```
3736+
arm_64bit=1
3737+
kernel=kernel8.img
3738+
enable_uart=1
3739+
uart_2ndstage=1
3740+
dtoverlay=disable-bt
3741+
init_uart_clock=48000000
3742+
init_uart_baud=115200
3743+
```
3744+
3745+
### Flashing
3746+
3747+
- CM4 Lite: write `kernel8.img` + the RPi firmware (`start4.elf`, `fixup4.dat`) + `config.txt` to the microSD FAT boot partition.
3748+
- CM4 with eMMC: put the module in USB boot mode (nRPIBOOT), run `rpiboot` to expose the eMMC as USB mass storage, and write the same files to its FAT boot partition. See https://github.com/raspberrypi/usbboot .
3749+
3750+
### Boot output
3751+
3752+
With `DEBUG_UART=1`, a successful authenticated boot prints (115200 8N1):
3753+
3754+
```
3755+
wolfBoot CM4 (BCM2711 Cortex-A72) hal_init, EL2
3756+
Trying partition 0 at 0x140000
3757+
Checking integrity...done
3758+
Verifying signature...done
3759+
Firmware Valid
3760+
Booting at 0x3080000
3761+
```
3762+
3763+
### Optional: eMMC/SD A/B updates
3764+
3765+
`config/examples/cm4_sdcard.config` enables the disk updater (`DISK_SDCARD`/`DISK_EMMC`), driving the BCM2711 EMMC2 controller through the generic SDHCI driver (`src/sdhci.c`) for A/B image partitions on the boot medium. This path is provided as bring-up scaffolding and is not yet hardware-validated.
3766+
36973767
## Xilinx Zynq UltraScale
36983768
36993769
AMD Zynq UltraScale+ MPSoC ZCU102 Evaluation Kit - Quad-core ARM Cortex-A53 (plus dual Cortex-R5).

0 commit comments

Comments
 (0)