Skip to content

Commit 27b52d5

Browse files
committed
Add Xilinx Zynq-7000 (ZC702) wolfBoot port
1 parent 8c7b864 commit 27b52d5

19 files changed

Lines changed: 2474 additions & 81 deletions

.github/workflows/test-configs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,24 @@ jobs:
648648
arch: aarch64
649649
config-file: ./config/examples/zynqmp_sdcard.config
650650

651+
zynq7000_test:
652+
uses: ./.github/workflows/test-build.yml
653+
with:
654+
arch: arm
655+
config-file: ./config/examples/zynq7000.config
656+
657+
zynq7000_linux_test:
658+
uses: ./.github/workflows/test-build.yml
659+
with:
660+
arch: arm
661+
config-file: ./config/examples/zynq7000_linux.config
662+
663+
zc702_sdcard_test:
664+
uses: ./.github/workflows/test-build.yml
665+
with:
666+
arch: arm
667+
config-file: ./config/examples/zc702_sdcard.config
668+
651669
versal_vmk180_test:
652670
uses: ./.github/workflows/test-build-aarch64.yml
653671
with:

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ ifeq ($(TARGET),sama5d3)
285285
MAIN_TARGET:=wolfboot.bin test-app/image_v1_signed.bin
286286
endif
287287

288+
ifeq ($(TARGET),zynq7000)
289+
MAIN_TARGET:=wolfboot.bin test-app/image_v1_signed.bin
290+
endif
291+
288292
ifeq ($(TARGET),rp2350)
289293
MAIN_TARGET:=include/target.h keytools wolfboot_signing_private_key.der pico-sdk-info
290294
endif

arch.mk

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,19 @@ ifeq ($(ARCH),ARM)
303303
CFLAGS+=-DWOLFBOOT_USE_STDLIBC
304304
endif
305305

