Generate dfu_alt_info setup at runtime for capsule update.
Enabling this feature will help with upgrading boards without remembering
what is where.

The similar change was done for ZynqMP by commit b86f43de0be0 ("xilinx:
zynqmp: Add support for runtime dfu_alt_info setup").
Code needs to be enabled by CONFIG_SET_DFU_ALT_INFO.

And also enable capsule on disk for RAW firmware images with efidebug
command.

Two indexes are supported for SPL flow. Images can be generated like:
./tools/mkeficapsule --raw spl/boot.bin --index 1 capsule1.bin
./tools/mkeficapsule --raw u-boot.img --index 2 capsule2.bin

Then place them to SD card and load them:
load mmc 0 10000000 capsule1.bin && efidebug capsule update -v 10000000
load mmc 0 10000000 capsule2.bin && efidebug capsule update -v 10000000

FSBL flow will also work where only index 1 capsule is used. There
should be enough space for using boot.bin with bitstream too.

Zynq also support multiple boot locations in SPI or MMC but it is not wired
by this patch.

Signed-off-by: Michal Simek <michal.si...@xilinx.com>
---

 board/xilinx/zynq/board.c          | 35 ++++++++++++++++++++++++++++++
 configs/xilinx_zynq_virt_defconfig |  6 +++++
 2 files changed, 41 insertions(+)

diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index 61e0a90c119b..1111ad6fca9c 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -13,6 +13,7 @@
 #include <fdtdec.h>
 #include <fpga.h>
 #include <malloc.h>
+#include <memalign.h>
 #include <mmc.h>
 #include <watchdog.h>
 #include <wdt.h>
@@ -151,3 +152,37 @@ 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)
+{
+       ALLOC_CACHE_ALIGN_BUFFER(char, buf, DFU_ALT_BUF_LEN);
+
+       if (env_get("dfu_alt_info"))
+               return;
+
+       memset(buf, 0, sizeof(buf));
+
+       switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
+       case ZYNQ_BM_SD:
+               snprintf(buf, DFU_ALT_BUF_LEN,
+                        "mmc 0:1=boot.bin fat 0 1;"
+                        "u-boot.img fat 0 1");
+               break;
+       case ZYNQ_BM_QSPI:
+               snprintf(buf, DFU_ALT_BUF_LEN,
+                        "sf 0:0=boot.bin raw 0 0x1500000;"
+                        "u-boot.img raw 0x%x 0x500000",
+                        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_zynq_virt_defconfig 
b/configs/xilinx_zynq_virt_defconfig
index 573a10fe221b..09ee066fdce2 100644
--- a/configs/xilinx_zynq_virt_defconfig
+++ b/configs/xilinx_zynq_virt_defconfig
@@ -49,6 +49,7 @@ CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_CMD_TFTPPUT=y
 CONFIG_CMD_CACHE=y
+CONFIG_CMD_EFIDEBUG=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_TIMER=y
 CONFIG_CMD_EXT4_WRITE=y
@@ -69,6 +70,8 @@ CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_DFU_TIMEOUT=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_RAM=y
+CONFIG_DFU_SF=y
+CONFIG_SET_DFU_ALT_INFO=y
 CONFIG_SYS_DFU_DATA_BUF_SIZE=0x600000
 CONFIG_FPGA_XILINX=y
 CONFIG_FPGA_ZYNQPL=y
@@ -123,3 +126,6 @@ CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_USB_FUNCTION_THOR=y
 CONFIG_DISPLAY=y
 CONFIG_SPL_GZIP=y
+CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
+CONFIG_EFI_CAPSULE_ON_DISK=y
+CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y
-- 
2.33.0

Reply via email to