[PATCH v2 1/2] arm64: zynqmp: Generate desc when SPL_FS_LOAD_PAYLOAD_NAME is valid

Generate description only when CONFIG_SPL_FS_LOAD_PAYLOAD_NAME is not empty. When name is empty there is no reason to generate description for it because it is not aligned with dfu rules.
Signed-off-by: Michal Simek michal.simek@amd.com ---
Changes in v2: - New patch is series coming from discussion at https://lore.kernel.org/all/561f9d0ee96ebb6cd674042f269f280ab68fbbac.1708705...
board/xilinx/zynqmp/zynqmp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index ba49eb7be229..3844a9c9a8ff 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -661,8 +661,11 @@ void set_dfu_alt_info(char *interface, char *devstr) len += snprintf(buf + len, DFU_ALT_BUF_LEN, ".bin fat %d 1", bootseq); #if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) - len += snprintf(buf + len, DFU_ALT_BUF_LEN, ";%s fat %d 1", - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq); + if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + ";%s fat %d 1", + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + bootseq); #endif break; case QSPI_MODE_24BIT: @@ -671,10 +674,12 @@ void set_dfu_alt_info(char *interface, char *devstr) "sf 0:0=boot.bin raw %x 0x1500000", multiboot * SZ_32K); #if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS) - len += snprintf(buf + len, DFU_ALT_BUF_LEN, - ";%s raw 0x%x 0x500000", - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, - multiboot * SZ_32K + CONFIG_SYS_SPI_U_BOOT_OFFS); + if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + ";%s raw 0x%x 0x500000", + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + multiboot * SZ_32K + + CONFIG_SYS_SPI_U_BOOT_OFFS); #endif break; default:

Generate dfu_alt_info generation based on information from MTD partitions. mtd_found_part() is trying to identify MTD partition which code is running from. If partitions are not defined and location is not found it is going to previous behavior.
Signed-off-by: Michal Simek michal.simek@amd.com ---
Changes in v2: - Update logic based on 1/2 patch
board/xilinx/zynqmp/zynqmp.c | 55 ++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-)
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 3844a9c9a8ff..2522024b4082 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -626,6 +626,31 @@ enum env_location env_get_location(enum env_operation op, int prio)
#define DFU_ALT_BUF_LEN SZ_1K
+static void mtd_found_part(u32 *base, u32 *size) +{ + struct mtd_info *part, *mtd; + + mtd_probe_devices(); + + mtd = get_mtd_device_nm("nor0"); + if (!IS_ERR_OR_NULL(mtd)) { + list_for_each_entry(part, &mtd->partitions, node) { + debug("0x%012llx-0x%012llx : "%s"\n", + part->offset, part->offset + part->size, + part->name); + + if (*base >= part->offset && + *base < part->offset + part->size) { + debug("Found my partition: %d/%s\n", + part->index, part->name); + *base = part->offset; + *size = part->size; + break; + } + } + } +} + void set_dfu_alt_info(char *interface, char *devstr) { int multiboot, bootseq = 0, len = 0; @@ -670,17 +695,29 @@ void set_dfu_alt_info(char *interface, char *devstr) break; case QSPI_MODE_24BIT: case QSPI_MODE_32BIT: - len += snprintf(buf + len, DFU_ALT_BUF_LEN, - "sf 0:0=boot.bin raw %x 0x1500000", - multiboot * SZ_32K); -#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS) - if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + { + u32 base = multiboot * SZ_32K; + u32 size = 0x1500000; + u32 limit = size; + + mtd_found_part(&base, &limit); + +#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS) + size = limit; + limit = CONFIG_SYS_SPI_U_BOOT_OFFS; +#endif + len += snprintf(buf + len, DFU_ALT_BUF_LEN, - ";%s raw 0x%x 0x500000", - CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, - multiboot * SZ_32K + - CONFIG_SYS_SPI_U_BOOT_OFFS); + "sf 0:0=boot.bin raw 0x%x 0x%x", + base, limit); +#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS) + if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)) + len += snprintf(buf + len, DFU_ALT_BUF_LEN, + ";%s raw 0x%x 0x%x", + CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, + base + limit, size - limit); #endif + } break; default: return;

On 3/22/24 13:09, Michal Simek wrote:
Generate dfu_alt_info generation based on information from MTD partitions. mtd_found_part() is trying to identify MTD partition which code is running from. If partitions are not defined and location is not found it is going to previous behavior.
Signed-off-by: Michal Simek michal.simek@amd.com
Changes in v2:
Update logic based on 1/2 patch
board/xilinx/zynqmp/zynqmp.c | 55 ++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-)
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 3844a9c9a8ff..2522024b4082 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -626,6 +626,31 @@ enum env_location env_get_location(enum env_operation op, int prio)
#define DFU_ALT_BUF_LEN SZ_1K
+static void mtd_found_part(u32 *base, u32 *size) +{
- struct mtd_info *part, *mtd;
- mtd_probe_devices();
- mtd = get_mtd_device_nm("nor0");
- if (!IS_ERR_OR_NULL(mtd)) {
list_for_each_entry(part, &mtd->partitions, node) {
debug("0x%012llx-0x%012llx : \"%s\"\n",
part->offset, part->offset + part->size,
part->name);
if (*base >= part->offset &&
*base < part->offset + part->size) {
debug("Found my partition: %d/%s\n",
part->index, part->name);
*base = part->offset;
*size = part->size;
break;
}
}
- }
+}
- void set_dfu_alt_info(char *interface, char *devstr) { int multiboot, bootseq = 0, len = 0;
@@ -670,17 +695,29 @@ void set_dfu_alt_info(char *interface, char *devstr) break; case QSPI_MODE_24BIT: case QSPI_MODE_32BIT:
len += snprintf(buf + len, DFU_ALT_BUF_LEN,
"sf 0:0=boot.bin raw %x 0x1500000",
multiboot * SZ_32K);
-#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS)
if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME))
{
u32 base = multiboot * SZ_32K;
u32 size = 0x1500000;
u32 limit = size;
mtd_found_part(&base, &limit);
+#if defined(CONFIG_SYS_SPI_U_BOOT_OFFS)
size = limit;
limit = CONFIG_SYS_SPI_U_BOOT_OFFS;
+#endif
len += snprintf(buf + len, DFU_ALT_BUF_LEN,
";%s raw 0x%x 0x500000",
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME,
multiboot * SZ_32K +
CONFIG_SYS_SPI_U_BOOT_OFFS);
"sf 0:0=boot.bin raw 0x%x 0x%x",
base, limit);
+#if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS)
if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME))
len += snprintf(buf + len, DFU_ALT_BUF_LEN,
";%s raw 0x%x 0x%x",
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME,
#endifbase + limit, size - limit);
break; default: return;}
Applied. M

