Skip to content

Commit 8e2e553

Browse files
committed
AMD/Xilinx Versal Gen 1 VMK180 wolfBoot support
1 parent e380365 commit 8e2e553

File tree

12 files changed

+2064
-27
lines changed

12 files changed

+2064
-27
lines changed

arch.mk

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,34 @@ ifeq ($(ARCH),AARCH64)
7878
HASH_HAL=1
7979
CFLAGS+=-DWOLFBOOT_ZYNQMP_CSU
8080
endif
81-
else
82-
ifeq ($(TARGET),nxp_ls1028a)
83-
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
84-
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72
81+
endif
8582

86-
CFLAGS +=-ffunction-sections -fdata-sections
87-
LDFLAGS+=-Wl,--gc-sections
83+
ifeq ($(TARGET),versal)
84+
# AMD Versal ACAP (VMK180) - Dual Cortex-A72
85+
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
86+
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72
87+
CFLAGS+=-DWOLFBOOT_DUALBOOT
88+
# Support detection and skip of U-Boot legacy header
89+
CFLAGS+=-DWOLFBOOT_UBOOT_LEGACY
90+
endif
8891

89-
ifeq ($(DEBUG_UART),0)
90-
CFLAGS+=-fno-builtin-printf
91-
endif
92+
ifeq ($(TARGET),nxp_ls1028a)
93+
ARCH_FLAGS=-mcpu=cortex-a72+crypto -march=armv8-a+crypto -mtune=cortex-a72
94+
CFLAGS+=$(ARCH_FLAGS) -DCORTEX_A72
9295

93-
SPI_TARGET=nxp
94-
else
95-
# By default disable ARM ASM for other targets
96-
NO_ARM_ASM?=1
96+
CFLAGS +=-ffunction-sections -fdata-sections
97+
LDFLAGS+=-Wl,--gc-sections
98+
99+
ifeq ($(DEBUG_UART),0)
100+
CFLAGS+=-fno-builtin-printf
97101
endif
102+
103+
SPI_TARGET=nxp
104+
endif
105+
106+
# Default ARM ASM setting for unrecognized AARCH64 targets
107+
ifeq ($(filter zynq versal nxp_ls1028a,$(TARGET)),)
108+
NO_ARM_ASM?=1
98109
endif
99110

100111
ifeq ($(SPMATH),1)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# wolfBoot configuration for AMD Versal VMK180 - DDR Boot (U-Boot Replacement)
2+
# Versal Prime VM1802 ACAP - Dual ARM Cortex-A72
3+
#
4+
# This configuration replaces U-Boot in the Versal boot flow:
5+
# PLM -> PSM -> BL31 (EL3) -> wolfBoot (EL2) -> Linux (EL1)
6+
#
7+
# wolfBoot entry point is 0x8000000 in DDR, running at EL2 (non-secure)
8+
# All clock, MIO, and DDR initialization is done by PLM/PSM before wolfBoot starts
9+
10+
ARCH?=AARCH64
11+
TARGET?=versal
12+
13+
WOLFBOOT_VERSION?=1
14+
15+
# ECC-384 with SHA-384 (good balance of security and performance)
16+
SIGN?=ECC384
17+
HASH?=SHA384
18+
IMAGE_HEADER_SIZE?=512
19+
20+
# RSA 4096-bit with SHA3-384 (alternative)
21+
#SIGN?=RSA4096
22+
#HASH?=SHA3
23+
#IMAGE_HEADER_SIZE?=1024
24+
25+
# Debug options
26+
DEBUG?=1
27+
DEBUG_SYMBOLS=1
28+
DEBUG_UART=1
29+
30+
VTOR?=1
31+
CORTEX_M0?=0
32+
NO_ASM?=0
33+
ALLOW_DOWNGRADE?=0
34+
NVM_FLASH_WRITEONCE?=0
35+
V?=0
36+
SPMATH?=1
37+
RAM_CODE?=0
38+
DUALBANK_SWAP?=0
39+
PKA?=0
40+
WOLFTPM?=0
41+
42+
# Flash configuration
43+
EXT_FLASH?=1
44+
NO_XIP=1
45+
46+
# ELF loading support
47+
ELF?=1
48+
49+
# Toolchain
50+
USE_GCC=1
51+
CROSS_COMPILE=aarch64-none-elf-
52+
53+
# ============================================================================
54+
# Boot Memory Layout
55+
# ============================================================================
56+
# wolfBoot runs from DDR at 0x8000000 (same address as U-Boot)
57+
# This matches the partition header from PetaLinux BOOT.BIN:
58+
# exec_addr: 0x08000000, load_addr: 0x08000000
59+
# EL: el-2, trustzone: non-secure, aarch-64
60+
WOLFBOOT_ORIGIN=0x8000000
61+
62+
# Optional debugging with OCRAM
63+
# Versal Gen 1 (VMK180): OCM is 256KB at 0xFFFC0000 - 0xFFFFFFFF
64+
# Versal Gen 2: OCM is 2MB at 0xFFE00000 - 0xFFFFFFFF
65+
#WOLFBOOT_ORIGIN=0xFFFC0000
66+
67+
# Flash Sector Size (QSPI)
68+
WOLFBOOT_SECTOR_SIZE=0x20000
69+
70+
# Application Partition Size (44MB)
71+
WOLFBOOT_PARTITION_SIZE=0x2C00000
72+
73+
# Location in Flash for Primary Boot Partition
74+
WOLFBOOT_PARTITION_BOOT_ADDRESS?=0x800000
75+
76+
# Load Partition to RAM Address (Linux kernel loads here)
77+
WOLFBOOT_LOAD_ADDRESS?=0x10000000
78+
79+
# Location in Flash for Secondary Partition (update image)
80+
WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x3400000
81+
82+
# Location to store wolfBoot state/swap
83+
WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x6000000
84+
85+
# DTS (Device Tree) - matches addresses from BOOT.BIN analysis
86+
WOLFBOOT_LOAD_DTS_ADDRESS?=0x1000
87+
WOLFBOOT_DTS_BOOT_ADDRESS?=0x7B0000
88+
WOLFBOOT_DTS_UPDATE_ADDRESS?=0x39B0000
89+
90+
# Speed up reads by using larger blocks
91+
CFLAGS_EXTRA+=-DWOLFBOOT_SHA_BLOCK_SIZE=4096
92+
93+
# UART Configuration - UART0 for APU console
94+
CFLAGS_EXTRA+=-DDEBUG_UART_NUM=0

