From ec217210f351c5c5089063f42eeb5e967a8ea5ba Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 24 Feb 2021 10:33:45 +0100 Subject: [PATCH 01/17] env: Setup default value for ENV_OFFSET_REDUND This variable is used for pointing to location where redundant variables are located. There is no default value. And it doesn't need to be specified which is showing as warning when savedefconfig is called. make xilinx_zynqmp_virt_defconfig # # configuration written to .config # make savedefconfig scripts/kconfig/conf --savedefconfig=defconfig Kconfig .config:199:warning: symbol value '' invalid for ENV_OFFSET_REDUND Signed-off-by: Michal Simek --- env/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/env/Kconfig b/env/Kconfig index 08e49c2a47..84e9fb1f8a 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -556,6 +556,7 @@ config ENV_OFFSET_REDUND hex "Redundant environment offset" depends on (ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \ ENV_IS_IN_SPI_FLASH) && SYS_REDUNDAND_ENVIRONMENT + default 0 help Offset from the start of the device (or partition) of the redundant environment location. From cd08513b051890e6e426d902570a07467b6d2318 Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Tue, 23 Feb 2021 08:07:45 -0700 Subject: [PATCH 02/17] xilinx: zynq: Add support for saving env based on bootmode Enable saving variables to MMC(FAT), NAND, SPI based on primary bootmode. If bootmode is JTAG, dont save env anywhere(NOWHERE). Since most of the flashes on zynq evaluation boards are 16MB in size, set default ENV_OFFSET to 15MB(0xE00000). Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- board/xilinx/zynq/board.c | 32 ++++++++++++++++++++++++++++++ configs/xilinx_zynq_virt_defconfig | 5 ++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c index 7533dddb9b..e2e9b3f0f7 100644 --- a/board/xilinx/zynq/board.c +++ b/board/xilinx/zynq/board.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -119,3 +120,34 @@ int dram_init(void) return 0; } #endif + +enum env_location env_get_location(enum env_operation op, int prio) +{ + u32 bootmode = zynq_slcr_get_boot_mode() & ZYNQ_BM_MASK; + + if (prio) + return ENVL_UNKNOWN; + + switch (bootmode) { + case ZYNQ_BM_SD: + if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT)) + return ENVL_FAT; + if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4)) + return ENVL_EXT4; + return ENVL_UNKNOWN; + case ZYNQ_BM_NAND: + if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND)) + return ENVL_NAND; + if (IS_ENABLED(CONFIG_ENV_IS_IN_UBI)) + return ENVL_UBI; + return ENVL_UNKNOWN; + case ZYNQ_BM_NOR: + case ZYNQ_BM_QSPI: + if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)) + return ENVL_SPI_FLASH; + return ENVL_UNKNOWN; + case ZYNQ_BM_JTAG: + default: + return ENVL_NOWHERE; + } +} diff --git a/configs/xilinx_zynq_virt_defconfig b/configs/xilinx_zynq_virt_defconfig index 2fe53182ca..bdd6be2b90 100644 --- a/configs/xilinx_zynq_virt_defconfig +++ b/configs/xilinx_zynq_virt_defconfig @@ -4,6 +4,7 @@ CONFIG_ARCH_ZYNQ=y CONFIG_SYS_TEXT_BASE=0x4000000 CONFIG_SYS_MEMTEST_START=0x00000000 CONFIG_SYS_MEMTEST_END=0x00001000 +CONFIG_ENV_OFFSET=0xE00000 CONFIG_SYS_SPI_U_BOOT_OFFS=0x100000 CONFIG_DM_GPIO=y CONFIG_SPL_STACK_R_ADDR=0x200000 @@ -55,7 +56,9 @@ CONFIG_CMD_MTDPARTS_SPREAD=y CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y CONFIG_CMD_UBI=y CONFIG_OF_LIST="zynq-zc702 zynq-zc706 zynq-zc770-xm010 zynq-zc770-xm011 zynq-zc770-xm011-x16 zynq-zc770-xm012 zynq-zc770-xm013 zynq-cc108 zynq-microzed zynq-minized zynq-picozed zynq-zed zynq-zturn zynq-zturn-v5 zynq-zybo zynq-zybo-z7 zynq-dlc20-rev1.0" -CONFIG_ENV_OVERWRITE=y +CONFIG_ENV_IS_NOWHERE=y +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_IS_IN_NAND=y CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NET_RANDOM_ETHADDR=y From 4fb83c9c2b2659b9493e271542c1c4568f97380c Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Tue, 23 Feb 2021 08:07:46 -0700 Subject: [PATCH 03/17] xilinx: versal: Add support for saving env based on bootmode Enable saving variables to MMC(FAT) and SPI based on primary bootmode. If bootmode is JTAG, dont save env anywhere(NOWHERE). Enable ENV_FAT_DEVICE_AND_PART="0:auto" for Versal platforms as well. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- board/xilinx/versal/board.c | 30 ++++++++++++++++++++++++++++ configs/xilinx_versal_virt_defconfig | 3 +++ env/Kconfig | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index e2f9d13c12..b17506453e 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -245,3 +246,32 @@ int dram_init(void) void reset_cpu(void) { } + +enum env_location env_get_location(enum env_operation op, int prio) +{ + u32 bootmode = versal_get_bootmode(); + + if (prio) + return ENVL_UNKNOWN; + + switch (bootmode) { + case EMMC_MODE: + case SD_MODE: + case SD1_LSHFT_MODE: + case SD_MODE1: + if (IS_ENABLED(CONFIG_ENV_IS_IN_FAT)) + return ENVL_FAT; + if (IS_ENABLED(CONFIG_ENV_IS_IN_EXT4)) + return ENVL_EXT4; + return ENVL_UNKNOWN; + case OSPI_MODE: + case QSPI_MODE_24BIT: + case QSPI_MODE_32BIT: + if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH)) + return ENVL_SPI_FLASH; + return ENVL_UNKNOWN; + case JTAG_MODE: + default: + return ENVL_NOWHERE; + } +} diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index 2d639a1026..fe108d3475 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -39,6 +39,9 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_MTDPARTS=y CONFIG_CMD_UBI=y CONFIG_OF_BOARD=y +CONFIG_ENV_IS_NOWHERE=y +CONFIG_ENV_IS_IN_FAT=y +CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y diff --git a/env/Kconfig b/env/Kconfig index 84e9fb1f8a..1b7906cf72 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -445,7 +445,7 @@ config ENV_FAT_DEVICE_AND_PART string "Device and partition for where to store the environemt in FAT" depends on ENV_IS_IN_FAT default "0:1" if TI_COMMON_CMD_OPTIONS - default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP + default "0:auto" if ARCH_ZYNQ || ARCH_ZYNQMP || ARCH_VERSAL default "0:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA = -1 default "1:auto" if ARCH_SUNXI && MMC_SUNXI_SLOT_EXTRA != -1 default "0" if ARCH_AT91 From 4274dc39478b2a28ce01d83233056a550a0f8a96 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 24 Feb 2021 10:44:20 +0100 Subject: [PATCH 04/17] xilinx: Enable redundant variable handling Enable this feature by default to be able to work with env import/export commands which are done in this slightly changed variable format (There is addtional flag fields in variable file which is changing CRC calculation). Signed-off-by: Michal Simek --- configs/microblaze-generic_defconfig | 1 + configs/xilinx_versal_virt_defconfig | 1 + configs/xilinx_zynq_virt_defconfig | 1 + configs/xilinx_zynqmp_virt_defconfig | 1 + 4 files changed, 4 insertions(+) diff --git a/configs/microblaze-generic_defconfig b/configs/microblaze-generic_defconfig index 761cc65cbf..245763b408 100644 --- a/configs/microblaze-generic_defconfig +++ b/configs/microblaze-generic_defconfig @@ -40,6 +40,7 @@ CONFIG_CMD_CACHE=y CONFIG_CMD_JFFS2=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_EMBED=y +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y CONFIG_SPL_DM=y diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index fe108d3475..da3d2c2a93 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -42,6 +42,7 @@ CONFIG_OF_BOARD=y CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y diff --git a/configs/xilinx_zynq_virt_defconfig b/configs/xilinx_zynq_virt_defconfig index bdd6be2b90..3892a71eac 100644 --- a/configs/xilinx_zynq_virt_defconfig +++ b/configs/xilinx_zynq_virt_defconfig @@ -60,6 +60,7 @@ CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y CONFIG_ENV_IS_IN_NAND=y CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig index fbff21590a..db7d3824d7 100644 --- a/configs/xilinx_zynqmp_virt_defconfig +++ b/configs/xilinx_zynqmp_virt_defconfig @@ -72,6 +72,7 @@ CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y CONFIG_ENV_IS_IN_NAND=y CONFIG_ENV_IS_IN_SPI_FLASH=y +CONFIG_SYS_REDUNDAND_ENVIRONMENT=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y From 74fe3f2ef3d66d1eaf4564467c9a34bfe3561d30 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 31 Mar 2021 09:05:52 +0200 Subject: [PATCH 05/17] cmd: dfu: Propagate error if dfu gadget fails On systems without usb gadget dfu core fails which was reported by error but command itself returns pass which breaks any usage in a script. That's why propagate error from run_usb_dnl_gadget(). Fixes: 16297cfb2a20 ("usb: new board-specific USB init interface") Signed-off-by: Michal Simek --- cmd/dfu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/dfu.c b/cmd/dfu.c index ef4f897ce0..4a288f74c2 100644 --- a/cmd/dfu.c +++ b/cmd/dfu.c @@ -68,7 +68,7 @@ static int do_dfu(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) int controller_index = simple_strtoul(usb_controller, NULL, 0); bool retry = false; do { - run_usb_dnl_gadget(controller_index, "usb_dnl_dfu"); + ret = run_usb_dnl_gadget(controller_index, "usb_dnl_dfu"); if (dfu_reinit_needed) { dfu_free_entities(); From ef1be3e3647e2c48610bfea5049d5e2b5c9bb813 Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Wed, 24 Mar 2021 23:37:57 -0600 Subject: [PATCH 06/17] xilinx: zynqmp: Add usb dfu/thor distro boot support In usb boot mode distro boot should select usb device as primary boot device instead of usb host. So make usb dfu as primary boot device. But do not list it in boot_targets as fallback option because it is not classic mode for booting. Using 60s timeout by default should be enough time for dfu-utils to start transaction. In case none needs this please change timeout value in the command or disable CONFIG_DFU_TIMEOUT. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- board/xilinx/zynqmp/zynqmp.c | 2 +- configs/xilinx_zynqmp_virt_defconfig | 1 + include/configs/xilinx_zynqmp.h | 30 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 23c12f45ea..d05f0b2e12 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -571,7 +571,7 @@ int board_late_init(void) switch (bootmode) { case USB_MODE: puts("USB_MODE\n"); - mode = "usb"; + mode = "usb_dfu0 usb_dfu1"; env_set("modeboot", "usb_dfu_spl"); break; case JTAG_MODE: diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig index db7d3824d7..810bbdb022 100644 --- a/configs/xilinx_zynqmp_virt_defconfig +++ b/configs/xilinx_zynqmp_virt_defconfig @@ -81,6 +81,7 @@ CONFIG_SCSI_AHCI=y CONFIG_SATA_CEVA=y CONFIG_CLK_ZYNQMP=y CONFIG_DFU_TFTP=y +CONFIG_DFU_TIMEOUT=y CONFIG_DFU_RAM=y CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_FLASH=y diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index 15ad4198a6..87704ff630 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -179,11 +179,41 @@ #define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \ "jtag " +#define BOOT_TARGET_DEVICES_USB_DFU(func) \ + func(USB_DFU, usb_dfu, 0) func(USB_DFU, usb_dfu, 1) + +#define BOOTENV_DEV_USB_DFU(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=setenv dfu_alt_info boot.scr ram " \ + "$scriptaddr $script_size_f && " \ + "dfu " #instance " ram " #instance " 60 && " \ + "echo DFU" #instance ": Trying to boot script at ${scriptaddr} && " \ + "source ${scriptaddr}; " \ + "echo DFU" #instance ": SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_USB_DFU(devtypeu, devtypel, instance) \ + "" + +#define BOOT_TARGET_DEVICES_USB_THOR(func) \ + func(USB_THOR, usb_thor, 0) func(USB_THOR, usb_thor, 1) + +#define BOOTENV_DEV_USB_THOR(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=setenv dfu_alt_info boot.scr ram " \ + "$scriptaddr $script_size_f && " \ + "thordown " #instance " ram " #instance " && " \ + "echo THOR" #instance ": Trying to boot script at ${scriptaddr} && " \ + "source ${scriptaddr}; " \ + "echo THOR" #instance ": SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_USB_THOR(devtypeu, devtypel, instance) \ + "" + #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_DEVICES_JTAG(func) \ BOOT_TARGET_DEVICES_MMC(func) \ BOOT_TARGET_DEVICES_QSPI(func) \ BOOT_TARGET_DEVICES_NAND(func) \ + BOOT_TARGET_DEVICES_USB_DFU(func) \ + BOOT_TARGET_DEVICES_USB_THOR(func) \ BOOT_TARGET_DEVICES_USB(func) \ BOOT_TARGET_DEVICES_SCSI(func) \ BOOT_TARGET_DEVICES_PXE(func) \ From 1e967b53a7fa7ba9a98cfc27af01eb373a1c202c Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 25 Mar 2021 09:55:30 +0100 Subject: [PATCH 07/17] xilinx: zynqmp: Remove dfu_ram_info setup The dfu ram info is wired in connection to Linux kernel and certain setup. We should change this to be more generic as others command. That's why using boot via script is the way to go. Signed-off-by: Michal Simek --- include/configs/xilinx_zynqmp.h | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index 87704ff630..36f3d962e4 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -55,18 +55,6 @@ #define CONFIG_SYS_DFU_DATA_BUF_SIZE 0x1800000 #define DFU_DEFAULT_POLL_TIMEOUT 300 #define CONFIG_THOR_RESET_OFF -#define DFU_ALT_INFO_RAM \ - "dfu_ram_info=" \ - "setenv dfu_alt_info " \ - "Image ram 80000 $kernel_size_r\\\\;" \ - "system.dtb ram $fdt_addr_r $fdt_size_r\0" \ - "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \ - "thor_ram=run dfu_ram_info && thordown 0 ram 0\0" \ - "dfu_ram_tftp=run dfu_ram_info && setenv updatefile boot && " \ - "setenv loadaddr 10000000 && dfu tftp ram 0\0" - -#define DFU_ALT_INFO \ - DFU_ALT_INFO_RAM #ifndef CONFIG_SPL_BUILD # define PARTS_DEFAULT \ @@ -76,10 +64,6 @@ #endif #endif -#if !defined(DFU_ALT_INFO) -# define DFU_ALT_INFO -#endif - #if !defined(PARTS_DEFAULT) # define PARTS_DEFAULT #endif @@ -225,8 +209,7 @@ #ifndef CONFIG_EXTRA_ENV_SETTINGS #define CONFIG_EXTRA_ENV_SETTINGS \ ENV_MEM_LAYOUT_SETTINGS \ - BOOTENV \ - DFU_ALT_INFO + BOOTENV #endif /* SPL can't handle all huge variables - define just DFU */ From 82cb49dc001f0e2141ef739087d51c3c7eb893c8 Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Tue, 30 Mar 2021 23:24:57 -0600 Subject: [PATCH 08/17] xilinx: versal: Add usb dfu/thor distro boot support Change "dfu_usb" to "usb_dfu" for better representation and change required macros. Add 60s timeout of dfu-utils to start transaction. Add support for usb thor to distro boot. Remove DFU_ALT_INFO_RAM as we use bootcmd_usb_dfu instead of dfu_ram. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- board/xilinx/versal/board.c | 2 +- include/configs/xilinx_versal.h | 52 +++++++++++++++++---------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c index b17506453e..6045eb2baa 100644 --- a/board/xilinx/versal/board.c +++ b/board/xilinx/versal/board.c @@ -130,7 +130,7 @@ int board_late_init(void) switch (bootmode) { case USB_MODE: puts("USB_MODE\n"); - mode = "dfu_usb"; + mode = "usb_dfu0 usb_dfu1"; break; case JTAG_MODE: puts("JTAG_MODE\n"); diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h index f1d2594f3b..380f93a2f6 100644 --- a/include/configs/xilinx_versal.h +++ b/include/configs/xilinx_versal.h @@ -50,20 +50,6 @@ #define CONFIG_SYS_DFU_DATA_BUF_SIZE 0x1800000 #define DFU_DEFAULT_POLL_TIMEOUT 300 #define CONFIG_THOR_RESET_OFF -#define DFU_ALT_INFO_RAM \ - "dfu_ram_info=" \ - "setenv dfu_alt_info " \ - "Image ram 80000 $kernel_size_r\\\\;" \ - "system.dtb ram $fdt_addr_r $fdt_size_r\0" \ - "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \ - "thor_ram=run dfu_ram_info && thordown 0 ram 0\0" - -#define DFU_ALT_INFO \ - DFU_ALT_INFO_RAM -#endif - -#if !defined(DFU_ALT_INFO) -# define DFU_ALT_INFO #endif /* Ethernet driver */ @@ -129,23 +115,40 @@ #define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \ "jtag " -#define BOOT_TARGET_DEVICES_DFU_USB(func) func(DFU_USB, dfu_usb, 0) +#define BOOT_TARGET_DEVICES_USB_DFU(func) \ + func(USB_DFU, usb_dfu, 0) func(USB_DFU, usb_dfu, 1) -#define BOOTENV_DEV_DFU_USB(devtypeu, devtypel, instance) \ - "bootcmd_dfu_usb=setenv dfu_alt_info boot.scr ram $scriptaddr " \ - "$script_size_f; dfu 0 ram 0 && " \ - "echo DFU: Trying to boot script at ${scriptaddr} && " \ +#define BOOTENV_DEV_USB_DFU(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=setenv dfu_alt_info boot.scr ram " \ + "$scriptaddr $script_size_f && " \ + "dfu " #instance " ram " #instance " 60 && " \ + "echo DFU" #instance ": Trying to boot script at ${scriptaddr} && " \ "source ${scriptaddr}; " \ - "echo DFU: SCRIPT FAILED: continuing...;\0" + "echo DFU" #instance ": SCRIPT FAILED: continuing...;\0" -#define BOOTENV_DEV_NAME_DFU_USB(devtypeu, devtypel, instance) \ - "dfu_usb " +#define BOOTENV_DEV_NAME_USB_DFU(devtypeu, devtypel, instance) \ + "" + +#define BOOT_TARGET_DEVICES_USB_THOR(func) \ + func(USB_THOR, usb_thor, 0) func(USB_THOR, usb_thor, 1) + +#define BOOTENV_DEV_USB_THOR(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=setenv dfu_alt_info boot.scr ram " \ + "$scriptaddr $script_size_f && " \ + "thordown " #instance " ram " #instance " && " \ + "echo THOR" #instance ": Trying to boot script at ${scriptaddr} && " \ + "source ${scriptaddr}; " \ + "echo THOR" #instance ": SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_USB_THOR(devtypeu, devtypel, instance) \ + "" #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_DEVICES_JTAG(func) \ BOOT_TARGET_DEVICES_MMC(func) \ BOOT_TARGET_DEVICES_XSPI(func) \ - BOOT_TARGET_DEVICES_DFU_USB(func) \ + BOOT_TARGET_DEVICES_USB_DFU(func) \ + BOOT_TARGET_DEVICES_USB_THOR(func) \ BOOT_TARGET_DEVICES_PXE(func) \ BOOT_TARGET_DEVICES_DHCP(func) @@ -155,8 +158,7 @@ #ifndef CONFIG_EXTRA_ENV_SETTINGS #define CONFIG_EXTRA_ENV_SETTINGS \ ENV_MEM_LAYOUT_SETTINGS \ - BOOTENV \ - DFU_ALT_INFO + BOOTENV #endif #endif /* __XILINX_VERSAL_H */ From b8126ab2bc6fe3beb2bedcfac9770022cb4f246a Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Tue, 30 Mar 2021 23:24:58 -0600 Subject: [PATCH 09/17] xilinx: zynq: Add usb dfu/thor distro boot support Add support for usb dfu & thor to distro boot on zynq platform. Add 60s timeout of dfu-utils to start transaction. Remove DFU_ALT_INFO_RAM as we use bootcmd_usb_dfu instead of dfu_ram. Remove DFU_ALT_INFO_MMC as part of distro boot cleanup. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- include/configs/syzygy_hub.h | 1 - include/configs/topic_miami.h | 1 - include/configs/zynq-common.h | 61 +++++++++++++++++------------------ 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/include/configs/syzygy_hub.h b/include/configs/syzygy_hub.h index e31b77c0c0..7af7b08eb4 100644 --- a/include/configs/syzygy_hub.h +++ b/include/configs/syzygy_hub.h @@ -58,7 +58,6 @@ "jtagboot=echo TFTPing FIT to RAM... && " \ "tftpboot ${load_addr} ${fit_image} && " \ "bootm ${load_addr}\0" \ - DFU_ALT_INFO \ BOOTENV #include diff --git a/include/configs/topic_miami.h b/include/configs/topic_miami.h index 010d28ac86..c12cd7ccad 100644 --- a/include/configs/topic_miami.h +++ b/include/configs/topic_miami.h @@ -49,7 +49,6 @@ "${devicetree_addr}; " \ "fi\0" /* Note that addresses here should match the addresses in the env */ -# undef DFU_ALT_INFO # define DFU_ALT_INFO \ "dfu_alt_info=" \ "uImage ram 0x2080000 0x500000;" \ diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 1607a8d065..39035f8beb 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -61,36 +61,6 @@ # define CONFIG_SYS_DFU_DATA_BUF_SIZE 0x600000 # define DFU_DEFAULT_POLL_TIMEOUT 300 # define CONFIG_THOR_RESET_OFF -# define DFU_ALT_INFO_RAM \ - "dfu_ram_info=" \ - "setenv dfu_alt_info " \ - "${kernel_image} ram 0x3000000 0x500000\\\\;" \ - "${devicetree_image} ram 0x2A00000 0x20000\\\\;" \ - "${ramdisk_image} ram 0x2000000 0x600000\0" \ - "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \ - "thor_ram=run dfu_ram_info && thordown 0 ram 0\0" - -# if defined(CONFIG_MMC_SDHCI_ZYNQ) -# define DFU_ALT_INFO_MMC \ - "dfu_mmc_info=" \ - "setenv dfu_alt_info " \ - "${kernel_image} fat 0 1\\\\;" \ - "${devicetree_image} fat 0 1\\\\;" \ - "${ramdisk_image} fat 0 1\0" \ - "dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0\0" \ - "thor_mmc=run dfu_mmc_info && thordown 0 mmc 0\0" - -# define DFU_ALT_INFO \ - DFU_ALT_INFO_RAM \ - DFU_ALT_INFO_MMC -# else -# define DFU_ALT_INFO \ - DFU_ALT_INFO_RAM -# endif -#endif - -#if !defined(DFU_ALT_INFO) -# define DFU_ALT_INFO #endif /* enable preboot to be loaded before CONFIG_BOOTDELAY */ @@ -180,12 +150,42 @@ #define BOOTENV_DEV_NAME_JTAG(devtypeu, devtypel, instance) \ "jtag " +#define BOOT_TARGET_DEVICES_USB_DFU(func) \ + func(USB_DFU, usb_dfu, 0) func(USB_DFU, usb_dfu, 1) + +#define BOOTENV_DEV_USB_DFU(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=setenv dfu_alt_info boot.scr ram " \ + "$scriptaddr $script_size_f && " \ + "dfu " #instance " ram " #instance " 60 && " \ + "echo DFU" #instance ": Trying to boot script at ${scriptaddr} && " \ + "source ${scriptaddr}; " \ + "echo DFU" #instance ": SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_USB_DFU(devtypeu, devtypel, instance) \ + "" + +#define BOOT_TARGET_DEVICES_USB_THOR(func) \ + func(USB_THOR, usb_thor, 0) func(USB_THOR, usb_thor, 1) + +#define BOOTENV_DEV_USB_THOR(devtypeu, devtypel, instance) \ + "bootcmd_" #devtypel #instance "=setenv dfu_alt_info boot.scr ram " \ + "$scriptaddr $script_size_f && " \ + "thordown " #instance " ram " #instance " && " \ + "echo THOR" #instance ": Trying to boot script at ${scriptaddr} && " \ + "source ${scriptaddr}; " \ + "echo THOR" #instance ": SCRIPT FAILED: continuing...;\0" + +#define BOOTENV_DEV_NAME_USB_THOR(devtypeu, devtypel, instance) \ + "" + #define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_DEVICES_JTAG(func) \ BOOT_TARGET_DEVICES_MMC(func) \ BOOT_TARGET_DEVICES_QSPI(func) \ BOOT_TARGET_DEVICES_NAND(func) \ BOOT_TARGET_DEVICES_NOR(func) \ + BOOT_TARGET_DEVICES_USB_DFU(func) \ + BOOT_TARGET_DEVICES_USB_THOR(func) \ BOOT_TARGET_DEVICES_USB(func) \ BOOT_TARGET_DEVICES_PXE(func) \ BOOT_TARGET_DEVICES_DHCP(func) @@ -203,7 +203,6 @@ "kernel_addr_r=0x2000000\0" \ "scriptaddr=0x3000000\0" \ "ramdisk_addr_r=0x3100000\0" \ - DFU_ALT_INFO \ BOOTENV #endif From 84e7cc9126714e278912ca2e72e1816c364babdd Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Tue, 30 Mar 2021 23:24:59 -0600 Subject: [PATCH 10/17] xilinx: Enable DFU_TIMEOUT config Enable CONFIG_DFU_TIMEOUT to set timeout waiting for dfu command. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek --- configs/xilinx_versal_virt_defconfig | 1 + configs/xilinx_zynq_virt_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index da3d2c2a93..03c81e6c27 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -49,6 +49,7 @@ CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y CONFIG_TFTP_BLOCKSIZE=4096 CONFIG_CLK_VERSAL=y +CONFIG_DFU_TIMEOUT=y CONFIG_DFU_RAM=y CONFIG_FPGA_XILINX=y CONFIG_FPGA_VERSALPL=y diff --git a/configs/xilinx_zynq_virt_defconfig b/configs/xilinx_zynq_virt_defconfig index 3892a71eac..7e56395a52 100644 --- a/configs/xilinx_zynq_virt_defconfig +++ b/configs/xilinx_zynq_virt_defconfig @@ -65,6 +65,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_NETCONSOLE=y CONFIG_SPL_DM_SEQ_ALIAS=y +CONFIG_DFU_TIMEOUT=y CONFIG_DFU_MMC=y CONFIG_DFU_RAM=y CONFIG_FPGA_XILINX=y From 25484d907039148807e9b1c4924c816f59a13929 Mon Sep 17 00:00:00 2001 From: T Karthik Reddy Date: Fri, 2 Apr 2021 01:49:17 -0600 Subject: [PATCH 11/17] xilinx: common: Fix boot script address Currently u-boot supports addresses upto 39-bits only. If anybody wants to use addresses of more than 39-bits in Linux they will have a separate memory node in DT. In such cases they will have multiple memory nodes. Currently u-boot selects and runs on lower memory bank region. But bootscript is being loaded on dram bank 0, where dram bank 0 will point to 1st memory node in DT. If first memory node is mentioned as higher ddr(>39-bits address) then u-boot cannot load the bootscript. So fix this issue by setting bootscript address within the lower memory bank region. Signed-off-by: T Karthik Reddy Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek --- board/xilinx/common/board.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 475628b925..92b61d83ca 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -378,14 +378,12 @@ int board_late_init_xilinx(void) int i, id, macid = 0; struct xilinx_board_description *desc; phys_size_t bootm_size = gd->ram_size; - struct bd_info *bd = gd->bd; - if (!CONFIG_IS_ENABLED(MICROBLAZE) && bd->bi_dram[0].start) { + if (!CONFIG_IS_ENABLED(MICROBLAZE)) { ulong scriptaddr; scriptaddr = env_get_hex("scriptaddr", 0); - ret |= env_set_hex("scriptaddr", - bd->bi_dram[0].start + scriptaddr); + ret |= env_set_hex("scriptaddr", gd->ram_base + scriptaddr); } if (CONFIG_IS_ENABLED(ARCH_ZYNQ) || CONFIG_IS_ENABLED(MICROBLAZE)) From 84befd408c1e3ad2d7b410adaf58fe4d397cb7b6 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 1 Apr 2021 12:35:42 +0200 Subject: [PATCH 12/17] xilinx: Enable GUID partitions and EFI variable commands For work with EFI it is good to have GUID partitions enabled and also option to work with UEFI variables. That's why enable both. Signed-off-by: Michal Simek --- configs/xilinx_versal_virt_defconfig | 2 ++ configs/xilinx_zynqmp_virt_defconfig | 3 +++ 2 files changed, 5 insertions(+) diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index 03c81e6c27..707693713a 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -18,6 +18,7 @@ CONFIG_USE_PREBOOT=y CONFIG_BOARD_EARLY_INIT_R=y CONFIG_SYS_PROMPT="Versal> " CONFIG_CMD_BOOTMENU=y +CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_MEMTEST=y CONFIG_SYS_ALT_MEMTEST=y CONFIG_CMD_CLK=y @@ -38,6 +39,7 @@ CONFIG_CMD_TIMER=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_MTDPARTS=y CONFIG_CMD_UBI=y +CONFIG_PARTITION_TYPE_GUID=y CONFIG_OF_BOARD=y CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_FAT=y diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig index 810bbdb022..c94e6b3e2b 100644 --- a/configs/xilinx_zynqmp_virt_defconfig +++ b/configs/xilinx_zynqmp_virt_defconfig @@ -33,6 +33,7 @@ CONFIG_SPL_ATF=y CONFIG_SPL_ATF_NO_PLATFORM_PARAM=y CONFIG_CMD_BOOTMENU=y CONFIG_CMD_THOR_DOWNLOAD=y +CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_MEMTEST=y CONFIG_SYS_ALT_MEMTEST=y CONFIG_CMD_BIND=y @@ -65,6 +66,7 @@ CONFIG_CMD_MTDPARTS=y CONFIG_CMD_MTDPARTS_SPREAD=y CONFIG_CMD_MTDPARTS_SHOW_NET_SIZES=y CONFIG_CMD_UBI=y +CONFIG_PARTITION_TYPE_GUID=y CONFIG_SPL_OF_CONTROL=y CONFIG_OF_LIST="avnet-ultra96-rev1 zynqmp-a2197-revA zynqmp-e-a2197-00-revA zynqmp-g-a2197-00-revA zynqmp-m-a2197-01-revA zynqmp-m-a2197-02-revA zynqmp-m-a2197-03-revA zynqmp-p-a2197-00-revA zynqmp-zc1232-revA zynqmp-zc1254-revA zynqmp-zc1751-xm015-dc1 zynqmp-zc1751-xm016-dc2 zynqmp-zc1751-xm017-dc3 zynqmp-zc1751-xm018-dc4 zynqmp-zc1751-xm019-dc5 zynqmp-zcu100-revC zynqmp-zcu102-rev1.1 zynqmp-zcu102-rev1.0 zynqmp-zcu102-revA zynqmp-zcu102-revB zynqmp-zcu104-revA zynqmp-zcu104-revC zynqmp-zcu106-revA zynqmp-zcu111-revA zynqmp-zcu1275-revA zynqmp-zcu1275-revB zynqmp-zcu1285-revA zynqmp-zcu208-revA zynqmp-zcu216-revA zynqmp-topic-miamimp-xilinx-xdp-v1r1" CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names interrupt-parent interrupts iommus power-domains" @@ -173,4 +175,5 @@ CONFIG_WDT_CDNS=y CONFIG_PANIC_HANG=y CONFIG_TPM=y CONFIG_SPL_GZIP=y +# CONFIG_SPL_HEXDUMP is not set CONFIG_OF_LIBFDT_OVERLAY=y From cd9aafc0ea16e483f881c1547c82630a9c6803b6 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 7 Apr 2021 14:36:14 +0200 Subject: [PATCH 13/17] clk: Fix typo in Zynq Kconfig symbol description Trivial typo fix. Signed-off-by: Michal Simek --- drivers/clk/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig index 4aeaa0cd58..40a5a5dd88 100644 --- a/drivers/clk/Kconfig +++ b/drivers/clk/Kconfig @@ -125,7 +125,7 @@ config CLK_ZYNQ depends on CLK && ARCH_ZYNQ default y help - This clock driver adds support for clock realted settings for + This clock driver adds support for clock related settings for Zynq platform. config CLK_ZYNQMP From e59d575d3efd86eccb483f5261d341164a7e31ec Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 15 Apr 2021 09:14:16 +0200 Subject: [PATCH 14/17] arm64: versal: Remove gd reference gd is not used in this file that's why doesn't make sense to declare it. Signed-off-by: Michal Simek --- arch/arm/mach-versal/mp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/arm/mach-versal/mp.c b/arch/arm/mach-versal/mp.c index c97c311d31..9b0518d6a2 100644 --- a/arch/arm/mach-versal/mp.c +++ b/arch/arm/mach-versal/mp.c @@ -5,13 +5,10 @@ */ #include -#include #include #include #include -DECLARE_GLOBAL_DATA_PTR; - #define HALT 0 #define RELEASE 1 From 0b0705b5ed7865a1c86a3ed6ece82346e5f2e57f Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 26 Apr 2021 08:27:04 +0200 Subject: [PATCH 15/17] arm64: zynqmp: Enable capsule update Enable EFI capsule update features to be enabled by default also with all dfu valid options for ZynqMP. This feature was tested on Xilinx ZynqMP zcu104 board with defining dfu_alt_info="mmc 0:1=boot.bin fat 0 1;u-boot.itb fat 0 1" and dfu_alt_info="sf 0:0=boot.bin raw 0 0x50000;u-boot.itb raw 0x80000 0x500000". There is a need to increase malloc size for getting dfu mmc to work. Signed-off-by: Michal Simek CC: Sughosh Ganu CC: Ilias Apalodimas CC: Heinrich Schuchardt --- configs/xilinx_zynqmp_virt_defconfig | 9 +++++++++ include/configs/xilinx_zynqmp.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig index c94e6b3e2b..9414b26706 100644 --- a/configs/xilinx_zynqmp_virt_defconfig +++ b/configs/xilinx_zynqmp_virt_defconfig @@ -84,7 +84,11 @@ CONFIG_SATA_CEVA=y CONFIG_CLK_ZYNQMP=y CONFIG_DFU_TFTP=y CONFIG_DFU_TIMEOUT=y +CONFIG_DFU_MMC=y +CONFIG_DFU_NAND=y CONFIG_DFU_RAM=y +CONFIG_DFU_SF=y +CONFIG_DFU_MTD=y CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_FLASH=y CONFIG_FASTBOOT_FLASH_MMC_DEV=0 @@ -177,3 +181,8 @@ CONFIG_TPM=y CONFIG_SPL_GZIP=y # CONFIG_SPL_HEXDUMP is not set CONFIG_OF_LIBFDT_OVERLAY=y +CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_ON_DISK_EARLY=y +CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index 36f3d962e4..986af2be78 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -27,7 +27,7 @@ #endif /* Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 0x2000000) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 0x4000000) /* Serial setup */ #define CONFIG_CPU_ARMV8 From 0a9f0e0d00e0e8b2c5b6a2ae844c5ebca684616f Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 26 Apr 2021 14:26:48 +0200 Subject: [PATCH 16/17] net: phy: xilinx: Break while loop over ethernet phy The commit 6c993815bbea ("net: phy: xilinx: Be compatible with live OF tree") change driver behavior to while loop which wasn't correct because the driver was looping over again and again. The reason was that ofnode_valid() is taking 0 as correct value. Fix it by changing while loop to ofnode_for_each_subnode() which is only loop over available nodes. Fixes: 6c993815bbea ("net: phy: xilinx: Be compatible with live OF tree") Signed-off-by: Michal Simek Reviewed-by: Bin Meng --- drivers/net/phy/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index dcdef9e661..ed197fa46d 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -948,9 +948,9 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus, phy_interface_t interface) { struct phy_device *phydev = NULL; - ofnode node = dev_ofnode(dev); + ofnode node; - while (ofnode_valid(node)) { + ofnode_for_each_subnode(node, dev_ofnode(dev)) { node = ofnode_by_compatible(node, "xlnx,gmii-to-rgmii-1.0"); if (ofnode_valid(node)) { phydev = phy_device_create(bus, 0, From b00bad9dc81ee0337761cc50443dffa22a6cdedf Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 26 Apr 2021 08:26:33 +0200 Subject: [PATCH 17/17] spi: zynqmp: Remove gd reference gd is not used in this file that's why doesn't make sense to declare it. Signed-off-by: Michal Simek --- drivers/spi/zynqmp_gqspi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/spi/zynqmp_gqspi.c b/drivers/spi/zynqmp_gqspi.c index f8d13d193e..17780066ae 100644 --- a/drivers/spi/zynqmp_gqspi.c +++ b/drivers/spi/zynqmp_gqspi.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -156,8 +155,6 @@ struct zynqmp_qspi_dma_regs { u32 dmadstmsb; /* 0x28 */ }; -DECLARE_GLOBAL_DATA_PTR; - struct zynqmp_qspi_plat { struct zynqmp_qspi_regs *regs; struct zynqmp_qspi_dma_regs *dma_regs;