Skip to content

Commit 93e9cb6

Browse files
committed
Fixes from peer review. Thank you Alex
1 parent ee23e8b commit 93e9cb6

8 files changed

Lines changed: 50 additions & 25 deletions

File tree

config/examples/zynqmp_sdcard.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ CFLAGS_EXTRA+=-DLINUX_BOOTARGS_ROOT=\"/dev/mmcblk0p4\"
114114
#
115115
# To enable: uncomment the three lines below and comment out the
116116
# LINUX_BOOTARGS_ROOT line above (root= is supplied by the cpio's /init).
117-
#RAMDISK?=1
117+
#FIT_RAMDISK?=1
118118
#WOLFBOOT_LOAD_RAMDISK_ADDRESS?=0x40000000
119119
#CFLAGS_EXTRA+=-DLINUX_BOOTARGS='"earlycon console=ttyPS0,115200 init_fatal_sh=1"'
120120

docs/Targets.md

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,12 +3428,20 @@ Application running successfully!
34283428
Entering idle loop...
34293429
```
34303430

3431-
**Booting PetaLinux**
3431+
**Booting Linux via FIT image**
34323432

3433-
ZynqMP can chain into a PetaLinux kernel using the same FIT mechanism as
3434-
the Versal target. wolfBoot's FIT-using configs (`zynqmp.config` and
3435-
`zynqmp_sdcard.config`) default to `GZIP=1`, which lets you point the
3436-
FIT at a gzipped kernel (`Image.gz`) directly:
3433+
wolfBoot is a drop-in replacement for U-Boot's FIT image loader: it parses
3434+
the same `mkimage`-produced multi-component FIT (kernel + DTB + optional
3435+
ramdisk), honors per-subimage `load`/`entry`/`compression` properties, and
3436+
hands off to the kernel the same way - with the added value of
3437+
authenticating the entire FIT against a wolfBoot signature before any
3438+
subimage is touched.
3439+
3440+
ZynqMP can chain into a Linux kernel (PetaLinux, Yocto, or any other
3441+
producer) using the same FIT mechanism as the Versal target. wolfBoot's
3442+
FIT-using configs (`zynqmp.config` and `zynqmp_sdcard.config`) default to
3443+
`GZIP=1`, which lets you point the FIT at a gzipped kernel (`Image.gz`)
3444+
directly:
34373445

34383446
```dts
34393447
images {
@@ -3449,9 +3457,10 @@ images {
34493457

34503458
`mkimage -f your-zynqmp.its fitImage` then produces a single signed FIT
34513459
that wolfBoot decompresses straight to the kernel load address at boot.
3452-
See the [Versal "Booting PetaLinux"](#versal-gen-1-vmk180) section for a
3453-
full walkthrough - the flow is identical apart from the load addresses
3454-
and the `bl31`/`fsbl` versus `bl31`/`plm` boot chain. Set `GZIP=0` in
3460+
See the [Versal "Booting Linux via FIT image"](#versal-gen-1-vmk180)
3461+
section for a full walkthrough - the flow is identical apart from the
3462+
load addresses and the `bl31`/`fsbl` versus `bl31`/`plm` boot chain. Set
3463+
`GZIP=0` in
34553464
`.config` if you want to keep using an uncompressed `Image` plus
34563465
`compression = "none"`.
34573466

@@ -3468,18 +3477,18 @@ When PetaLinux is built with `INITRAMFS_IMAGE_BUNDLE = "0"` the rootfs cpio
34683477
ships as a separate `ramdisk` node in the FIT alongside the kernel and DTB.
34693478
wolfBoot can extract it, copy it to a configurable RAM address, and patch the
34703479
loaded DTB with `/chosen/linux,initrd-{start,end}` so the kernel finds it.
3471-
Enable this with `RAMDISK=1`:
3480+
Enable this with `FIT_RAMDISK=1`:
34723481

34733482
```sh
34743483
cp config/examples/zynqmp_sdcard.config .config
3475-
# Uncomment the RAMDISK / WOLFBOOT_LOAD_RAMDISK_ADDRESS / LINUX_BOOTARGS
3484+
# Uncomment the FIT_RAMDISK / WOLFBOOT_LOAD_RAMDISK_ADDRESS / LINUX_BOOTARGS
34763485
# block under "Optional: FIT-bundled initramfs" and comment out the
34773486
# LINUX_BOOTARGS_ROOT line above it.
34783487
make
34793488
```
34803489

34813490
Key options (in `config/examples/zynqmp_sdcard.config`):
3482-
- `RAMDISK=1` - enables FIT ramdisk extraction (`-DWOLFBOOT_FIT_RAMDISK`).
3491+
- `FIT_RAMDISK=1` - enables FIT ramdisk extraction (`-DWOLFBOOT_FIT_RAMDISK`).
34833492
- `WOLFBOOT_LOAD_RAMDISK_ADDRESS=0x40000000` - destination address. Pick a
34843493
region clear of the kernel image (`~0x80000` + tens of MB) and clear of
34853494
FIT staging (`WOLFBOOT_LOAD_ADDRESS=0x10000000` + FIT size). The default
@@ -3679,7 +3688,7 @@ Application running successfully!
36793688
Entering idle loop...
36803689
```
36813690

3682-
**Booting PetaLinux (QSPI)**
3691+
**Booting Linux via FIT image (QSPI)**
36833692

36843693
wolfBoot can boot a signed Linux kernel on the Versal VMK180, replacing U-Boot entirely for a secure boot chain.
36853694

hal/mpfs250.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,10 @@ int hal_dts_fixup(void* dts_addr)
327327
wolfBoot_printf("FDT: Version %d, Size %d\n",
328328
fdt_version(fdt), fdt_totalsize(fdt));
329329

330-
/* Expand total size to allow adding/modifying properties */
331-
fdt_set_totalsize(fdt, fdt_totalsize(fdt) + 512);
330+
/* Expand total size to allow adding/modifying properties.
331+
* Sizing comes from WOLFBOOT_FDT_FIXUP_HEADROOM in include/fdt.h. */
332+
fdt_set_totalsize(fdt,
333+
fdt_totalsize(fdt) + WOLFBOOT_FDT_FIXUP_HEADROOM);
332334

333335
/* Find /chosen node */
334336
off = fdt_find_node_offset(fdt, -1, "chosen");

hal/versal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,8 +1277,10 @@ int hal_dts_fixup(void* dts_addr)
12771277
fdt_version(fdt), fdt_totalsize(fdt));
12781278

12791279
/* Expand total size to allow adding/modifying properties (bootargs and,
1280-
* when WOLFBOOT_FIT_RAMDISK is in play, linux,initrd-{start,end}). */
1281-
fdt_set_totalsize(fdt, fdt_totalsize(fdt) + 768);
1280+
* when WOLFBOOT_FIT_RAMDISK is in play, linux,initrd-{start,end}).
1281+
* Sizing comes from WOLFBOOT_FDT_FIXUP_HEADROOM in include/fdt.h. */
1282+
fdt_set_totalsize(fdt,
1283+
fdt_totalsize(fdt) + WOLFBOOT_FDT_FIXUP_HEADROOM);
12821284

12831285
/* Find /chosen node; create it only if genuinely missing. Any other
12841286
* negative return (malformed FDT, etc.) is surfaced directly rather

hal/zynq.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,8 +1931,10 @@ int hal_dts_fixup(void* dts_addr)
19311931
* play) the linux,initrd-{start,end} properties. Physical headroom is
19321932
* already guaranteed by the load-address layout (DTB at
19331933
* WOLFBOOT_LOAD_DTS_ADDRESS, kernel loaded much higher), so growing
1934-
* the header is safe. Matches the pattern in hal/versal.c. */
1935-
fdt_set_totalsize(fdt, fdt_totalsize(fdt) + 768);
1934+
* the header is safe. Sizing comes from WOLFBOOT_FDT_FIXUP_HEADROOM
1935+
* in include/fdt.h - same constant as hal/versal.c. */
1936+
fdt_set_totalsize(fdt,
1937+
fdt_totalsize(fdt) + WOLFBOOT_FDT_FIXUP_HEADROOM);
19361938

19371939
/* Find /chosen node; create it only if genuinely missing. Any other
19381940
* negative return (malformed FDT, etc.) is surfaced directly rather

include/fdt.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ uint64_t fdt64_to_cpu(uint64_t x);
127127
#define fdt_set_size_dt_strings(fdt, val) (fdt_set_header(fdt, size_dt_strings, (val)))
128128
#define fdt_set_size_dt_struct(fdt, val) (fdt_set_header(fdt, size_dt_struct, (val)))
129129

130+
/* Headroom (bytes) appended to fdt_totalsize() before wolfBoot inserts
131+
* /chosen properties. Sized to comfortably hold a full LINUX_BOOTARGS
132+
* plus, when WOLFBOOT_FIT_RAMDISK is enabled, two 64-bit
133+
* linux,initrd-{start,end} cells with property-name overhead. A target
134+
* whose hal_dts_fixup() inserts more chosen entries can override this
135+
* with -DWOLFBOOT_FDT_FIXUP_HEADROOM=<bytes>. */
136+
#ifndef WOLFBOOT_FDT_FIXUP_HEADROOM
137+
#define WOLFBOOT_FDT_FIXUP_HEADROOM 768
138+
#endif
139+
130140
int fdt_check_header(const void *fdt);
131141
int fdt_next_node(const void *fdt, int offset, int *depth);
132142
int fdt_first_property_offset(const void *fdt, int nodeoffset);

options.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,11 +908,11 @@ ifeq ($(GZIP),1)
908908
CFLAGS+=-DWOLFBOOT_GZIP
909909
endif
910910

911-
# RAMDISK=1 enables FIT ramdisk (initramfs) extraction and DTB
911+
# FIT_RAMDISK=1 enables FIT ramdisk (initramfs) extraction and DTB
912912
# /chosen/linux,initrd-{start,end} fixup. Compressed (gzip) ramdisks
913913
# decompress through the same path when GZIP=1.
914-
RAMDISK ?= 0
915-
ifeq ($(RAMDISK),1)
914+
FIT_RAMDISK ?= 0
915+
ifeq ($(FIT_RAMDISK),1)
916916
CFLAGS+=-DWOLFBOOT_FIT_RAMDISK
917917
endif
918918

tools/config.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ ifeq ($(ARCH),)
9494
endif
9595

9696
# Global default: 0 means "use the FIT image's `load` property verbatim".
97-
# Defaulted globally (outside the CI ifeq block above) so RAMDISK=1 can
98-
# be toggled on any target without forcing an explicit address.
97+
# Defaulted globally (outside the CI ifeq block above) so FIT_RAMDISK=1
98+
# can be toggled on any target without forcing an explicit address.
9999
WOLFBOOT_LOAD_RAMDISK_ADDRESS?=0
100100

101101
CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXSDK MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO_DRIVERS \
@@ -123,7 +123,7 @@ CONFIG_VARS:= ARCH TARGET SIGN HASH MCUXSDK MCUXPRESSO MCUXPRESSO_CPU MCUXPRESSO
123123
WOLFBOOT_UNIVERSAL_KEYSTORE \
124124
XMSS_PARAMS \
125125
ELF BIG_ENDIAN \
126-
GZIP RAMDISK \
126+
GZIP FIT_RAMDISK \
127127
NXP_CUSTOM_DCD NXP_CUSTOM_DCD_OBJS \
128128
FLASH_OTP_KEYSTORE \
129129
KEYVAULT_OBJ_SIZE \

0 commit comments

Comments
 (0)