Skip to content

Commit 267e3d7

Browse files
committed
Add Xilinx Zynq-7000 (ZC702) wolfBoot port
1 parent 51592bc commit 267e3d7

9 files changed

Lines changed: 131 additions & 45 deletions

File tree

.github/workflows/test-configs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,11 @@ jobs:
654654
arch: arm
655655
config-file: ./config/examples/zynq7000.config
656656

657-
zc702_sdcard_test:
657+
zynq7000_sdcard_test:
658658
uses: ./.github/workflows/test-build.yml
659659
with:
660660
arch: arm
661-
config-file: ./config/examples/zc702_sdcard.config
661+
config-file: ./config/examples/zynq7000_sdcard.config
662662

663663
versal_vmk180_test:
664664
uses: ./.github/workflows/test-build-aarch64.yml

arch.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ ifeq ($(ARCH),ARM)
316316
# mapping enabled to avoid that, but we still link against the
317317
# aligned-safe memcpy in src/string.c so unaligned loads can never
318318
# surprise us regardless of MMU state.
319-
# U-Boot legacy 64-byte header strip is only meaningful for the
320-
# Linux/U-Boot payload variant (zynq7000_linux.config). Bare-metal
321-
# payloads (zynq7000.config, zc702_sdcard.config) shouldn't risk a
322-
# ~1-in-2^32 false-positive collision with UBOOT_IMG_HDR_MAGIC.
319+
# The legacy 64-byte uImage header strip is only meaningful when the
320+
# payload is a Linux kernel (LINUX_PAYLOAD=1). Bare-metal payloads
321+
# shouldn't risk a ~1-in-2^32 false-positive collision against
322+
# UBOOT_IMG_HDR_MAGIC, so the flag is gated on LINUX_PAYLOAD.
323323
ifeq ($(LINUX_PAYLOAD),1)
324324
CFLAGS+=-DWOLFBOOT_UBOOT_LEGACY
325325
endif

config/examples/zynq7000.config

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,33 @@ SIGN?=ECC256
44
HASH?=SHA256
55

66
# Cortex-A9 (Zynq-7000) - selected automatically via TARGET=zynq7000 in arch.mk.
7-
# This single config supports bare-metal, U-Boot, and Linux payloads from QSPI.
7+
# wolfBoot replaces U-Boot in the Z7 boot flow (BootROM -> FSBL -> wolfBoot ->
8+
# kernel/app, no U-Boot stage). This single config supports both bare-metal
9+
# and Linux payloads from QSPI.
810
DEBUG?=0
911
DEBUG_UART?=1
1012
V?=0
1113
SPMATH?=1
1214

13-
# Linux/U-Boot payload support (no-op for plain bare-metal payloads):
15+
# Linux payload support (no-op for plain bare-metal payloads):
1416
# LINUX_PAYLOAD=1 -> do_boot uses ARM Linux boot ABI (r0=0, r1=~0,
1517
# r2=DTB_phys, r3=0). Bare-metal apps don't read these
1618
# registers, so the same ABI is fine for them.
1719
# MMU=1 -> enables update_ram.c DTB-load codepath and pulls in
1820
# src/fdt.o. wolfBoot itself does NOT manage page
1921
# tables; it inherits FSBL's flat 1:1 DDR mapping.
20-
# ELF=1 -> wolfBoot understands ELF inputs (vmlinux / u-boot.elf)
21-
# and loads only their LOAD segments. Flat binaries
22-
# (zImage, bare-metal .bin) fall through to raw-binary
23-
# boot.
22+
# ELF=1 -> wolfBoot understands ELF inputs (e.g. vmlinux) and
23+
# loads only their LOAD segments. Flat binaries (zImage,
24+
# bare-metal .bin) fall through to raw-binary boot.
2425
# Cost vs. a strictly bare-metal-only build: ~5 KB extra wolfBoot binary
25-
# from the FDT/MMU/ELF support, in exchange for one config that covers all
26-
# three payload types.
26+
# from the FDT/MMU/ELF support, in exchange for one config that covers
27+
# both payload types.
2728
LINUX_PAYLOAD=1
2829
MMU=1
2930
ELF=1
3031