306+
ifeq ($(TARGET),zynq7000)
307+
# AMD/Xilinx Zynq-7000 (Cortex-A9, ARMv7-A) - ZC702 Evaluation Kit.
308+
# Loaded by Xilinx FSBL into DDR; see hal/zynq7000.{c,h,ld}.
309+
CORTEX_A9=1
310+
UPDATE_OBJS:=src/update_ram.o
311+
CFLAGS+=-DWOLFBOOT_DUALBOOT -fno-builtin -ffreestanding
312+
# Do NOT define WOLFBOOT_USE_STDLIBC: newlib's memcpy uses unaligned
313+
# LDRs which fault on Cortex-A9 when MMU is off (FSBL leaves MMU off
314+
# on Zynq-7000). Use wolfBoot's own aligned-safe memcpy from src/string.c.
315+
# U-Boot legacy header detection for Linux/U-Boot payloads (Milestone 5)
316+
CFLAGS+=-DWOLFBOOT_UBOOT_LEGACY
317+
endif
318+
306319
ifeq ($(TARGET),va416x0)
307320
CFLAGS+=-I$(WOLFBOOT_ROOT)/hal/vorago/ \
308321
-I$(VORAGO_SDK_DIR)/common/drivers/hdr/ \
@@ -344,6 +357,49 @@ ifeq ($(CORTEX_A5),1)
344357
-DWOLFSSL_ARM_ARCH=7 -DWOLFSSL_ARMASM_INLINE -DWOLFSSL_ARMASM_NO_NEON
345358
endif
346359
endif
360+
else
361+
ifeq ($(CORTEX_A9),1)
362+
# Cortex-A9 (ARMv7-A, 32-bit) - Zynq-7000.
363+
# Build in ARM state (-marm); reset vector lands in ARM mode after FSBL.
364+
# Note: do not filter out -mthumb from CFLAGS/LDFLAGS - that converts the
365+
# variables to simple-expansion flavor and breaks lazy $(LSCRIPT) expansion
366+
# in test-app/Makefile. -marm appended later wins over -mthumb anyway.
367+
FPU=-mfpu=vfp3-d16
368+
CFLAGS+=-mcpu=cortex-a9 -mtune=cortex-a9 -marm -static -z noexecstack \
369+
-mno-unaligned-access
370+
LDFLAGS+=-mcpu=cortex-a9 -mtune=cortex-a9 -marm -static -z noexecstack
371+
# Cortex-A9 uses the same generic ARMv7-A startup as Cortex-A5
372+
# (src/boot_arm32_start.S handles VBAR, per-mode stacks, cache
373+
# invalidate, async-abort enable for any ARMv7-A target).
374+
OBJS+=src/boot_arm32.o src/boot_arm32_start.o
375+
# Linux/U-Boot payload: enable MMU + FDT codepaths in update_ram.c so DTBs
376+
# can be loaded from a separate signed PART_DTS_BOOT partition. The MMU
377+
# itself stays inherited from FSBL's flat 1:1 mapping; wolfBoot does not
378+
# manage page tables on Cortex-A9.
379+
ifeq ($(MMU),1)
380+
CFLAGS+=-DMMU -DWOLFBOOT_FDT
381+
OBJS+=src/fdt.o
382+
endif
383+
# SD card / eMMC boot: swap the update_ram loader for update_disk + GPT.
384+
# The SDHCI HAL hooks live in hal/zynq7000.c and translate the generic
385+
# Cadence-layout driver to the Arasan SDHCI v2.0 controller.
386+
ifneq ($(filter 1,$(DISK_SDCARD) $(DISK_EMMC)),)
387+
CFLAGS+=-DWOLFBOOT_UPDATE_DISK -DMAX_DISKS=1
388+
UPDATE_OBJS:=src/update_disk.o
389+
OBJS += src/gpt.o
390+
OBJS += src/disk.o
391+
endif
392+
ifeq ($(NO_ASM),1)
393+
MATH_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_c32.o
394+
else
395+
MATH_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sp_arm32.o
396+
ifneq ($(NO_ARM_ASM),1)
397+
OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-32-sha256-asm.o
398+
OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/port/arm/armv8-32-sha256-asm_c.o
399+
CFLAGS+=-DWOLFSSL_SP_ARM32_ASM -DWOLFSSL_ARMASM -DWOLFSSL_ARMASM_NO_HW_CRYPTO \
400+
-DWOLFSSL_ARM_ARCH=7 -DWOLFSSL_ARMASM_INLINE -DWOLFSSL_ARMASM_NO_NEON
401+
endif
402+
endif
347403
else
348404
# All others use boot_arm.o
349405
OBJS+=src/boot_arm.o
@@ -456,6 +512,7 @@ else
456512
endif
457513
endif
458514
endif
515+
endif
459516

460517

