Skip to content

Commit 45df485

Browse files
committed
Add NXP S32G2 (S32G274A GoldBox) target: wolfBoot as the Boot ROM image, booting a signed FIT from SD, eMMC or QuadSPI NOR
1 parent 1147e6e commit 45df485

19 files changed

Lines changed: 3775 additions & 2 deletions

‎.github/workflows/test-configs.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,38 @@ jobs:
879879
config-file: ./config/examples/imx8mm-pico.config
880880
make-args: IMX8MM_BL33=1 DISK_EMMC=0 IMX8MM_MMU=0 wolfboot.bin test-app/image_v1_signed.bin
881881

882+
s32g2_test:
883+
uses: ./.github/workflows/test-build-aarch64.yml
884+
with:
885+
arch: aarch64
886+
# Boot ROM image in SRAM, signed FIT from the SD card.
887+
config-file: ./config/examples/s32g2-goldbox.config
888+
make-args: wolfboot.bin
889+
890+
s32g2_emmc_test:
891+
uses: ./.github/workflows/test-build-aarch64.yml
892+
with:
893+
arch: aarch64
894+
# FIT from the eMMC behind the board's SW3, no console.
895+
config-file: ./config/examples/s32g2-goldbox.config
896+
make-args: DISK_EMMC=1 DISK_SDCARD=0 DEBUG_UART=0 wolfboot.bin
897+
898+
s32g2_qspi_test:
899+
uses: ./.github/workflows/test-build-aarch64.yml
900+
with:
901+
arch: aarch64
902+
# Boot from the QuadSPI NOR with the A/B partitions in the NOR.
903+
config-file: ./config/examples/s32g2-goldbox-qspi.config
904+
make-args: wolfboot.bin
905+
906+
s32g2_qspi_program_test:
907+
uses: ./.github/workflows/test-build-aarch64.yml
908+
with:
909+
arch: aarch64
910+
# NOR programmer build: image file from the SD card to the NOR.
911+
config-file: ./config/examples/s32g2-goldbox.config
912+
make-args: S32G2_QSPI=1 S32G2_QSPI_PROGRAM_FILE=/s32g2_qspi_boot.bin wolfboot.bin
913+
882914
disk_boot_confirm_test:
883915
uses: ./.github/workflows/test-build-aarch64.yml
884916
with:

‎.gitignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,3 +695,8 @@ tools/unit-tests/stm32wb_write_extract.h
695695
tools/unit-tests/t10xx_flash_status_extract.h
696696
tools/unit-tests/ti_hercules_erase_extract.h
697697
tools/unit-tests/versal_host_write.c
698+
# S32G2 GoldBox FIT build outputs (tools/scripts/s32g2/s32g2-mkfit.sh)
699+
Image.gz
700+
s32g2-fitImage*
701+
s32g2.dtb
702+
s32g2_ddr.bin

‎Makefile‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ ifeq ($(TARGET),imx8mm)
515515
MAIN_TARGET:=wolfboot.bin test-app/image_v1_signed.bin
516516
endif
517517