3132
# wolfBoot itself is staged by FSBL to DDR at 0x04000000 (hal/zynq7000.ld);
32-
# the verified payload (kernel/U-Boot/bare-metal app) is staged at
33+
# the verified payload (kernel or bare-metal app) is staged at
3334
# WOLFBOOT_LOAD_ADDRESS, well clear of wolfBoot. 1 GB DDR3 on ZC702
3435
# starts at 0x00000000.
3536
WOLFBOOT_LOAD_ADDRESS=0x10000000
Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ TARGET?=zynq7000
33
SIGN?=ECC256
44
HASH?=SHA256
55

6-
# Cortex-A9 ZC702 SD-card boot variant. Uses the generic SDHCI driver
6+
# Cortex-A9 Zynq-7000 SD-card boot variant. Uses the generic SDHCI driver
77
# (src/sdhci.c) with HAL hooks in hal/zynq7000.c that translate between the
88
# driver's Cadence SD4HC register layout and the Arasan SDHCI v2.0 standard
99
# layout used by the Zynq-7000 controller (same IP family as ZynqMP's v3.0,
1010
# just an older revision; the translation is reused from hal/zynq.c).
11+
#
12+
# wolfBoot replaces U-Boot in the Z7 boot flow (BootROM -> FSBL -> wolfBoot
13+
# -> kernel/app, no U-Boot stage). This single config supports both
14+
# bare-metal and Linux payloads from SD card -- see the LINUX_PAYLOAD/MMU/
15+
# ELF block below.
1116
DEBUG?=0
1217
DEBUG_UART?=1
1318
V?=0
@@ -17,17 +22,41 @@ SPMATH?=1
1722
DISK_SDCARD=1
1823
NO_XIP=1
1924

25+
# Linux payload support (no-op for plain bare-metal payloads):
26+
# LINUX_PAYLOAD=1 -> do_boot uses ARM Linux boot ABI (r0=0, r1=~0,
27+
# r2=DTB_phys, r3=0). Bare-metal apps don't read
28+
# these registers, so the same ABI is fine for them.
29+
# MMU=1 -> pulls in src/fdt.o for FDT-aware paths in
30+
# update_disk.c. wolfBoot does NOT manage page
31+
# tables; it inherits FSBL's flat 1:1 DDR mapping.
32+
# ELF=1 -> wolfBoot understands ELF inputs (e.g. vmlinux) and
33+
# loads only their LOAD segments. Flat binaries
34+
# (zImage, bare-metal .bin) fall through to raw-
35+
# binary boot.
36+
# For Linux from SD use tools/scripts/zynq7000/prepare_linux.sh APPENDED=1
37+
# (DTB concatenated to zImage and signed as one image). update_disk.c does
38+
# not read a separate PART_DTS_BOOT partition; the appended-DTB path is
39+
# what carries the device tree to the kernel via CONFIG_ARM_APPENDED_DTB.
40+
LINUX_PAYLOAD=1
41+
MMU=1
42+
ELF=1
43+
2044
# Stage payload at low DDR (clear of wolfBoot at 0x04000000-0x040FFFFF).
2145
WOLFBOOT_LOAD_ADDRESS=0x10000000
2246

47+
# DTB load address (Linux only, used by update_disk.c when a FIT image
48+
# carries a DTB). Ignored for bare-metal and for the appended-DTB Linux
49+
# flow. 16 MB clear of WOLFBOOT_LOAD_ADDRESS.
50+
WOLFBOOT_LOAD_DTS_ADDRESS=0x11000000
51+
2352
# MBR partition layout on the SD card. Pure MBR (no GPT) - the Zynq-7000
2453
# BootROM (UG821 ch.6.3) only accepts MBR with the first partition as
2554
# FAT32 and the Active flag set. wolfBoot's src/disk.c falls back to MBR
2655
# parsing when no protective-GPT entry is present.
2756
# MBR p1 (wolfBoot idx 0): FAT32-LBA Active - holds BOOT.BIN for BootROM.
2857
# MBR p2 (wolfBoot idx 1): Linux raw (0x83) - signed boot image.
2958
# MBR p3 (wolfBoot idx 2): Linux raw (0x83) - signed update image.
30-
# tools/scripts/zc702/prepare_sdcard.sh lays this out; BOOT_PART_A/B tell
59+
# tools/scripts/zynq7000/prepare_sdcard.sh lays this out; BOOT_PART_A/B tell
3160
# update_disk.c which MBR entries (0-indexed) to use for boot/update.
3261
CFLAGS_EXTRA+=-DBOOT_PART_A=1 -DBOOT_PART_B=2
3362

