Skip to content

Commit ea874f8

Browse files
authored
Merge pull request #920 from dgarske/versal_fit_noload
Boot a FIT with no kernel load/entry and no device tree
2 parents aef57a1 + d490e36 commit ea874f8

22 files changed

Lines changed: 1634 additions & 148 deletions

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,12 +1332,35 @@ jobs:
13321332
arch: aarch64
13331333
config-file: ./config/examples/versal_vmk180.config
13341334

1335+
versal_vmk180_highddr_test:
1336+
uses: ./.github/workflows/test-build-aarch64.yml
1337+
with:
1338+
arch: aarch64
1339+
config-file: ./config/examples/versal_vmk180_highddr.config
1340+
13351341
versal_vmk180_sdcard_test:
13361342
uses: ./.github/workflows/test-build-aarch64.yml
13371343
with:
13381344
arch: aarch64
13391345
config-file: ./config/examples/versal_vmk180_sdcard.config
13401346

1347+
# FIT read from a filesystem with no kernel load/entry and no fdt
1348+
# sub-image, so the staging addresses come from the build.
1349+
versal_vmk180_sdcard_fit_file_test:
1350+
uses: ./.github/workflows/test-build-aarch64.yml
1351+
with:
1352+
arch: aarch64
1353+
config-file: ./config/examples/versal_vmk180_sdcard.config
1354+
make-args: DISK_FS=fat32 FIT_RAMDISK=1 WOLFBOOT_LOAD_KERNEL_ADDRESS=0x200000 WOLFBOOT_LOAD_RAMDISK_ADDRESS=0x40000000
1355+
1356+
# Same, with every address moved into a high DDR aperture.
1357+
versal_vmk180_sdcard_fit_file_highddr_test:
1358+
uses: ./.github/workflows/test-build-aarch64.yml
1359+
with:
1360+
arch: aarch64
1361+
config-file: ./config/examples/versal_vmk180_sdcard.config
1362+
make-args: DISK_FS=fat32 FIT_RAMDISK=1 DDR_HIGH_BASE=0x40000000000 DDR_HIGH_SIZE=0x10000000000 NO_DDR_LOW=1 WOLFBOOT_ORIGIN=0x40000800000 WOLFBOOT_LOAD_ADDRESS=0x40010000000 WOLFBOOT_LOAD_DTS_ADDRESS=0x40000001000 WOLFBOOT_LOAD_KERNEL_ADDRESS=0x40002000000 WOLFBOOT_LOAD_RAMDISK_ADDRESS=0x40030000000
1363+
13411364
versal_vmk180_sdcard_fs_test:
13421365
uses: ./.github/workflows/test-build-aarch64.yml
13431366
with:

‎Makefile‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,6 @@ include/target.h: $(TARGET_H_TEMPLATE) FORCE
887887
sed -e "s/@WOLFBOOT_DTS_UPDATE_ADDRESS@/$(WOLFBOOT_DTS_UPDATE_ADDRESS)/g" | \
888888
sed -e "s/@WOLFBOOT_LOAD_ADDRESS@/$(WOLFBOOT_LOAD_ADDRESS)/g" | \
889889
sed -e "s/@WOLFBOOT_LOAD_DTS_ADDRESS@/$(WOLFBOOT_LOAD_DTS_ADDRESS)/g" | \
890-
sed -e "s/@WOLFBOOT_LOAD_RAMDISK_ADDRESS@/$(WOLFBOOT_LOAD_RAMDISK_ADDRESS)/g" | \
891-
sed -e "s/@WOLFBOOT_LOAD_FPGA_ADDRESS@/$(WOLFBOOT_LOAD_FPGA_ADDRESS)/g" | \
892890
sed -e "s|@WOLFBOOT_RAMBOOT_MAX_SIZE_DEFINE@|$(if $(strip $(WOLFBOOT_RAMBOOT_MAX_SIZE)),#define WOLFBOOT_RAMBOOT_MAX_SIZE $(WOLFBOOT_RAMBOOT_MAX_SIZE),/* WOLFBOOT_RAMBOOT_MAX_SIZE undefined */)|g" | \
893891
sed -e "s/@WOLFBOOT_PARTITION_SELF_HEADER_ADDRESS@/$(WOLFBOOT_PARTITION_SELF_HEADER_ADDRESS)/g" \
894892
> $@

‎config/examples/versal_vmk180.config‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,11 @@ WOLFTPM?=0
4747
EXT_FLASH?=1
4848
NO_XIP=1
4949

