All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime
@ 2021-07-29  9:39 Michal Simek
  2021-07-29  9:39 ` [PATCH v2 1/4] xilinx: zynqmp: Change multi_boot() to return value Michal Simek
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Michal Simek @ 2021-07-29  9:39 UTC (permalink / raw)
  To: u-boot, git
  Cc: Ashok Reddy Soma, Ibai Erkiaga, Ilias Apalodimas, Michal Simek,
	Simon Glass, T Karthik Reddy

Hi,

this series is just for composing dfu_alt_info string for capsule update to
work automatically based on current setup.
QSPI/MMC FAT bootmodes are handled and supported. Other bootmodes are
ignored for now.

Thanks,
Michal

Changes in v2:
- no need to free local buf variable

Michal Simek (4):
  xilinx: zynqmp: Change multi_boot() to return value
  xilinx: zynqmp: use zynqmp_mmio_read() in multi_boot()
  xilinx: zynqmp: Config non zero SYS_SPI_U_BOOT_OFFS
  xilinx: zynqmp: Add support for runtime dfu_alt_info setup

 board/xilinx/zynqmp/zynqmp.c         | 67 +++++++++++++++++++++++++---
 configs/xilinx_zynqmp_virt_defconfig |  2 +
 2 files changed, 63 insertions(+), 6 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/4] xilinx: zynqmp: Change multi_boot() to return value
  2021-07-29  9:39 [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
@ 2021-07-29  9:39 ` Michal Simek
  2021-07-29  9:39 ` [PATCH v2 2/4] xilinx: zynqmp: use zynqmp_mmio_read() in multi_boot() Michal Simek
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2021-07-29  9:39 UTC (permalink / raw)
  To: u-boot, git; +Cc: Ibai Erkiaga, Michal Simek, Simon Glass, T Karthik Reddy

Change multi_boot() to return multiboot value and move print out of this
function and let this function to be used by other functions without
duplicating message.

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

Changes in v2: None

 board/xilinx/zynqmp/zynqmp.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index 2cb97f42bec3..eb67116d5b44 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -350,9 +350,7 @@ static int multi_boot(void)
 
 	multiboot = readl(&csu_base->multi_boot);
 
-	printf("Multiboot:\t%d\n", multiboot);
-
-	return 0;
+	return multiboot;
 }
 
 #define PS_SYSMON_ANALOG_BUS_VAL	0x3210
@@ -392,7 +390,7 @@ int board_init(void)
 #endif
 
 	if (current_el() == 3)
-		multi_boot();
+		printf("Multiboot:\t%d\n", multi_boot());
 
 	return 0;
 }
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] xilinx: zynqmp: use zynqmp_mmio_read() in multi_boot()
  2021-07-29  9:39 [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
  2021-07-29  9:39 ` [PATCH v2 1/4] xilinx: zynqmp: Change multi_boot() to return value Michal Simek
@ 2021-07-29  9:39 ` Michal Simek
  2021-07-29  9:39 ` [PATCH v2 3/4] xilinx: zynqmp: Config non zero SYS_SPI_U_BOOT_OFFS Michal Simek
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2021-07-29  9:39 UTC (permalink / raw)
  To: u-boot, git; +Cc: Ibai Erkiaga, Michal Simek, Simon Glass, T Karthik Reddy

When U-Boot runs in EL2 there is no access to csu_base registers that's why
this has to be done via firmware interface to find out multi boot register
value. Till now this function is called only from SPL in EL3.

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