@@ -47,8 +76,17 @@ CFLAGS_EXTRA+=-DBOOT_PART_A=1 -DBOOT_PART_B=2
4776
# adds an explicit DAT-line reset between transfers.
4877
CFLAGS_EXTRA+=-DSDHCI_CLK_50MHZ=6000 -DSDHCI_CLK_25MHZ=6000
4978

50-
# Uncomment to enable verbose SDHCI driver logging when bringing up
51-
# new boards or debugging timing issues.
79+
# update_disk.c reads images in DISK_BLOCK_SIZE chunks. Default 512 B = one
80+
# disk_read = one CMD17 per 512 B, which makes a multi-MB Linux load issue
81+
# thousands of CMDs and stall the card with per-CMD overhead. Bump to
82+
# 512 KB so each disk_read pulls 1024 blocks via one CMD18 SDMA (matches
83+
# ZynqMP). Verified on ZC702 with a 4.76 MB appended-DTB zImage: 9 CMD18s
84+
# complete in well under a second. The default 4 KB SDMA buffer boundary
85+
# is left in place -- overriding it to 512 KB stalled SDMA on Arasan v2.0.
86+
CFLAGS_EXTRA+=-DDISK_BLOCK_SIZE=0x80000
87+
88+
# Uncomment for verbose SDHCI driver logging when bringing up new boards
89+
# or debugging timing issues.
5290
#CFLAGS_EXTRA+=-DDEBUG_SDHCI
5391

5492
# Image-header partition addresses are unused for disk boot (kept for the
@@ -65,4 +103,11 @@ WOLFBOOT_SECTOR_SIZE=0x1000
65103

66104
IMAGE_HEADER_SIZE=1024
67105

106+
# Required by image.c when MMU=1 is set, even though update_disk.c never
107+
# opens PART_DTS_BOOT/PART_DTS_UPDATE (the disk boot path uses appended-
108+
# DTB or FIT, not a separate DTB partition). Set to dummy addresses to
109+
# satisfy the build.
110+
WOLFBOOT_DTS_BOOT_ADDRESS=0x0
111+
WOLFBOOT_DTS_UPDATE_ADDRESS=0x0
112+
68113
CROSS_COMPILE=arm-none-eabi-

docs/Targets.md

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,16 +3396,18 @@ Entering idle loop...
33963396

33973397
AMD/Xilinx Zynq-7000 (XC7Z020) on the ZC702 Evaluation Kit - dual ARM Cortex-A9 (ARMv7-A 32-bit), 1 GB DDR3, 16 MB QSPI NOR (N25Q128A), SDIO, dual UART. Older sibling of the ZynqMP family - distinct silicon, different controllers (`XQspiPs` not `XQspiPsu`, Arasan SDHCI v2.0 not v3.0, no CSU/PMU/PUF, PL310 L2).
33983398

3399-
wolfBoot is loaded by the Xilinx Zynq-7000 FSBL into DDR:
3399+
wolfBoot replaces U-Boot in the Zynq-7000 boot flow -- there is no
3400+
U-Boot stage. wolfBoot is loaded by the Xilinx Zynq-7000 FSBL into
3401+
DDR:
34003402
```
3401-
BootROM -> FSBL -> wolfBoot -> signed app (or U-Boot/Linux)
3403+
BootROM -> FSBL -> wolfBoot -> signed app or Linux kernel
34023404
```
34033405

