@@ -2038,6 +2038,154 @@ Application running successfully!
20382038Entering idle loop...
20392039```
20402040
2041+ ### Booting PetaLinux
2042+
2043+ wolfBoot can boot a signed Linux kernel on the Versal VMK180. This replaces U-Boot entirely for a secure boot chain.
2044+
2045+ #### Prerequisites
2046+
2047+ 1 . ** PetaLinux 2024.2** (or compatible version) built for VMK180
2048+ 2 . ** Pre-built Linux images** from your PetaLinux build:
2049+ - ` Image ` - Uncompressed Linux kernel (ARM64)
2050+ - ` system-default.dtb ` - Device tree blob for VMK180
2051+ - ` bl31.elf ` - ARM Trusted Firmware
2052+ - ` plm.elf ` - Platform Loader & Manager
2053+ - ` psmfw.elf ` - PSM firmware
2054+
2055+ 3 . ** SD card** with root filesystem (PetaLinux rootfs.ext4 written to partition 2)
2056+
2057+ #### Boot Flow
2058+
2059+ ```
2060+ PLM -> PSM -> BL31 (EL3) -> wolfBoot (EL2) -> Linux (EL1)
2061+ ```
2062+
2063+ wolfBoot:
2064+ 1 . Loads the signed FIT image from QSPI flash
2065+ 2 . Verifies the cryptographic signature (ECC384/SHA384)
2066+ 3 . Parses the FIT image to extract kernel and DTB
2067+ 4 . Applies DTB fixups (bootargs for root filesystem)
2068+ 5 . Transitions from EL2 to EL1 and jumps to the kernel
2069+
2070+ #### Creating the FIT Image
2071+
2072+ wolfBoot uses a FIT (Flattened Image Tree) image containing the kernel and device tree. Create the FIT image using the provided ITS file:
2073+
2074+ ``` sh
2075+ # Copy Linux images to wolfBoot root directory
2076+ cp /path/to/petalinux/images/linux/Image .
2077+ cp /path/to/petalinux/images/linux/system-default.dtb .
2078+
2079+ # Create FIT image using mkimage
2080+ mkimage -f hal/versal.its fitImage
2081+ ```
2082+
2083+ The ITS file (` hal/versal.its ` ) specifies:
2084+ - Kernel load address: ` 0x00200000 `
2085+ - DTB load address: ` 0x00001000 `
2086+ - SHA256 hashes for integrity
2087+
2088+ #### Signing the FIT Image
2089+
2090+ Sign the FIT image with wolfBoot tools:
2091+
2092+ ``` sh
2093+ # Sign with ECC384 (default for Versal config)
2094+ ./tools/keytools/sign --ecc384 --sha384 fitImage wolfboot_signing_private_key.der 1
2095+ ```
2096+
2097+ This creates ` fitImage_v1_signed.bin ` .
2098+
2099+ #### DTB Fixup for Root Filesystem
2100+
2101+ wolfBoot automatically modifies the device tree to set the kernel command line (` bootargs ` ). The default configuration mounts the root filesystem from SD card partition 2:
2102+
2103+ ```
2104+ earlycon root=/dev/mmcblk0p2 rootwait
2105+ ```
2106+
2107+ To customize the root device, add to your config:
2108+
2109+ ``` makefile
2110+ # Mount root from SD card partition 4
2111+ CFLAGS_EXTRA+=-DLINUX_BOOTARGS_ROOT =\"/dev/mmcblk0p4\"
2112+ ```
2113+
2114+ #### Flashing to QSPI
2115+
2116+ Flash the signed FIT image to the boot partition at ` 0x800000 ` :
2117+
2118+ ``` sh
2119+ # From U-Boot (via SD card boot)
2120+ tftp ${loadaddr} fitImage_v1_signed.bin
2121+ sf probe 0
2122+ sf erase 0x800000 +${filesize}
2123+ sf write ${loadaddr} 0x800000 ${filesize}
2124+ ```
2125+
2126+ #### Automated Testing
2127+
2128+ The test script supports Linux boot testing:
2129+
2130+ ``` sh
2131+ # Set path to PetaLinux images
2132+ export LINUX_IMAGES_DIR=/path/to/petalinux/images/linux
2133+
2134+ # Build wolfBoot, create signed FIT, flash to QSPI, and boot
2135+ ./tools/scripts/versal_test.sh --linux
2136+ ```
2137+
2138+ #### Example Linux Boot Output
2139+
2140+ ```
2141+ ========================================
2142+ wolfBoot Secure Boot - AMD Versal
2143+ ========================================
2144+ Current EL: 2
2145+ QSPI: Lower ID: 20 BB 21
2146+ QSPI: Upper ID: 20 BB 21
2147+ QSPI: 75MHz, Quad mode, DMA
2148+ Versions: Boot 1, Update 0
2149+ Trying Boot partition at 0x800000
2150+ Loading header 512 bytes from 0x800000 to 0xFFFFE00
2151+ Loading image 24658696 bytes from 0x800200 to 0x10000000...done (701 ms)
2152+ Boot partition: 0xFFFFE00 (sz 24658696, ver 0x1, type 0x601)
2153+ Checking integrity...done (167 ms)
2154+ Verifying signature...done (3 ms)
2155+ Successfully selected image in part: 0
2156+ Firmware Valid
2157+ Loading elf at 0x10000000
2158+ Invalid elf, falling back to raw binary
2159+ Flattened uImage Tree: Version 17, Size 24658696
2160+ Loading Image kernel-1: 0x100000D8 -> 0x200000 (24617472 bytes)
2161+ Image kernel-1: 0x200000 (24617472 bytes)
2162+ Loading Image fdt-1: 0x1177A3DC -> 0x1000 (39384 bytes)
2163+ Image fdt-1: 0x1000 (39384 bytes)
2164+ Loading DTS: 0x1000 -> 0x1000 (39384 bytes)
2165+ FDT: Version 17, Size 39384
2166+ FDT: Setting bootargs: earlycon root=/dev/mmcblk0p2 rootwait
2167+ FDT: Set chosen (28076), bootargs=earlycon root=/dev/mmcblk0p2 rootwait
2168+ Booting at 0x200000
2169+ [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd083]
2170+ [ 0.000000] Linux version 6.6.40-xilinx-g2b7f6f70a62a ...
2171+ [ 0.000000] Machine model: Xilinx Versal vmk180 Eval board revA
2172+ ...
2173+ PetaLinux 2024.2 xilinx-vmk180 ttyAMA0
2174+
2175+ xilinx-vmk180 login:
2176+ ```
2177+
2178+ #### Boot Performance
2179+
2180+ Typical boot timing with ECC384/SHA384 signing:
2181+
2182+ | Operation | Time |
2183+ | -----------| ------|
2184+ | Load 24MB FIT from QSPI | ~ 700ms |
2185+ | SHA384 integrity check | ~ 167ms |
2186+ | ECC384 signature verify | ~ 3ms |
2187+ | ** Total wolfBoot overhead** | ** ~ 870ms** |
2188+
20412189
20422190## Cypress PSoC-6
20432191
0 commit comments