docs/Targets.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This README describes configuration of supported targets.
4848
* [TI Hercules TMS570LC435](#ti-hercules-tms570lc435)
4949
* [Vorago VA416x0](#vorago-va416x0)
5050
* [Xilinx Zynq UltraScale](#xilinx-zynq-ultrascale)
51+
* [Versal Gen 1 VMK180](#versal-gen-1-vmk180)
5152

5253
## STM32F4
5354

@@ -1859,6 +1860,123 @@ qemu-system-aarch64 -machine xlnx-zcu102 -cpu cortex-a53 -serial stdio -display
18591860
`tools/keytools/sign --rsa4096 --sha3 /srv/linux-rpi4/vmlinux.bin wolfboot_signing_private_key.der 1`
18601861

18611862

1863+
## Versal Gen 1 VMK180
1864+
1865+
AMD Versal Prime VM1802 ACAP - Dual ARM Cortex-A72 (VMK180 Evaluation Board)
1866+
1867+
wolfBoot replaces U-Boot in the Versal boot flow:
1868+
```
1869+
PLM -> PSM -> BL31 (EL3) -> wolfBoot (EL2) -> Linux (EL1)
1870+
```
1871+
1872+
wolfBoot runs from DDR at address `0x8000000` at EL2 (non-secure). All clock, MIO, and DDR initialization is handled by PLM/PSM before wolfBoot starts.
1873+
1874+
See example configuration file at `config/examples/versal_vmk180.config`.
1875+
1876+
### Prerequisites
1877+
1878+
1. **Xilinx Vitis 2024.1 or 2024.2** (required for bootgen - 2025.1 or later has QSPI boot issues)
1879+
- Set `VITIS_PATH` environment variable: `export VITIS_PATH=/opt/Xilinx/Vitis/2024.1`
1880+
1881+
2. **Toolchain**
1882+
- ARM GCC toolchain: `aarch64-none-elf-gcc`
1883+
1884+
1885+
### Configuration Options
1886+
1887+
Key configuration options in `config/examples/versal_vmk180.config`:
1888+
1889+
- `ARCH=AARCH64` - ARM 64-bit architecture
1890+
- `TARGET=versal` - Versal platform target
1891+
- `WOLFBOOT_ORIGIN=0x8000000` - Entry point in DDR
1892+
- `WOLFBOOT_SECTOR_SIZE=0x20000` - QSPI flash sector size (128KB)
1893+
- `WOLFBOOT_PARTITION_SIZE=0x2C00000` - Application partition size (44MB)
1894+
- `EXT_FLASH=1` - External flash support
1895+
- `ELF=1` - ELF loading support
1896+
1897+
### Memory Layout
1898+
1899+
| Partition | Size | Address | Description |
1900+
|-------------|--------|---------|-------------|
1901+
| Bootloader | - | 0x8000000 | wolfBoot in DDR (loaded by BL31) |
1902+
| Primary | 44MB | 0x800000 | Boot partition in QSPI |
1903+
| Update | 44MB | 0x3400000 | Update partition in QSPI |
1904+
| Swap | - | 0x6000000 | Swap area in QSPI |
1905+
1906+
### Debugging
1907+
1908+
For debugging with OCRAM (OCM), set `WOLFBOOT_ORIGIN=0xFFFC0000` in the config file. Versal Gen 1 OCM is 256KB at `0xFFFC0000 - 0xFFFFFFFF`.
1909+
1910+
### Building wolfBoot
1911+
1912+
Build wolfBoot from the wolfBoot root directory:
1913+
1914+
```sh
1915+
cp config/examples/versal_vmk180.config .config
1916+
make clean
1917+
make
1918+
```
1919+
1920+
### Building BOOT.BIN
1921+
1922+
If you don't already have prebuilt firmware, clone the Xilinx prebuilt firmware repository:
1923+
1924+
```sh
1925+
git clone --branch xlnx_rel_v2024.1 https://github.com/Xilinx/soc-prebuilt-firmware.git
1926+
export PREBUILT_DIR=$(pwd)/../soc-prebuilt-firmware/vmk180-versal
1927+
```
1928+
1929+
Copy the required files into wolfboot root directory:
1930+
1931+
```sh
1932+
cp ${PREBUILT_DIR}/project_1.pdi .
1933+
cp ${PREBUILT_DIR}/plm.elf .
1934+
cp ${PREBUILT_DIR}/psmfw.elf .
1935+
cp ${PREBUILT_DIR}/bl31.elf .
1936+
cp ${PREBUILT_DIR}/system-default.dtb .
1937+
```
1938+
1939+
Source the Vitis environment and generate BOOT.BIN using bootgen:
1940+
1941+
```sh
1942+
source ${VITIS_PATH}/settings64.sh
1943+
bootgen -arch versal -image ./tools/scripts/vmk180/boot_wolfboot.bif -w -o BOOT.BIN
1944+
```
1945+
1946+
The BIF file (`boot_wolfboot.bif`) references files using relative paths in the same directory. After successful generation, `BOOT.BIN` will be created in `tools/scripts/vmk180/`.
1947+
1948+
### Flashing QSPI
1949+
1950+
Flash `BOOT.BIN` to QSPI flash using one of the following methods:
1951+
1952+
- **Vitis**: Use the Hardware Manager to program the QSPI flash via JTAG. Load `BOOT.BIN` and program to QSPI32 flash memory.
1953+
1954+
- **Lauterbach**: Use Trace32 to program QSPI flash via JTAG. Load `BOOT.BIN` and write to QSPI flash memory addresses.
1955+
1956+
- **U-Boot via SD Card**: Boot from SD card with U-Boot, then use TFTP to download `BOOT.BIN` and program QSPI flash:
1957+
```sh
1958+
tftp ${loadaddr} BOOT.BIN
1959+
sf probe 0 0 0
1960+
sf erase 0 +${filesize}
1961+
sf write ${loadaddr} 0 ${filesize}
1962+
```
1963+
1964+
### Example Boot Output
1965+
1966+
```
1967+
========================================
1968+
wolfBoot Secure Boot - AMD Versal
1969+
========================================
1970+
Current EL: 2
1971+
Timer Freq: 99999904 Hz
1972+
ext_flash_read: STUB
1973+
ext_flash_read: STUB
1974+
Versions: Boot 0, Update 0
1975+
No valid image found!
1976+
wolfBoot: PANIC!
1977+
```
1978+
1979+
18621980
## Cypress PSoC-6
18631981

18641982
The Cypress PSoC 62S2 is a dual-core Cortex-M4 & Cortex-M0+ MCU. The secure boot process is managed by the M0+.

0 commit comments

Comments
 (0)