34043406
The FSBL handles all PS init (DDR, MIO, clocks, QSPI ref clock); wolfBoot only initializes UART, the QSPI controller, runs the verify/swap logic, and chain-loads the next stage.
34053407

34063408
This target supports:
3407-
- **QSPI boot** (primary): `config/examples/zynq7000.config` -- one config for bare-metal, U-Boot, and Linux payloads (LINUX_PAYLOAD=1 + MMU=1 + ELF=1; bare-metal apps don't pay any runtime cost beyond ~5 KB of unused FDT/MMU code).
3408-
- **SD card boot**: `config/examples/zc702_sdcard.config` -- bare-metal payload from MBR-partitioned SD via the generic SDHCI driver and the Arasan v2.0 translation in `hal/zynq7000.c`.
3409+
- **QSPI boot** (primary): `config/examples/zynq7000.config` -- one config for both bare-metal and Linux payloads (LINUX_PAYLOAD=1 + MMU=1 + ELF=1; bare-metal apps don't pay any runtime cost beyond ~5 KB of unused FDT/MMU code).
3410+
- **SD card boot**: `config/examples/zynq7000_sdcard.config` -- bare-metal **and** Linux payloads from MBR-partitioned SD via the generic SDHCI driver and the Arasan v2.0 translation in `hal/zynq7000.c`.
34093411
- **JTAG-loaded dev** via Platform Cable II + xsdb (no flash required).
34103412

34113413
### Prerequisites
@@ -3438,7 +3440,7 @@ Key options in `config/examples/zynq7000.config`:
34383440
- `ARCH=ARM` - 32-bit ARM
34393441
- `TARGET=zynq7000` - selects `hal/zynq7000.{c,h,ld}` and the `CORTEX_A9` arch.mk block
34403442
- `SIGN=ECC256` / `HASH=SHA256` - smaller and faster than RSA on Cortex-A9
3441-
- `LINUX_PAYLOAD=1 MMU=1 ELF=1` - lets the same image boot Linux/U-Boot or bare-metal. `do_boot` switches to the ARM Linux boot ABI (`r0=0`, `r1=~0`, `r2=DTB_phys`, `r3=0`) which bare-metal apps simply ignore. `MMU=1` enables `update_ram.c`'s DTB-load codepath and pulls in `src/fdt.o`; wolfBoot does not manage page tables (it inherits FSBL's flat 1:1 DDR mapping). `ELF=1` lets wolfBoot understand `vmlinux` / `u-boot.elf` inputs and load only their LOAD segments. Cost over a strictly bare-metal-only build: ~5 KB extra wolfBoot binary (31 KB -> 36 KB).
3443+
- `LINUX_PAYLOAD=1 MMU=1 ELF=1` - lets the same image boot Linux or bare-metal. `do_boot` switches to the ARM Linux boot ABI (`r0=0`, `r1=~0`, `r2=DTB_phys`, `r3=0`) which bare-metal apps simply ignore. `MMU=1` enables `update_ram.c`'s DTB-load codepath and pulls in `src/fdt.o`; wolfBoot does not manage page tables (it inherits FSBL's flat 1:1 DDR mapping). `ELF=1` lets wolfBoot understand ELF inputs (e.g. `vmlinux`) and load only their LOAD segments. Cost over a strictly bare-metal-only build: ~5 KB extra wolfBoot binary (31 KB -> 36 KB).
34423444
- `EXT_FLASH=1` - QSPI as external flash via `XQspiPs`
34433445
- `WOLFBOOT_LOAD_ADDRESS=0x10000000` - DDR offset 256 MB, where the verified app is staged before `do_boot`. Must be **above** wolfBoot's own region (`0x04000000`-`0x040FFFFF`) because `src/update_ram.c` enforces `dst > _end`.
34443446
- `WOLFBOOT_LOAD_DTS_ADDRESS=0x11000000` - DDR offset 272 MB, where a DTB read out of `PART_DTS_BOOT` would be relocated. Ignored for bare-metal payloads and for the appended-DTB Linux flow (where the DTB lives at the end of the signed kernel image).
@@ -3478,10 +3480,10 @@ The result is a 32-bit ARM ELF with entry point `0x04000000` and `.text` start a
34783480