Changes in v2: None

 board/xilinx/zynqmp/zynqmp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index eb67116d5b44..1b0356c84c5c 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -346,9 +346,12 @@ int board_early_init_f(void)
 
 static int multi_boot(void)
 {
-	u32 multiboot;
+	u32 multiboot = 0;
+	int ret;
 
-	multiboot = readl(&csu_base->multi_boot);
+	ret = zynqmp_mmio_read((ulong)&csu_base->multi_boot, &multiboot);
+	if (ret)
+		return -EINVAL;
 
 	return multiboot;
 }
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] xilinx: zynqmp: Config non zero SYS_SPI_U_BOOT_OFFS
  2021-07-29  9:39 [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
  2021-07-29  9:39 ` [PATCH v2 1/4] xilinx: zynqmp: Change multi_boot() to return value Michal Simek
  2021-07-29  9:39 ` [PATCH v2 2/4] xilinx: zynqmp: use zynqmp_mmio_read() in multi_boot() Michal Simek
@ 2021-07-29  9:39 ` Michal Simek
  2021-07-29  9:39 ` [PATCH v2 4/4] xilinx: zynqmp: Add support for runtime dfu_alt_info setup Michal Simek
  2021-08-06  7:26 ` [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2021-07-29  9:39 UTC (permalink / raw)
  To: u-boot, git
  Cc: Ashok Reddy Soma, Ilias Apalodimas, Michal Simek, T Karthik Reddy

This variable is pointing to offset is qspi where u-boot image is placed.
In our case it is location of u-boot.itb file. Offset is the same as is
used by Xilinx Zynq SoC.

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

Changes in v2: None

 configs/xilinx_zynqmp_virt_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/xilinx_zynqmp_virt_defconfig b/configs/xilinx_zynqmp_virt_defconfig
index bac1e181d265..095260403d95 100644
--- a/configs/xilinx_zynqmp_virt_defconfig
+++ b/configs/xilinx_zynqmp_virt_defconfig
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x8000000
 CONFIG_SYS_MALLOC_F_LEN=0x8000
 CONFIG_SYS_MEMTEST_START=0x00000000
 CONFIG_SYS_MEMTEST_END=0x00001000
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x100000
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="zynqmp-zcu100-revC"
 CONFIG_SPL=y
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] xilinx: zynqmp: Add support for runtime dfu_alt_info setup
  2021-07-29  9:39 [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
                   ` (2 preceding siblings ...)
  2021-07-29  9:39 ` [PATCH v2 3/4] xilinx: zynqmp: Config non zero SYS_SPI_U_BOOT_OFFS Michal Simek
@ 2021-07-29  9:39 ` Michal Simek
  2021-08-06  7:26 ` [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2021-07-29  9:39 UTC (permalink / raw)
  To: u-boot, git
  Cc: Ashok Reddy Soma, Ibai Erkiaga, Ilias Apalodimas, Michal Simek,
	Simon Glass, T Karthik Reddy

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 <michal.simek@xilinx.com>
---

Changes in v2:
- no need to free local buf variable

 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 1b0356c84c5c..27bb2b056c58 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -8,6 +8,7 @@
 #include <command.h>
 #include <cpu_func.h>
 #include <debug_uart.h>
+#include <dfu.h>
 #include <env.h>
 #include <env_internal.h>
 #include <init.h>
@@ -19,6 +20,7 @@
 #include <ahci.h>
 #include <scsi.h>
 #include <malloc.h>
+#include <memalign.h>
 #include <wdt.h>
 #include <asm/arch/clk.h>
 #include <asm/arch/hardware.h>
@@ -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 095260403d95..2b80292fb687 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.32.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime
  2021-07-29  9:39 [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
                   ` (3 preceding siblings ...)
  2021-07-29  9:39 ` [PATCH v2 4/4] xilinx: zynqmp: Add support for runtime dfu_alt_info setup Michal Simek
@ 2021-08-06  7:26 ` Michal Simek
  4 siblings, 0 replies; 6+ messages in thread
From: Michal Simek @ 2021-08-06  7:26 UTC (permalink / raw)
  To: U-Boot, git
  Cc: Ashok Reddy Soma, Ibai Erkiaga, Ilias Apalodimas, Simon Glass,
	T Karthik Reddy

čt 29. 7. 2021 v 11:39 odesílatel Michal Simek <michal.simek@xilinx.com> napsal:
>
> Hi,
>
> this series is just for composing dfu_alt_info string for capsule update to
> work automatically based on current setup.
> QSPI/MMC FAT bootmodes are handled and supported. Other bootmodes are
> ignored for now.
>
> Thanks,
> Michal
>
> Changes in v2:
> - no need to free local buf variable
>
> Michal Simek (4):
>   xilinx: zynqmp: Change multi_boot() to return value
>   xilinx: zynqmp: use zynqmp_mmio_read() in multi_boot()
>   xilinx: zynqmp: Config non zero SYS_SPI_U_BOOT_OFFS
>   xilinx: zynqmp: Add support for runtime dfu_alt_info setup
>
>  board/xilinx/zynqmp/zynqmp.c         | 67 +++++++++++++++++++++++++---
>  configs/xilinx_zynqmp_virt_defconfig |  2 +
>  2 files changed, 63 insertions(+), 6 deletions(-)
>
> --
> 2.32.0
>

Applied.
M

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-06  7:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29  9:39 [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek
2021-07-29  9:39 ` [PATCH v2 1/4] xilinx: zynqmp: Change multi_boot() to return value Michal Simek
2021-07-29  9:39 ` [PATCH v2 2/4] xilinx: zynqmp: use zynqmp_mmio_read() in multi_boot() Michal Simek
2021-07-29  9:39 ` [PATCH v2 3/4] xilinx: zynqmp: Config non zero SYS_SPI_U_BOOT_OFFS Michal Simek
2021-07-29  9:39 ` [PATCH v2 4/4] xilinx: zynqmp: Add support for runtime dfu_alt_info setup Michal Simek
2021-08-06  7:26 ` [PATCH v2 0/4] xilinx: zynqmp: Add support for dfu_alt_info setup at runtime Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.