50-
# Boot Exception Level
51-
# Choose the exception level for booting applications (mutually exclusive):
52-
# BOOT_EL1: Transition applications to EL1 (default - for Linux, most bare-metal)
53-
# BOOT_EL2: Boot applications at EL2 (for hypervisors, RTOSes that expect EL2)
54-
# Default is BOOT_EL1 if neither is specified.
55-
# Uncomment one of the following to override:
50+
# Boot Exception Level (mutually exclusive)
51+
# BOOT_EL1: drop to EL1 via ERET before entering the application.
52+
# BOOT_EL2: enter the application at the EL2 wolfBoot runs at (default).
53+
# EL2 is the default: PSCI brings the secondary cores up at EL2, so dropping
54+
# only the boot core leaves Linux with "CPUs started in inconsistent modes".
5655
#BOOT_EL1=1
5756
#BOOT_EL2=1
5857

@@ -78,6 +77,13 @@ GZIP?=1
7877
# "bootm" loads; without this wolfBoot ignores it.
7978
FIT_RAMDISK?=1
8079

80+
# Load address for the FIT kernel sub-image, overriding the FIT's own
81+
# `load`/`entry`. Needed when the ITS omits them. 0 honors the FIT.
82+
#WOLFBOOT_LOAD_KERNEL_ADDRESS?=0x200000
83+
84+
# Likewise for the ramdisk: 0 honors the FIT's own `load`.
85+
#WOLFBOOT_LOAD_RAMDISK_ADDRESS?=0x40000000
86+
8187
# Toolchain
8288
USE_GCC=1
8389
CROSS_COMPILE=aarch64-none-elf-
@@ -118,17 +124,25 @@ WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x6000000
118124
WOLFBOOT_LOAD_DTS_ADDRESS?=0x1000
119125