34793481
```sh
34803482
cp ${PREBUILT_DIR}/zynq_fsbl.elf .
3481-
bootgen -arch zynq -image tools/scripts/zc702/zc702_qspi.bif -w -o BOOT.BIN
3483+
bootgen -arch zynq -image tools/scripts/zynq7000/zynq7000_qspi.bif -w -o BOOT.BIN
34823484
```
34833485

3484-
`bootgen` ships with Vitis. The `.bif` template at `tools/scripts/zc702/zc702_qspi.bif` is the minimum bootable image; add `download.bit` and a DTB if you also need to load the PL bitstream and a Linux device tree (see Milestone 5).
3486+
`bootgen` ships with Vitis. The `.bif` template at `tools/scripts/zynq7000/zynq7000_qspi.bif` is the minimum bootable image; add `download.bit` and a DTB if you also need to load the PL bitstream and a Linux device tree (see Milestone 5).
34853487

34863488
### Programming QSPI
34873489

@@ -3517,7 +3519,7 @@ For driver bring-up or quick iteration, skip bootgen and load directly via Platf
35173519

35183520
```sh
35193521
source /opt/Xilinx/2025.2/Vitis/settings64.sh # once per shell
3520-
xsdb tools/scripts/zc702/jtag_load.tcl
3522+
xsdb tools/scripts/zynq7000/jtag_load.tcl
35213523
```
35223524

35233525
The script runs the prebuilt FSBL (PS init: DDR/MIO/clocks/UART), then loads `wolfboot.elf` over the top, sets PC to `0x04000000` and CPSR to SVC with IRQ/FIQ masked, and resumes. Override paths via `FSBL_ELF=...` or `WOLFBOOT_ELF=...` env vars.
@@ -3567,15 +3569,15 @@ program_flash -f test-app/image_v1_signed.bin \
35673569
-flash_type qspi-x4-single -offset 0x100000
35683570
```
35693571

3570-
`program_flash` ships with Vitis. Then run wolfBoot via `xsdb tools/scripts/zc702/jtag_load.tcl` - it should verify and chain-load the test app, producing the heartbeat output above.
3572+
`program_flash` ships with Vitis. Then run wolfBoot via `xsdb tools/scripts/zynq7000/jtag_load.tcl` - it should verify and chain-load the test app, producing the heartbeat output above.
35713573

35723574
### QSPI driver self-test (`TEST_EXT_FLASH`)
35733575

35743576
To exercise the `XQspiPs` driver in isolation - read JEDEC ID, sector erase + page program + linear-mode read-back of a 256-byte pattern at `0x200000`:
35753577

35763578
```sh
35773579
make CFLAGS_EXTRA=-DTEST_EXT_FLASH wolfboot.elf
3578-
xsdb tools/scripts/zc702/jtag_load.tcl
3580+
xsdb tools/scripts/zynq7000/jtag_load.tcl
35793581
```
35803582

35813583
Expected output:
@@ -3616,10 +3618,14 @@ For TX-only commands sent without RX capture, `qspi_xfer4` picks `TXD1`/`TXD2`/`
36163618

36173619
### SD card boot (Milestone 6)
36183620

3619-
`config/examples/zc702_sdcard.config` enables SD-card boot via the generic
3621+
`config/examples/zynq7000_sdcard.config` enables SD-card boot via the generic
36203622
SDHCI driver (`src/sdhci.c`) with HAL hooks in `hal/zynq7000.c` that
36213623
translate the driver's Cadence SD4HC register layout to the Arasan
3622-
SDHCI v2.0 standard layout used by the Zynq-7000 controller.
3624+
SDHCI v2.0 standard layout used by the Zynq-7000 controller. The config
3625+
sets `LINUX_PAYLOAD=1 MMU=1 ELF=1` so the same SD-card image can chain-
3626+
load either a bare-metal app or a signed appended-DTB Linux zImage --
3627+
Linux-from-SD is verified end-to-end on ZC702 (full kernel banner +
3628+
SMP + driver init through to rootfs panic).
36233629