461518
## Renesas RX
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ARCH?=ARM
2+
TARGET?=zynq7000
3+
SIGN?=ECC256
4+
HASH?=SHA256
5+
6+
# Cortex-A9 ZC702 SD-card boot variant. Uses the generic SDHCI driver
7+
# (src/sdhci.c) with HAL hooks in hal/zynq7000.c that translate between the
8+
# driver's Cadence SD4HC register layout and the Arasan SDHCI v2.0 standard
9+
# layout used by the Zynq-7000 controller (same IP family as ZynqMP's v3.0,
10+
# just an older revision; the translation is reused from hal/zynq.c).
11+
DEBUG?=0
12+
DEBUG_UART?=1
13+
V?=0
14+
SPMATH?=1
15+
16+
# SD card boot - swaps update_ram.o for update_disk.o + GPT/disk support.
17+
DISK_SDCARD=1
18+
NO_XIP=1
19+
20+
# Stage payload at low DDR (clear of wolfBoot at 0x04000000-0x040FFFFF).
21+
WOLFBOOT_LOAD_ADDRESS=0x10000000
22+
23+
# GPT/MBR partition layout on the SD card.
24+
# GPT partition 0 (idx 0): FAT32 - holds BOOT.BIN for the BootROM.
25+
# GPT partition 1 (idx 1): raw - signed boot image (BOOT_PART_A).
26+
# GPT partition 2 (idx 2): raw - signed update image (BOOT_PART_B).
27+
# tools/scripts/zc702/prepare_sdcard.sh lays this out; BOOT_PART_A/B tell
28+
# update_disk.c which GPT entries to use for boot/update.
29+
CFLAGS_EXTRA+=-DBOOT_PART_A=1 -DBOOT_PART_B=2
30+
31+
# Arasan SDHCI v2.0 on Zynq-7000 is 3.3V-only, no UHS-I. The generic
32+
# driver tries to push the card to UHS-I SDR25 / 50 MHz / High Speed mode
33+
# which is invalid for our v2.0 + 3.3V combo and causes DTOE on the first
34+
# data transfer (MBR read). Cap the post-init clock at SD default-speed
35+
# 25 MHz; the HSE bit is also masked in hal/zynq7000.c sdhci_reg_write so
36+
# the controller stays in single-edge timing the card matches.
37+
# Cap the post-init SDHCI clock at 6 MHz. The Arasan SDHCI v2.0 on
38+
# Zynq-7000 has a clock-dependent state-cleanup issue: at 12 MHz multi-
39+
# block reads (CMD18) work, but a single-block read (CMD17) issued
40+
# immediately after a CMD18+CMD12 sequence times out (DTOE) on the first
41+
# data block. At 24 MHz even the very first CMD17 fails. 6 MHz / 4-bit
42+
# bus is plenty fast for boot-time loading (~3 MB/s) and is well below
43+
# the v2.0 quirk threshold; raise this if a future fix in src/sdhci.c
44+
# adds an explicit DAT-line reset between transfers.
45+
CFLAGS_EXTRA+=-DSDHCI_CLK_50MHZ=6000 -DSDHCI_CLK_25MHZ=6000
46+
47+
# Uncomment to enable verbose SDHCI driver logging when bringing up
48+
# new boards or debugging timing issues.
49+
#CFLAGS_EXTRA+=-DDEBUG_SDHCI
50+
51+
# Image-header partition addresses are unused for disk boot (kept for the
52+
# Makefile sanity checks). update_disk.c finds images by GPT entry, not by
53+
# memory address.
54+
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x00100000
55+
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00700000
56+
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x00D00000
57+
WOLFBOOT_PARTITION_SIZE=0x00600000
58+
# Sector size of WOLFBOOT_PARTITION (not the SD physical sector, which is
59+
# always 512 B). Used as the smallest erase/copy unit for the BOOT/UPDATE
60+
# partitions; must be > IMAGE_HEADER_SIZE.
61+
WOLFBOOT_SECTOR_SIZE=0x1000
62+
63+
IMAGE_HEADER_SIZE=1024
64+
65+
CROSS_COMPILE=arm-none-eabi-