518+
# S32G2 runs from SRAM and boots a signed FIT; there is no factory.bin.
519+
ifeq ($(TARGET),s32g2)
520+
MAIN_TARGET:=wolfboot.bin
521+
endif
522+
518523
# i.MX95 M7 runs from ITCM (loaded by the Linux remoteproc driver); the payload
519524
# lives in DDR at 0x80100000, so there is no contiguous flash image to assemble.
520525
ifeq ($(TARGET),imx95_m7)
@@ -1101,6 +1106,16 @@ secondary: $(SECONDARY_PRIVATE_KEY)
11011106
@echo "\t[CC $(ARCH)] $@"
11021107
$(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ $^
11031108

1109+
# The S32G2 HAL objects are rebuilt on every make: hal/s32g2_ddr.o links the
1110+
# DDR blob in by content (its path and presence are build options), and the
1111+
# NOR programmer file and offset in hal/s32g2.o are command-line options that
1112+
# a stale object would silently keep.
1113+
ifeq ($(TARGET),s32g2)
1114+
hal/s32g2.o hal/s32g2_ddr.o: %.o: %.c FORCE
1115+
@echo "\t[CC $(ARCH)] $@"
1116+
$(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ $<
1117+
endif
1118+
11041119
%.o:%.S
11051120
@echo "\t[AS $(ARCH)] $@"
11061121
$(Q)$(CC) $(CFLAGS) -c $(OUTPUT_FLAG) $@ $^

‎arch.mk‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,56 @@ ifeq ($(ARCH),AARCH64)
363363
endif
364364
endif
365365

366+
ifeq ($(TARGET),s32g2)
367+
# NXP S32G274A GoldBox: wolfBoot is the Boot ROM's application image,
368+
# copied into SRAM and entered at EL3. It runs its own identity MMU there
369+
# and tears it down at the handoff with the stack-free flush routine.
370+
ARCH_FLAGS=-mcpu=cortex-a53+crypto -march=armv8-a+crypto -mstrict-align
371+
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A53
372+
CFLAGS+=-DWOLFBOOT_AARCH64_MMU_TEARDOWN
373+
WOLFBOOT_ORIGIN=0x340A0000
374+
OBJS+=hal/s32g2_ddr.o
375+
# wolfBoot adds /memory and the spin-table addresses to the FIT's DTB,
376+
# which needs more room than the default headroom.
377+
CFLAGS+=-DWOLFBOOT_FDT_FIXUP_HEADROOM=4096
378+
# LPDDR4 register tables and PHY training firmware, generated by
379+
# tools/scripts/s32g2/s32g2-ddr-blob.py. Without the file the image
380+
# still builds, and reports the missing blob instead of training.
381+
S32G2_DDR_BLOB ?= s32g2_ddr.bin
382+
ifneq ($(wildcard $(S32G2_DDR_BLOB)),)
383+
CFLAGS+=-DS32G2_DDR_BLOB='"$(abspath $(S32G2_DDR_BLOB))"'
384+
endif
385+
# uSDHC0 board facts. Here rather than in the config because a command-line
386+
# CFLAGS_EXTRA= would replace the config's, whereas CFLAGS is additive.
387+
ifneq ($(filter 1,$(DISK_SDCARD) $(DISK_EMMC)),)
388+
# uSDHC -> SDHCI shim, shared with the i.MX 8 targets
389+
OBJS+=hal/imx_usdhc_sdhci.o
390+
# Card detect is a GPIO, so PRES_STATE bit 16 never sets.
391+
CFLAGS+=-DSDHCI_FORCE_CARD_DETECT
392+
# Read the payload in 64 KB chunks rather than the 512-byte default.
393+
DISK_BLOCK_SIZE ?= 65536
394+
CFLAGS+=-DDISK_BLOCK_SIZE=$(DISK_BLOCK_SIZE)
395+
# 3.3 V signalling only (no-1-8-v): high-speed rates.
396+
ifeq ($(DISK_EMMC),1)
397+
S32G2_USDHC_MAX_CLK_KHZ ?= 52000
398+
else
399+
S32G2_USDHC_MAX_CLK_KHZ ?= 50000
400+
endif
401+
CFLAGS+=-DS32G2_USDHC_MAX_CLK_KHZ=$(S32G2_USDHC_MAX_CLK_KHZ)
402+
endif
403+
# QuadSPI NOR driver (the ext_flash API with EXT_FLASH=1)
404+
ifeq ($(S32G2_QSPI),1)
405+
CFLAGS+=-DS32G2_QSPI
406+
# NOR programmer build: writes the named file from the SD/eMMC FAT
407+
# partition to the NOR at S32G2_QSPI_PROGRAM_OFFSET, then halts.
408+
ifneq ($(S32G2_QSPI_PROGRAM_FILE),)
409+
S32G2_QSPI_PROGRAM_OFFSET ?= 0
410+
CFLAGS+=-DS32G2_QSPI_PROGRAM_FILE='"$(S32G2_QSPI_PROGRAM_FILE)"'
411+
CFLAGS+=-DS32G2_QSPI_PROGRAM_OFFSET=$(S32G2_QSPI_PROGRAM_OFFSET)
412+
endif
413+
endif
414+
endif
415+
366416
ifeq ($(TARGET),imx8mm)
367417
# uSDHC -> SDHCI shim, shared with imx8qm
368418
ifneq ($(filter 1,$(DISK_SDCARD) $(DISK_EMMC)),)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# NXP S32G2 GoldBox (S32G-VNP-GLDBOX, S32G274A-RDB2) - wolfBoot as the Boot
2+
# ROM's application image booting from the 64 MB QuadSPI NOR, with the A/B
3+
# image partitions in the same NOR and the signed FIT loaded into DDR. No SD
4+
# card is needed (DISK_SDCARD=0).
5+
#
6+
# NOR layout: wolfBoot at 0 (IVT, ROM QSPI parameters, code), BOOT partition
7+
# at 1 MB, UPDATE at 17 MB, SWAP sector at 33 MB.
8+
# tools/scripts/s32g2/s32g2_mkimage.py wolfboot.bin s32g2_qspi_boot.bin --qspi
9+
# The NOR is written by a programmer build of the SD config
10+
# (S32G2_QSPI=1 S32G2_QSPI_PROGRAM_FILE=/<file>); the board must be strapped
11+
# for QuadSPI boot.
12+
# See docs/Targets.md.
13+
#
14+
# Never pass CFLAGS_EXTRA= on the command line - it replaces, not appends.
15+
ARCH=AARCH64
16+
TARGET=s32g2
17+
S32G2_QSPI=1
18+
SIGN?=ECC384
19+
HASH?=SHA384
20+
DEBUG?=1
21+
DEBUG_UART?=1
22+
SPMATH?=1
23+
NO_XIP?=1
24+
EXT_FLASH?=1
25+
# The HAL sets up the GICv3 itself (hal/s32g2.c); skip the generic GICv2 init.
26+
SKIP_GIC_INIT?=1
27+
GZIP?=1
28+
DISK_SDCARD?=0
29+
# The MX25UW51245G keeps an ECC code for every 16 bytes and each of those
30+
# units may be programmed once per erase, so the partition state cannot be
31+
# rewritten in place: keep it as a log of 16-byte records. The log takes the
32+
# last sector of each partition, and 64 KB sectors give it room for a 16 MB
33+
# partition (the driver erases them as 4 KB flash sectors).
34+
NVM_FLASH_JOURNAL?=1
35+
WOLFBOOT_SECTOR_SIZE?=0x10000
36+
WOLFBOOT_PARTITION_SIZE?=0x1000000
37+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x100000
38+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x1100000
39+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x2100000
40+
# Separate DTB partitions are not used (the FIT carries the DTB) but the
41+
# RAM-boot flow needs them defined; they sit after the swap sector.
42+
WOLFBOOT_DTS_BOOT_ADDRESS?=0x2110000
43+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x2120000
44+
45+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x4000000
46+
WOLFBOOT_LOAD_ADDRESS?=0xA0000000
47+
WOLFBOOT_LOAD_DTS_ADDRESS?=0xA5000000
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# NXP S32G2 GoldBox (S32G-VNP-GLDBOX, S32G274A-RDB2) - wolfBoot as the Boot
2+
# ROM's application image: copied into SRAM at 0x340A0000 and entered at EL3
3+
# with only FIRC running, in place of U-Boot. The signed FIT (kernel + DTB,
4+
# hal/s32g2.its) is read from a FAT32 partition of the SD card, or of the
5+
# eMMC with DISK_EMMC=1 DISK_SDCARD=0.
6+
#
7+
# The LPDDR4 tables and PHY firmware come from the NXP BSP U-Boot sources:
8+
# tools/scripts/s32g2/s32g2-ddr-blob.py <nxp-u-boot> s32g2_ddr.bin
9+
# Wrap wolfboot.bin for the Boot ROM and write it at SD byte offset 0x1000:
10+
# tools/scripts/s32g2/s32g2_mkimage.py wolfboot.bin s32g2_boot.bin
11+
# dd if=s32g2_boot.bin of=/dev/sdX bs=512 seek=8
12+
# See docs/Targets.md.
13+
#
14+
# Never pass CFLAGS_EXTRA= on the command line - it replaces, not appends.
15+
ARCH=AARCH64
16+
TARGET=s32g2
17+
SIGN?=ECC384
18+
HASH?=SHA384
19+
DEBUG?=1
20+
DEBUG_UART?=1
21+
SPMATH?=1
22+
NO_XIP?=1
23+
# The HAL sets up the GICv3 itself (hal/s32g2.c); skip the generic GICv2 init.
24+
SKIP_GIC_INIT?=1
25+
WOLFBOOT_SECTOR_SIZE?=0x1000
26+
WOLFBOOT_NO_PARTITIONS=1
27+
GZIP?=1
28+
DISK_SDCARD?=1
29+
DISK_FS?=fat32
30+
31+
# A/B slots: two files on the third partition (FAT32). The higher version
32+
# boots. An older version is not used when the newer one fails to verify
33+
# (anti-rollback), unless built with ALLOW_DOWNGRADE=1.
34+
# A slot staged by an update is booted once on probation and skipped on the
35+
# next boot unless the OS confirmed it (docs/compile.md, "Disk boot
36+
# confirmation"). The state is the last 8 bytes of the slot's file.
37+
DISK_BOOT_CONFIRM?=1
38+
CFLAGS_EXTRA+=-DBOOT_PART_A=2
39+
CFLAGS_EXTRA+=-DBOOT_PART_B=2
40+
CFLAGS_EXTRA+=-DBOOT_FILE_A='"/fitImage_a.bin"'
41+
CFLAGS_EXTRA+=-DBOOT_FILE_B='"/fitImage_b.bin"'
42+
43+
WOLFBOOT_RAMBOOT_MAX_SIZE=0x4000000
44+
WOLFBOOT_LOAD_ADDRESS?=0xA0000000
45+
WOLFBOOT_LOAD_DTS_ADDRESS?=0xA5000000

0 commit comments

Comments
 (0)