36243630
**Strap**: SW16-3 + SW16-4 ON (others OFF). `BOOT_MODE_REG = 0x5`.
36253631

@@ -3631,18 +3637,29 @@ SDHCI v2.0 standard layout used by the Zynq-7000 controller.
36313637
| p2 | 0x83 Linux raw | 16 MB | Signed boot image (`BOOT_PART_A=1`) |
36323638
| p3 | 0x83 Linux raw | 16 MB | Signed update image (`BOOT_PART_B=2`) |
36333639

3634-
`tools/scripts/zc702/prepare_sdcard.sh` lays this out (parted msdos +
3640+
`tools/scripts/zynq7000/prepare_sdcard.sh` lays this out (parted msdos +
36353641
manual MBR type/active patch + dd of signed images).
36363642

3643+
**Bare-metal payload** (signed test app):
3644+
36373645
```sh
3638-
cp config/examples/zc702_sdcard.config .config
3639-
make
3640-
make test-app/image.bin
3641-
IMAGE_HEADER_SIZE=1024 ./tools/keytools/sign --ecc256 --sha256 \
3642-
test-app/image.bin wolfboot_signing_private_key.der 1
3646+
cp config/examples/zynq7000_sdcard.config .config
3647+
make TARGET=zynq7000
3648+
cp ${PREBUILT_DIR}/zynq_fsbl.elf .
3649+
bootgen -arch zynq -image tools/scripts/zynq7000/zynq7000_qspi.bif -w -o BOOT.BIN
3650+
sudo ./tools/scripts/zynq7000/prepare_sdcard.sh /dev/sdX
3651+
```
3652+
3653+
**Linux payload** (signed appended-DTB zImage):
3654+
3655+
```sh
3656+
cp config/examples/zynq7000_sdcard.config .config
3657+
make TARGET=zynq7000
36433658
cp ${PREBUILT_DIR}/zynq_fsbl.elf .
3644-
bootgen -arch zynq -image tools/scripts/zc702/zc702_qspi.bif -w -o BOOT.BIN
3645-
sudo ./tools/scripts/zc702/prepare_sdcard.sh /dev/sdX
3659+
bootgen -arch zynq -image tools/scripts/zynq7000/zynq7000_qspi.bif -w -o BOOT.BIN
3660+
./tools/scripts/zynq7000/prepare_linux.sh # appends DTB to zImage and signs as one image
3661+
mv image_v1_signed.bin test-app/zImage_signed.bin
3662+
sudo ./tools/scripts/zynq7000/prepare_sdcard.sh /dev/sdX test-app/zImage_signed.bin
36463663
```
36473664

36483665
**Arasan SDHCI v2.0 quirks** (handled by the HAL/config):
@@ -3661,6 +3678,12 @@ sudo ./tools/scripts/zc702/prepare_sdcard.sh /dev/sdX
36613678
default ZC702 FSBL clock plan; `Z7_GTIMER_FREQ_HZ` in
36623679
`hal/zynq7000.h` defaults to that and feeds `hal_get_timer_us()`
36633680
used by the SDHCI driver's `udelay()`.
3681+
- `DISK_BLOCK_SIZE=0x80000` (512 KB) is set so `update_disk.c` issues
3682+
~10 CMD18 SDMA reads of 512 KB each instead of thousands of CMD17
3683+
PIO reads of 512 B each. The default 512 B causes the card to time
3684+
out (SRS12 bit 20 / EDT) on multi-MB Linux loads. The default 4 KB
3685+
SDMA buffer boundary is left in place; overriding it to 512 KB
3686+
stalled SDMA on Arasan v2.0 (TC never fired).
36643687

36653688
### Differences from the ZynqMP port
36663689

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Usage:
77
# source /opt/Xilinx/2025.2/Vitis/settings64.sh
8-
# xsdb tools/scripts/zc702/jtag_load.tcl
8+
# xsdb tools/scripts/zynq7000/jtag_load.tcl
99
#
1010
# Set the JTAG boot mode straps on the ZC702 (SW16 = all OFF) before use.
1111
# After this script runs the board may need a power-cycle to recover the
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Sign and stage a ZC702 Linux kernel for wolfBoot.
2+
# Sign and stage a Zynq-7000 Linux kernel for wolfBoot (verified on ZC702).
33
#
44
# Two modes (chosen by the APPENDED env var):
55
#
@@ -48,6 +48,12 @@ config_get() {
4848
WOLFBOOT_PARTITION_BOOT_ADDRESS=$(config_get WOLFBOOT_PARTITION_BOOT_ADDRESS)
4949
WOLFBOOT_DTS_BOOT_ADDRESS=$(config_get WOLFBOOT_DTS_BOOT_ADDRESS)
5050
WOLFBOOT_PARTITION_SIZE=$(config_get WOLFBOOT_PARTITION_SIZE)
51+
# The sign tool reads IMAGE_HEADER_SIZE from the environment (sign.c line
52+
# 2824). Without this export, sign defaults to 256 bytes -- which leaves
53+
# wolfBoot reading the wrong fw_base offset on flash if the running config
54+
# uses a larger header.
55+
IMAGE_HEADER_SIZE=$(config_get IMAGE_HEADER_SIZE)
56+
[ -n "$IMAGE_HEADER_SIZE" ] && export IMAGE_HEADER_SIZE
5157

5258
SIGN_TOOL="./tools/keytools/sign"
5359
KEY="wolfboot_signing_private_key.der"
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
# Lay out a ZC702 wolfBoot SD card.
2+
# Lay out a Zynq-7000 wolfBoot SD card (verified on ZC702 / Arasan v2.0).
33
#
44
# Pure MBR layout (no GPT). The Zynq-7000 BootROM (UG821 ch.6.3) requires
55
# an MBR with the first partition as FAT32, type 0x0C (FAT32-LBA), with the
@@ -19,7 +19,18 @@
1919
# p2=idx1, p3=idx2 - matching BOOT_PART_A=1 and BOOT_PART_B=2 in the config.
2020
#
2121
# Usage:
22-
# sudo ./tools/scripts/zc702/prepare_sdcard.sh /dev/sdX [signed_image]
22+
# sudo ./tools/scripts/zynq7000/prepare_sdcard.sh /dev/sdX [signed_image]
23+
#
24+
# Bare-metal payload (default):
25+
# sudo ./tools/scripts/zynq7000/prepare_sdcard.sh /dev/sdX
26+
# -> writes test-app/image_v1_signed.bin to p2 and p3.
27+
#
28+
# Linux payload (signed appended-DTB zImage produced by prepare_linux.sh):
29+
# sudo ./tools/scripts/zynq7000/prepare_sdcard.sh /dev/sdX \
30+
# test-app/zImage_signed.bin
31+
# -> writes the signed kernel image to p2 (BOOT_A) and p3 (BOOT_B).
32+
# The MBR partition layout is identical for both -- the choice of payload
33+
# is signing-side, not partitioning-side.
2334

2435
set -e
2536
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
@@ -54,7 +65,7 @@ esac
5465
# Some USB SD readers expose RM=0; in that case the user can set
5566
# ALLOW_NON_REMOVABLE=1 after eyeballing lsblk.
5667
if [ "${ALLOW_NON_REMOVABLE:-0}" != "1" ]; then
57-
rm_flag=$(lsblk -ndo RM "$DEV" 2>/dev/null || echo "")
68+
rm_flag=$(lsblk -ndo RM "$DEV" 2>/dev/null | tr -d '[:space:]' || echo "")
5869
if [ -n "$rm_flag" ] && [ "$rm_flag" != "1" ]; then
5970
echo -e "${RED}refusing $DEV (RM=$rm_flag - not flagged as removable)." >&2
6071
echo -e "Re-run with ALLOW_NON_REMOVABLE=1 if this really is the" >&2

0 commit comments

Comments
 (0)