From b86f43de0be0c511358a7caeab5d935a64eb9599 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Tue, 27 Jul 2021 16:19:18 +0200 Subject: [PATCH] xilinx: zynqmp: Add support for runtime dfu_alt_info setup The main reason for this to be implemented is capsule update. Two memories are supported and tested which is MMC FAT based and QSPI based. For creating capsule these commands are used: ./tools/mkeficapsule --raw spl/boot.bin --index 1 capsule1.bin ./tools/mkeficapsule --raw u-boot.itb --index 2 capsule2.bin Then transfer to SD card where these commands run: load mmc 0 10000000 capsule1.bin efidebug capsule update -v 10000000 load mmc 0 10000000 capsule2.bin efidebug capsule update -v 10000000 Depends on the boot device used are binaries loaded to qspi or mmc fat partition. Also multiboot register is handled to make sure that the same location(id) is used as image which is upgraded. Two locations are used by purpose for SPL flow. If only boot.bin is used create only one capsule. Signed-off-by: Michal Simek --- board/xilinx/zynqmp/zynqmp.c | 54 ++++++++++++++++++++++++++++ configs/xilinx_zynqmp_virt_defconfig | 1 + 2 files changed, 55 insertions(+) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 1b0356c84c..27bb2b056c 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -818,3 +820,55 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_NOWHERE; } } + +#if defined(CONFIG_SET_DFU_ALT_INFO) + +#define DFU_ALT_BUF_LEN SZ_1K + +void set_dfu_alt_info(char *interface, char *devstr) +{ + u8 multiboot; + int bootseq = 0; + + ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN); + + if (env_get("dfu_alt_info")) + return; + + memset(buf, 0, sizeof(buf)); + + multiboot = multi_boot(); + debug("Multiboot: %d\n", multiboot); + + switch (zynqmp_get_bootmode()) { + case EMMC_MODE: + case SD_MODE: + case SD1_LSHFT_MODE: + case SD_MODE1: + bootseq = mmc_get_env_dev(); + if (!multiboot) + snprintf(buf, DFU_ALT_BUF_LEN, + "mmc %d:1=boot.bin fat %d 1;" + "u-boot.itb fat %d 1", + bootseq, bootseq, bootseq); + else + snprintf(buf, DFU_ALT_BUF_LEN, + "mmc %d:1=boot%04d.bin fat %d 1;" + "u-boot.itb fat %d 1", + bootseq, multiboot, bootseq, bootseq); + break; + case QSPI_MODE_24BIT: + case QSPI_MODE_32BIT: + snprintf(buf, DFU_ALT_BUF_LEN, + "sf 0:0=boot.bin raw %x 0x1500000;" + "u-boot.itb raw 0x%x 0x500000", + multiboot * SZ_32K, CONFIG_SYS_SPI_U_BOOT_OFFS); + break; + default: + return; + } + + env_set("dfu_alt_info", buf); + puts("DFU alt info setting: done\n"); +} +#endif diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig index 73972a0dc9..40a87ca904 100644 --- a/configs/xilinx_zynqmp_virt_defconfig +++ b/configs/xilinx_zynqmp_virt_defconfig @@ -94,6 +94,7 @@ CONFIG_DFU_NAND=y CONFIG_DFU_RAM=y CONFIG_DFU_SF=y CONFIG_DFU_MTD=y +CONFIG_SET_DFU_ALT_INFO=y CONFIG_SYS_DFU_DATA_BUF_SIZE=0x1800000 CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_FLASH=y -- 2.39.5