config/examples/zynq7000.config

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
ARCH?=ARM
2+
TARGET?=zynq7000
3+
SIGN?=ECC256
4+
HASH?=SHA256
5+
6+
# Cortex-A9 (Zynq-7000) - selected automatically via TARGET=zynq7000 in arch.mk
7+
DEBUG?=0
8+
DEBUG_UART?=1
9+
V?=0
10+
SPMATH?=1
11+
12+
# wolfBoot itself is loaded by Xilinx FSBL to DDR at 0x04000000 (hal/zynq7000.ld).
13+
# WOLFBOOT_LOAD_ADDRESS is the *app* staging address: where wolfBoot copies
14+
# the verified signed image before do_boot. Must NOT overlap wolfBoot itself
15+
# AND src/update_ram.c expects dst > wolfBoot's _end - so place it above the
16+
# wolfBoot region (0x04000000-0x040FFFFF) at 16 MB.
17+
WOLFBOOT_LOAD_ADDRESS=0x10000000
18+
19+
# QSPI flash (16 MB N25Q128A on ZC702) via XQspiPs (hal/zynq7000.c).
20+
# Override EXT_FLASH=0 on the make command line for JTAG-only dev builds.
21+
EXT_FLASH?=1
22+
NO_XIP=1
23+
24+
# QSPI partition layout (16 MB total):
25+
# 0x000000 - 0x0FFFFF BOOT.BIN (FSBL + wolfboot)
26+
# 0x100000 - 0x6FFFFF BOOT_A (~6 MB primary)
27+
# 0x700000 - 0xCFFFFF UPDATE_B (~6 MB update)
28+
# 0xD00000 - 0xD0FFFF SWAP scratch (64 KB sector)
29+
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x00100000
30+
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00700000
31+
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x00D00000
32+
WOLFBOOT_PARTITION_SIZE=0x00600000
33+
WOLFBOOT_SECTOR_SIZE=0x10000
34+
35+
# DTS placeholders (used in Milestone 5 for Linux payload)
36+
WOLFBOOT_LOAD_DTS_ADDRESS=0x00100000
37+
WOLFBOOT_DTS_BOOT_ADDRESS=0x00080000
38+
WOLFBOOT_DTS_UPDATE_ADDRESS=0x00680000
39+
40+
IMAGE_HEADER_SIZE=1024
41+
42+
CROSS_COMPILE=arm-none-eabi-
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
ARCH?=ARM
2+
TARGET?=zynq7000
3+
SIGN?=ECC256
4+
HASH?=SHA256
5+
6+
# Cortex-A9 Linux/U-Boot variant: enables MMU + WOLFBOOT_FDT codepaths so
7+
# update_ram.c loads a signed DTB out of PART_DTS_BOOT, and switches do_boot
8+
# to the ARM Linux boot ABI (r0=0, r1=~0, r2=DTB_phys_addr).
9+
DEBUG?=0
10+
DEBUG_UART?=1
11+
V?=0
12+
SPMATH?=1
13+
14+
# Linux/U-Boot payload tells wolfBoot to use the ARM Linux boot ABI in
15+
# do_boot (boot_arm32.c). MMU=1 enables the DTB load logic in update_ram.c
16+
# and pulls in src/fdt.o. ELF=1 lets wolfBoot understand u-boot.elf or
17+
# vmlinux ELF inputs and load only their LOAD segments.
18+
LINUX_PAYLOAD=1
19+
MMU=1
20+
ELF=1
21+
22+
# wolfBoot itself is staged by FSBL to DDR at 0x04000000 (hal/zynq7000.ld);
23+
# the kernel/U-Boot image is staged at WOLFBOOT_LOAD_ADDRESS, well clear of
24+
# wolfBoot. 1 GB DDR3 on ZC702 starts at 0x00000000.
25+
WOLFBOOT_LOAD_ADDRESS=0x10000000
26+
27+
# DTB load address - kernel reads it from r2. 16 MB clear of WOLFBOOT_LOAD.
28+
WOLFBOOT_LOAD_DTS_ADDRESS=0x11000000
29+
30+
EXT_FLASH?=1
31+
NO_XIP=1
32+
33+
# QSPI partition layout (16 MB total) - wider partitions to hold a full
34+
# Linux kernel + DTB. Adjust WOLFBOOT_PARTITION_SIZE to fit the largest
35+
# signed kernel you ship.
36+
# 0x000000 - 0x07FFFF BOOT.BIN (FSBL + wolfboot, 512 KB)
37+
# 0x080000 - 0x0FFFFF DTS_BOOT (signed DTB, 512 KB)
38+
# 0x100000 - 0x6FFFFF BOOT_A (~6 MB kernel)
39+
# 0x700000 - 0x77FFFF DTS_UPD (signed update DTB, 512 KB)
40+
# 0x780000 - 0xDFFFFF UPDATE_B (~6.5 MB update kernel)
41+
# 0xE00000 - 0xE0FFFF SWAP (64 KB)
42+
WOLFBOOT_PARTITION_BOOT_ADDRESS=0x00100000
43+
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00780000
44+
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x00E00000
45+
WOLFBOOT_PARTITION_SIZE=0x00600000
46+
WOLFBOOT_SECTOR_SIZE=0x10000
47+
48+
WOLFBOOT_DTS_BOOT_ADDRESS=0x00080000
49+
WOLFBOOT_DTS_UPDATE_ADDRESS=0x00700000
50+
51+
IMAGE_HEADER_SIZE=1024
52+
53+
CROSS_COMPILE=arm-none-eabi-

0 commit comments

Comments
 (0)