From f5d027cecca5f7b0c028cabd1de60981f4e6c847 Mon Sep 17 00:00:00 2001 From: Joris van Rantwijk Date: Thu, 19 Sep 2024 21:08:22 +0200 Subject: [PATCH] Use U-Boot SPL instead of Xilinx FSBL --- os/12_build_uboot.sh | 13 +++++++++++++ os/22_prepare_sdcard.sh | 5 +++-- os/devicetree/redpitaya_puzzlefw.dts | 8 +++++++- os/script_env | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/os/12_build_uboot.sh b/os/12_build_uboot.sh index 2ecd9cd..80cdc81 100755 --- a/os/12_build_uboot.sh +++ b/os/12_build_uboot.sh @@ -7,6 +7,19 @@ setup_toolchain make -C "$UBOOT_DIR" CROSS_COMPILE=arm-linux- distclean +# We need the XSA file from Vivado. +# It contains the init code for the U-Boot SPL image. +if [ ! -f "$XSA_FILE" ]; then + echo "ERROR: $XSA_FILE not found" >&2 + echo "Build the FPGA image before building U-Boot." + exit 1 +fi + +# Create board directory with ps7_init_gpl.c. +rm -rf "$UBOOT_DIR/board/xilinx/zynq/redpitaya" +mkdir "$UBOOT_DIR/board/xilinx/zynq/redpitaya" +unzip $XSA_FILE ps7_init_gpl.c ps7_init_gpl.h -d "$UBOOT_DIR/board/xilinx/zynq/redpitaya" + cp -a devicetree/redpitaya_puzzlefw.dts "$UBOOT_DIR/arch/arm/dts/redpitaya.dts" cp -a config/uboot_redpitaya_puzzlefw_defconfig "$UBOOT_DIR/configs/redpitaya_puzzlefw_defconfig" diff --git a/os/22_prepare_sdcard.sh b/os/22_prepare_sdcard.sh index f6266e7..6611931 100755 --- a/os/22_prepare_sdcard.sh +++ b/os/22_prepare_sdcard.sh @@ -13,8 +13,9 @@ fi mkdir -p "$SDCARD_DIR" -# Copy Xilinx boot image (FSBL and U-Boot) -cp -a "$BOOTIMG_DIR/boot.bin" "$SDCARD_DIR" +# Copy U-Boot SPL and U-Boot program image +cp -a "$UBOOT_DIR/spl/boot.bin" "$SDCARD_DIR" +cp -a "$UBOOT_DIR/u-boot.img" "$SDCARD_DIR" # Wrap Linux kernel in U-Boot image file $MKIMAGE -A arm -O linux -C none -T kernel -a 0x8000 -e 0x8000 -n Linux -d "$LINUX_DIR/arch/arm/boot/zImage" "$SDCARD_DIR/uImage" diff --git a/os/devicetree/redpitaya_puzzlefw.dts b/os/devicetree/redpitaya_puzzlefw.dts index 2613d67..83b5415 100644 --- a/os/devicetree/redpitaya_puzzlefw.dts +++ b/os/devicetree/redpitaya_puzzlefw.dts @@ -146,7 +146,11 @@ }; &qspi { - status = "okay"; + // NOTE: "bootph-all" is a marker for U-Boot. + // It must be added to all sections that are required + // for the U-Boot SPL image. + bootph-all; + status = "okay"; is-dual = <0>; num-cs = <1>; spi-rx-bus-width = <4>; @@ -154,6 +158,7 @@ }; &sdhci0 { + bootph-all; status = "okay"; xlnx,has-cd = <0x1>; xlnx,has-power = <0x1>; @@ -173,6 +178,7 @@ }; &uart0 { + bootph-all; status = "okay"; device_type = "serial"; cts-override; diff --git a/os/script_env b/os/script_env index 524c460..af7f29b 100644 --- a/os/script_env +++ b/os/script_env @@ -17,6 +17,8 @@ LINUX_DIR="linux-xlnx" BOOTIMG_DIR="boot_img" SDCARD_DIR="sdcard_files" +XSA_FILE="../fpga/vivado/output/redpitaya_puzzlefw.xsa" + setup_toolchain () { if [ ! -x "$TOOLCHAIN_DIR/arm-linux-gcc" ]; then echo "ERROR: Missing $TOOLCHAIN_DIR/arm-linux-gcc" >&2