On 3/22/24 13:09, Michal Simek wrote:
Generate description only when CONFIG_SPL_FS_LOAD_PAYLOAD_NAME is not empty. When name is empty there is no reason to generate description for it because it is not aligned with dfu rules.
Signed-off-by: Michal Simek michal.simek@amd.com
Changes in v2:
- New patch is series coming from discussion at
https://lore.kernel.org/all/561f9d0ee96ebb6cd674042f269f280ab68fbbac.1708705...
board/xilinx/zynqmp/zynqmp.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index ba49eb7be229..3844a9c9a8ff 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -661,8 +661,11 @@ void set_dfu_alt_info(char *interface, char *devstr) len += snprintf(buf + len, DFU_ALT_BUF_LEN, ".bin fat %d 1", bootseq); #if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME)
len += snprintf(buf + len, DFU_ALT_BUF_LEN, ";%s fat %d 1",
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME, bootseq);
if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME))
len += snprintf(buf + len, DFU_ALT_BUF_LEN,
";%s fat %d 1",
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME,
#endif break; case QSPI_MODE_24BIT:bootseq);
@@ -671,10 +674,12 @@ void set_dfu_alt_info(char *interface, char *devstr) "sf 0:0=boot.bin raw %x 0x1500000", multiboot * SZ_32K); #if defined(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME) && defined(CONFIG_SYS_SPI_U_BOOT_OFFS)
len += snprintf(buf + len, DFU_ALT_BUF_LEN,
";%s raw 0x%x 0x500000",
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME,
multiboot * SZ_32K + CONFIG_SYS_SPI_U_BOOT_OFFS);
if (strlen(CONFIG_SPL_FS_LOAD_PAYLOAD_NAME))
len += snprintf(buf + len, DFU_ALT_BUF_LEN,
";%s raw 0x%x 0x500000",
CONFIG_SPL_FS_LOAD_PAYLOAD_NAME,
multiboot * SZ_32K +
#endif break; default:CONFIG_SYS_SPI_U_BOOT_OFFS);
Applied. M
participants (1)
-
Michal Simek