120126
# High DDR aperture: for designs whose DDR lives above the default address map
121-
# (e.g. DDR at 0x400_0000_0000). These must stay BELOW the defaults above and
122-
# use '=' so they override them. Base and size are 512 GB aligned with no
123-
# UL/ULL suffix (the assembler consumes them); the FIT ITS must then use
127+
# (e.g. DDR at 0x400_0000_0000). config/examples/versal_vmk180_highddr.config
128+
# is this recipe already applied. These must stay BELOW the defaults above
129+
# and use '=' so they override them. Base and size are 512 GB aligned with
130+
# no UL/ULL suffix (the assembler consumes them); the FIT ITS must then use
124131
# #address-cells = <2> with two-cell load/entry values, and the bootgen BIF
125132
# and BL31 BL33 entry must match WOLFBOOT_ORIGIN.
133+
#
134+
# Note 0x40000800000 is 0x400_0080_0000 (8 MB in), not 0x400_0800_0000.
135+
# The kernel and ramdisk destinations must clear the FIT staging buffer at
136+
# WOLFBOOT_LOAD_ADDRESS, which the sub-images are read out of, and
137+
# WOLFBOOT_PARTITION_SIZE must fit the whole signed FIT.
126138
#WOLFBOOT_ORIGIN=0x40000800000
127139
#WOLFBOOT_LOAD_ADDRESS=0x40010000000
128140
#WOLFBOOT_LOAD_DTS_ADDRESS=0x40000001000
129-
#CFLAGS_EXTRA+=-DVERSAL_DDR_HIGH_BASE=0x40000000000
130-
#CFLAGS_EXTRA+=-DVERSAL_DDR_HIGH_SIZE=0x10000000000
131-
#CFLAGS_EXTRA+=-DVERSAL_NO_DDR_LOW
141+
#WOLFBOOT_LOAD_KERNEL_ADDRESS=0x40002000000
142+
#WOLFBOOT_LOAD_RAMDISK_ADDRESS=0x40030000000
143+
#DDR_HIGH_BASE=0x40000000000
144+
#DDR_HIGH_SIZE=0x10000000000
145+
#NO_DDR_LOW=1
132146
WOLFBOOT_DTS_BOOT_ADDRESS?=0x7B0000
133147
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x39B0000
134148

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# wolfBoot configuration for AMD Versal - DDR Boot with a high DDR aperture
2+
# Versal with DDR mapped at 0x400_0000_0000 instead of the default map.
3+
#
4+
# PLM -> PSM -> BL31 (EL3) -> wolfBoot (EL2) -> Linux (EL2)
5+
#
6+
# Derived from versal_vmk180.config; see that file for the knobs this one
7+
# does not change. Every address here lives inside the aperture declared by
8+
# DDR_HIGH_BASE/DDR_HIGH_SIZE.
9+
#
10+
# Three things outside this file have to agree with it: the bootgen BIF
11+
# (wolfboot.elf at WOLFBOOT_ORIGIN, raw DTB at WOLFBOOT_LOAD_DTS_ADDRESS),
12+
# BL31's PRELOADED_BL33_BASE = WOLFBOOT_ORIGIN, and the FIT ITS using
13+
# #address-cells = <2>.
14+
15+
ARCH?=AARCH64
16+
TARGET?=versal
17+
18+
WOLFBOOT_VERSION?=1
19+
20+
# ECC-384 with SHA-384 (good balance of security and performance)
21+
SIGN?=ECC384
22+
HASH?=SHA384
23+
IMAGE_HEADER_SIZE?=512
24+
25+
# RSA 4096-bit with SHA3-384 (alternative)
26+
#SIGN?=RSA4096
27+
#HASH?=SHA3
28+
#IMAGE_HEADER_SIZE?=1024
29+
30+
# Debug options
31+
DEBUG?=1
32+
DEBUG_SYMBOLS=1
33+
DEBUG_UART=1
34+
35+
# Boot Benchmarking (optional):
36+
# Enables timing of boot operations (flash read, integrity, signature).
37+
BOOT_BENCHMARK?=1
38+
39+
VTOR?=1
40+
CORTEX_M0?=0
41+
NO_ASM?=0
42+
ALLOW_DOWNGRADE?=0
43+
NVM_FLASH_WRITEONCE?=0
44+
V?=0
45+
SPMATH?=1
46+
RAM_CODE?=0
47+
DUALBANK_SWAP?=0
48+
PKA?=0
49+
WOLFTPM?=0
50+
51+
# Flash configuration
52+
EXT_FLASH?=1
53+
NO_XIP=1
54+
55+
# Boot Exception Level (mutually exclusive)
56+
# BOOT_EL1: drop to EL1 via ERET before entering the application.
57+
# BOOT_EL2: enter the application at the EL2 wolfBoot runs at (default).
58+
# EL2 is the default: PSCI brings the secondary cores up at EL2, so dropping
59+
# only the boot core leaves Linux with "CPUs started in inconsistent modes".
60+
#BOOT_EL1=1
61+
#BOOT_EL2=1
62+
63+
# ELF loading support
64+
ELF?=1
65+
66+
# Native gzip decompression for FIT subimages (set GZIP=0 to disable)
67+
GZIP?=1
68+
69+
# FIT ramdisk (initramfs) extraction plus the /chosen/linux,initrd-{start,end}
70+
# fixup. A stock PetaLinux image.ub carries a ramdisk sub-image that a U-Boot
71+
# "bootm" loads; without this wolfBoot ignores it.
72+
FIT_RAMDISK?=1
73+
74+
# WOLFBOOT_LOAD_KERNEL_ADDRESS / WOLFBOOT_LOAD_RAMDISK_ADDRESS override the
75+
# FIT's own `load`/`entry`, so a FIT built without them boots. Set below.
76+
77+
# Toolchain
78+
USE_GCC=1
79+
CROSS_COMPILE=aarch64-none-elf-
80+
81+
# ============================================================================
82+
# Boot Memory Layout
83+
# ============================================================================
84+
# wolfBoot runs from DDR inside the high aperture, at EL2 non-secure.
85+
# WOLFBOOT_ORIGIN is set with the rest of the layout further down.
86+
87+
# Optional debugging with OCRAM
88+
# Versal Gen 1 (VMK180): OCM is 256KB at 0xFFFC0000 - 0xFFFFFFFF
89+
# Versal Gen 2: OCM is 2MB at 0xFFE00000 - 0xFFFFFFFF
90+
#WOLFBOOT_ORIGIN=0xFFFC0000
91+
92+
# Flash Sector Size (QSPI)
93+
WOLFBOOT_SECTOR_SIZE=0x20000
94+
95+
# Application Partition Size (44MB)
96+
WOLFBOOT_PARTITION_SIZE=0x2C00000
97+
98+
# Location in Flash for Primary Boot Partition
99+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x800000
100+
101+
# Load Partition to RAM Address (Linux kernel loads here)
102+
WOLFBOOT_LOAD_ADDRESS?=0x10000000
103+
104+
# Location in Flash for Secondary Partition (update image)
105+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x3400000
106+
107+
# Location to store wolfBoot state/swap
108+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x6000000
109+
110+
# DTS (Device Tree) - matches addresses from BOOT.BIN analysis
111+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x1000
112+
113+
# The aperture itself. Base and size are 512 GB aligned with no UL/ULL
114+
# suffix - the assembler consumes them. NO_DDR_LOW drops the low mapping.
115+
DDR_HIGH_BASE=0x40000000000
116+
DDR_HIGH_SIZE=0x10000000000
117+
NO_DDR_LOW=1
118+
119+
# DDR layout inside the aperture, using '=' to override the '?=' defaults
120+
# above. Each region is distinct: the kernel and ramdisk destinations must
121+
# clear the FIT staging buffer the sub-images are read out of.
122+
#
123+
# 0x400_0000_1000 DTB (WOLFBOOT_LOAD_DTS_ADDRESS)
124+
# 0x400_0080_0000 wolfBoot (WOLFBOOT_ORIGIN)
125+
# 0x400_0200_0000 kernel (WOLFBOOT_LOAD_KERNEL_ADDRESS)
126+
# 0x400_1000_0000 FIT staging (WOLFBOOT_LOAD_ADDRESS)
127+
# 0x400_3000_0000 ramdisk (WOLFBOOT_LOAD_RAMDISK_ADDRESS)
128+
WOLFBOOT_ORIGIN=0x40000800000
129+
WOLFBOOT_LOAD_DTS_ADDRESS=0x40000001000
130+
WOLFBOOT_LOAD_KERNEL_ADDRESS=0x40002000000
131+
WOLFBOOT_LOAD_ADDRESS=0x40010000000
132+
WOLFBOOT_LOAD_RAMDISK_ADDRESS=0x40030000000
133+
134+
# Cap the decompressed kernel at the 224 MB gap to the staging buffer above,
135+
# which is tighter than the 256 MB WOLFBOOT_FIT_MAX_DECOMP default.
136+
CFLAGS_EXTRA+=-DWOLFBOOT_FIT_MAX_KERNEL=0xE000000
137+
WOLFBOOT_DTS_BOOT_ADDRESS?=0x7B0000
138+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x39B0000
139+
140+
# Speed up reads by using larger blocks
141+
CFLAGS_EXTRA+=-DWOLFBOOT_SHA_BLOCK_SIZE=4096
142+
143+
# UART Configuration - UART0 for APU console
144+
CFLAGS_EXTRA+=-DDEBUG_UART_NUM=0
145+
146+
# QSPI Reference Clock: Ref (300MHz default for Versal)
147+
#CFLAGS_EXTRA+=-DGQSPI_CLK_REF=300000000
148+
149+
# QSPI Bus Divisor: (2 << div) = BUS (0=div2, 1=div4, 2=div8)
150+
# MT25QU01G max: 133MHz Quad Read (0x6C) with 8 dummy cycles
151+
# div=0: 300MHz/2 = 150MHz (above spec but tested working)
152+
# div=1: 300MHz/4 = 75MHz (within spec, default)
153+
# div=2: 300MHz/8 = 37.5MHz (conservative)
154+
#CFLAGS_EXTRA+=-DGQSPI_CLK_DIV=1
155+
156+
# QSPI flash options (uncomment to enable)
157+
#CFLAGS_EXTRA+=-DDEBUG_QSPI # Enable QSPI debug logging
158+
#CFLAGS_EXTRA+=-DGQSPI_MODE_IO # Use polling instead of DMA (slower)
159+
#CFLAGS_EXTRA+=-DTEST_EXT_FLASH # Run flash erase/write/read test

‎config/examples/versal_vmk180_sdcard.config‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ CFLAGS_EXTRA+=-DBOOT_PART_B=2
103103
#DISK_FS=both
104104
#CFLAGS_EXTRA+=-DBOOT_FILE_A='"/boot/fitImage_A.itb"'
105105
#CFLAGS_EXTRA+=-DBOOT_FILE_B='"/boot/fitImage_B.itb"'
106+
#
107+
# A U-Boot "fatload mmc 0:1 <addr> image.ub ; bootm <addr> <addr>
108+
# ${fdtcontroladdr}" flow maps onto DISK_FS=fat32 plus BOOT_FILE_A, with
109+
# wolfBoot reading the file itself. If that FIT declares no `load`/`entry`
110+
# and carries no `fdt`, add the staging addresses below and point
111+
# WOLFBOOT_LOAD_DTS_ADDRESS at the DTB the bootgen BIF leaves.
112+
#DISK_FS=fat32
113+
#CFLAGS_EXTRA+=-DBOOT_FILE_A='"/image.ub"'
114+
#FIT_RAMDISK=1
115+
#WOLFBOOT_LOAD_KERNEL_ADDRESS=0x200000
116+
#WOLFBOOT_LOAD_RAMDISK_ADDRESS=0x40000000
117+
#
118+
# For DDR above the default address map see the "High DDR aperture" block
119+
# in config/examples/versal_vmk180.config; the ITS then needs 2 cells.
106120
# Select the partitions by name instead of by index. The GPT partition label
107121
# is matched first, then the filesystem volume label (which is what makes
108122
# this work on MBR disks, where partitions have no names).

0 commit comments

Comments
 (0)