[PATCH v3 0/3] rockpi4: Add capsule update support

Add capsule update support for the RockPi4B and RockPi4C boards. Support is being added for updating the idbloader.img and u-boot.itb firmware images on configurations with the firmware images stored on GPT partitioned uSD card device.
Changes since V2: * Use rockchip in the commit message summary instead of rockpi * Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro * Move the board specific code out of this file into evb_rk3399.c * Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
Sughosh Ganu (3): rockchip: capsule: Add functions for supporting capsule updates rockpi4: board: Add firmware image information for capsule updates rockpi4: capsule: Enable UEFI capsule update on RockPi4 boards
arch/arm/include/asm/arch-rockchip/misc.h | 1 + arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/board.c | 152 ++++++++++++++++++++++ board/rockchip/evb_rk3399/evb-rk3399.c | 55 +++++++- configs/rock-pi-4-rk3399_defconfig | 8 ++ configs/rock-pi-4c-rk3399_defconfig | 8 ++ include/configs/rk3399_common.h | 16 +++ 7 files changed, 240 insertions(+), 1 deletion(-)

Add functions needed to support the UEFI capsule update feature on rockchip boards. Currently, the feature is being enabled on the RockPi4 boards with firmware images residing on GPT partitioned storage media.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V2: * Use rockchip in the commit message summary instead of rockpi * Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro * Move the board specific code out of this file into evb_rk3399.c
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/board.c | 152 +++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index b46cea2f91..619899ff68 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -246,6 +246,7 @@ config ROCKCHIP_RK3399 select DM_PMIC select DM_REGULATOR_FIXED select BOARD_LATE_INIT + imply PARTITION_TYPE_GUID imply PRE_CONSOLE_BUFFER imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_SDRAM_COMMON diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index cbe00d646c..0c806243e3 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -6,11 +6,15 @@ #include <clk.h> #include <cpu_func.h> #include <dm.h> +#include <efi_loader.h> #include <fastboot.h> #include <init.h> #include <log.h> +#include <mmc.h> +#include <part.h> #include <ram.h> #include <syscon.h> +#include <uuid.h> #include <asm/cache.h> #include <asm/global_data.h> #include <asm/io.h> @@ -22,8 +26,156 @@
DECLARE_GLOBAL_DATA_PTR;
+#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION) + +#define DFU_ALT_BUF_LEN SZ_1K + +extern struct efi_fw_image fw_images[]; + +static bool updatable_image(struct disk_partition *info) +{ + int i; + bool ret = false; + efi_guid_t image_type_guid; + + uuid_str_to_bin(info->type_guid, image_type_guid.b, + UUID_STR_FORMAT_GUID); + + for (i = 0; i < num_image_type_guids; i++) { + if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) { + ret = true; + break; + } + } + + return ret; +} + +static void set_image_index(struct disk_partition *info, int index) +{ + int i; + efi_guid_t image_type_guid; + + uuid_str_to_bin(info->type_guid, image_type_guid.b, + UUID_STR_FORMAT_GUID); + + for (i = 0; i < num_image_type_guids; i++) { + if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) { + fw_images[i].image_index = index; + break; + } + } +} + +static int get_mmc_desc(struct blk_desc **desc) +{ + int ret; + struct mmc *mmc; + struct udevice *dev; + + /* + * For now the firmware images are assumed to + * be on the SD card + */ + ret = uclass_get_device(UCLASS_MMC, 1, &dev); + if (ret) + return -1; + + mmc = mmc_get_mmc_dev(dev); + if (!mmc) + return -ENODEV; + + if ((ret = mmc_init(mmc))) + return ret; + + *desc = mmc_get_blk_desc(mmc); + if (!*desc) + return -1; + + return 0; +} + +void set_dfu_alt_info(char *interface, char *devstr) +{ + const char *name; + bool first = true; + int p, len, devnum, ret; + char buf[DFU_ALT_BUF_LEN]; + struct disk_partition info; + struct blk_desc *desc = NULL; + + ret = get_mmc_desc(&desc); + if (ret) { + log_err("Unable to get mmc desc\n"); + return; + } + + memset(buf, 0, sizeof(buf)); + name = blk_get_if_type_name(desc->if_type); + devnum = desc->devnum; + len = strlen(buf); + + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s %d=", name, devnum); + + for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) { + if (part_get_info(desc, p, &info)) + continue; + + /* Add entry to dfu_alt_info only for updatable images */ + if (updatable_image(&info)) { + if (!first) + len += snprintf(buf + len, + DFU_ALT_BUF_LEN - len, ";"); + + len += snprintf(buf + len, DFU_ALT_BUF_LEN - len, + "%s%d_%s part %d %d", + name, devnum, info.name, devnum, p); + first = false; + } + } + + log_debug("dfu_alt_info => %s\n", buf); + env_set("dfu_alt_info", buf); +} + +static void gpt_capsule_update_setup(void) +{ + int p, i, ret; + struct disk_partition info; + struct blk_desc *desc = NULL; + + rockchip_capsule_update_board_setup(); + + ret = get_mmc_desc(&desc); + if (ret) { + log_err("Unable to get mmc desc\n"); + return; + } + + for (p = 1, i = 1; p <= MAX_SEARCH_PARTITIONS; p++) { + if (part_get_info(desc, p, &info)) + continue; + + /* + * Since we have a GPT partitioned device, the updatable + * images could be stored in any order. Populate the + * image_index at runtime. + */ + if (updatable_image(&info)) { + set_image_index(&info, i); + i++; + } + } +} +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT && CONFIG_EFI_PARTITION */ + __weak int rk_board_late_init(void) { +#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION) + gpt_capsule_update_setup(); +#endif + return 0; }

On 2022/9/14 18:09, Sughosh Ganu wrote:
Add functions needed to support the UEFI capsule update feature on rockchip boards. Currently, the feature is being enabled on the RockPi4 boards with firmware images residing on GPT partitioned storage media.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
Changes since V2:
Use rockchip in the commit message summary instead of rockpi
Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro
Move the board specific code out of this file into evb_rk3399.c
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/board.c | 152 +++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+)
diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index b46cea2f91..619899ff68 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -246,6 +246,7 @@ config ROCKCHIP_RK3399 select DM_PMIC select DM_REGULATOR_FIXED select BOARD_LATE_INIT
- imply PARTITION_TYPE_GUID imply PRE_CONSOLE_BUFFER imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_SDRAM_COMMON
diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index cbe00d646c..0c806243e3 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -6,11 +6,15 @@ #include <clk.h> #include <cpu_func.h> #include <dm.h> +#include <efi_loader.h> #include <fastboot.h> #include <init.h> #include <log.h> +#include <mmc.h> +#include <part.h> #include <ram.h> #include <syscon.h> +#include <uuid.h> #include <asm/cache.h> #include <asm/global_data.h> #include <asm/io.h> @@ -22,8 +26,156 @@
DECLARE_GLOBAL_DATA_PTR;
+#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION)
+#define DFU_ALT_BUF_LEN SZ_1K
+extern struct efi_fw_image fw_images[];
+static bool updatable_image(struct disk_partition *info) +{
- int i;
- bool ret = false;
- efi_guid_t image_type_guid;
- uuid_str_to_bin(info->type_guid, image_type_guid.b,
UUID_STR_FORMAT_GUID);
- for (i = 0; i < num_image_type_guids; i++) {
if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) {
ret = true;
break;
}
- }
- return ret;
+}
+static void set_image_index(struct disk_partition *info, int index) +{
- int i;
- efi_guid_t image_type_guid;
- uuid_str_to_bin(info->type_guid, image_type_guid.b,
UUID_STR_FORMAT_GUID);
- for (i = 0; i < num_image_type_guids; i++) {
if (!guidcmp(&fw_images[i].image_type_id, &image_type_guid)) {
fw_images[i].image_index = index;
break;
}
- }
+}
+static int get_mmc_desc(struct blk_desc **desc) +{
- int ret;
- struct mmc *mmc;
- struct udevice *dev;
- /*
* For now the firmware images are assumed to
* be on the SD card
*/
- ret = uclass_get_device(UCLASS_MMC, 1, &dev);
- if (ret)
return -1;
- mmc = mmc_get_mmc_dev(dev);
- if (!mmc)
return -ENODEV;
- if ((ret = mmc_init(mmc)))
return ret;
- *desc = mmc_get_blk_desc(mmc);
- if (!*desc)
return -1;
- return 0;
+}
+void set_dfu_alt_info(char *interface, char *devstr) +{
- const char *name;
- bool first = true;
- int p, len, devnum, ret;
- char buf[DFU_ALT_BUF_LEN];
- struct disk_partition info;
- struct blk_desc *desc = NULL;
- ret = get_mmc_desc(&desc);
- if (ret) {
log_err("Unable to get mmc desc\n");
return;
- }
- memset(buf, 0, sizeof(buf));
- name = blk_get_if_type_name(desc->if_type);
- devnum = desc->devnum;
- len = strlen(buf);
- len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
"%s %d=", name, devnum);
- for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
if (part_get_info(desc, p, &info))
continue;
/* Add entry to dfu_alt_info only for updatable images */
if (updatable_image(&info)) {
if (!first)
len += snprintf(buf + len,
DFU_ALT_BUF_LEN - len, ";");
len += snprintf(buf + len, DFU_ALT_BUF_LEN - len,
"%s%d_%s part %d %d",
name, devnum, info.name, devnum, p);
first = false;
}
- }
- log_debug("dfu_alt_info => %s\n", buf);
- env_set("dfu_alt_info", buf);
+}
+static void gpt_capsule_update_setup(void) +{
- int p, i, ret;
- struct disk_partition info;
- struct blk_desc *desc = NULL;
- rockchip_capsule_update_board_setup();
- ret = get_mmc_desc(&desc);
- if (ret) {
log_err("Unable to get mmc desc\n");
return;
- }
- for (p = 1, i = 1; p <= MAX_SEARCH_PARTITIONS; p++) {
if (part_get_info(desc, p, &info))
continue;
/*
* Since we have a GPT partitioned device, the updatable
* images could be stored in any order. Populate the
* image_index at runtime.
*/
if (updatable_image(&info)) {
set_image_index(&info, i);
i++;
}
- }
+} +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT && CONFIG_EFI_PARTITION */
- __weak int rk_board_late_init(void) {
+#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION)
- gpt_capsule_update_setup();
+#endif
- return 0; }

Add information that will be needed for enabling the UEFI capsule update feature on the RockPi4 boards. With the feature enabled, it would be possible to update the idbloader and u-boot.itb images on the RockPi4B and RockPi4C variants.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V2: * Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
arch/arm/include/asm/arch-rockchip/misc.h | 1 + board/rockchip/evb_rk3399/evb-rk3399.c | 55 ++++++++++++++++++++++- include/configs/rk3399_common.h | 16 +++++++ 3 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/arch-rockchip/misc.h b/arch/arm/include/asm/arch-rockchip/misc.h index b6b03c934e..4155af8c3b 100644 --- a/arch/arm/include/asm/arch-rockchip/misc.h +++ b/arch/arm/include/asm/arch-rockchip/misc.h @@ -11,3 +11,4 @@ int rockchip_cpuid_from_efuse(const u32 cpuid_offset, u8 *cpuid); int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length); int rockchip_setup_macaddr(void); +void rockchip_capsule_update_board_setup(void); diff --git a/board/rockchip/evb_rk3399/evb-rk3399.c b/board/rockchip/evb_rk3399/evb-rk3399.c index abb76585cf..769d374f86 100644 --- a/board/rockchip/evb_rk3399/evb-rk3399.c +++ b/board/rockchip/evb_rk3399/evb-rk3399.c @@ -5,11 +5,25 @@
#include <common.h> #include <dm.h> +#include <efi_loader.h> #include <init.h> #include <log.h> #include <asm/arch-rockchip/periph.h> +#include <linux/kernel.h> #include <power/regulator.h>
+#define ROCKPI4_UPDATABLE_IMAGES 2 + +#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0}; + +struct efi_capsule_update_info update_info = { + .images = fw_images, +}; + +u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif + #ifndef CONFIG_SPL_BUILD int board_early_init_f(void) { @@ -29,4 +43,43 @@ int board_early_init_f(void) out: return 0; } -#endif + +#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION) +static bool board_is_rockpi_4b(void) +{ + return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) && + of_machine_is_compatible("radxa,rockpi4b"); +} + +static bool board_is_rockpi_4c(void) +{ + return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) && + of_machine_is_compatible("radxa,rockpi4c"); +} + +void rockchip_capsule_update_board_setup(void) +{ + if (board_is_rockpi_4b()) { + efi_guid_t idbldr_image_type_guid = + ROCKPI_4B_IDBLOADER_IMAGE_GUID; + efi_guid_t uboot_image_type_guid = ROCKPI_4B_UBOOT_IMAGE_GUID; + + guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid); + guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid); + + fw_images[0].fw_name = u"ROCKPI4B-IDBLOADER"; + fw_images[1].fw_name = u"ROCKPI4B-UBOOT"; + } else if (board_is_rockpi_4c()) { + efi_guid_t idbldr_image_type_guid = + ROCKPI_4C_IDBLOADER_IMAGE_GUID; + efi_guid_t uboot_image_type_guid = ROCKPI_4C_UBOOT_IMAGE_GUID; + + guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid); + guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid); + + fw_images[0].fw_name = u"ROCKPI4C-IDBLOADER"; + fw_images[1].fw_name = u"ROCKPI4C-UBOOT"; + } +} +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT && CONFIG_EFI_PARTITION */ +#endif /* !CONFIG_SPL_BUILD */ diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h index 2f9aee5819..f0a9ab8f83 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -24,6 +24,22 @@ #define CONFIG_SYS_SDRAM_BASE 0 #define SDRAM_MAX_SIZE 0xf8000000
+#define ROCKPI_4B_IDBLOADER_IMAGE_GUID \ + EFI_GUID(0x02f4d760, 0xcfd5, 0x43bd, 0x8e, 0x2d, \ + 0xa4, 0x2a, 0xcb, 0x33, 0xc6, 0x60) + +#define ROCKPI_4B_UBOOT_IMAGE_GUID \ + EFI_GUID(0x4ce292da, 0x1dd8, 0x428d, 0xa1, 0xc2, \ + 0x77, 0x74, 0x3e, 0xf8, 0xb9, 0x6e) + +#define ROCKPI_4C_IDBLOADER_IMAGE_GUID \ + EFI_GUID(0xfd68510c, 0x12d3, 0x4f0a, 0xb8, 0xd3, \ + 0xd8, 0x79, 0xe1, 0xd3, 0xa5, 0x40) + +#define ROCKPI_4C_UBOOT_IMAGE_GUID \ + EFI_GUID(0xb81fb4ae, 0xe4f3, 0x471b, 0x99, 0xb4, \ + 0x0b, 0x3d, 0xa5, 0x49, 0xce, 0x13) + #ifndef CONFIG_SPL_BUILD
#define ENV_MEM_LAYOUT_SETTINGS \

On 2022/9/14 18:09, Sughosh Ganu wrote:
Add information that will be needed for enabling the UEFI capsule update feature on the RockPi4 boards. With the feature enabled, it would be possible to update the idbloader and u-boot.itb images on the RockPi4B and RockPi4C variants.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
Changes since V2:
Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
arch/arm/include/asm/arch-rockchip/misc.h | 1 + board/rockchip/evb_rk3399/evb-rk3399.c | 55 ++++++++++++++++++++++- include/configs/rk3399_common.h | 16 +++++++ 3 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/arch-rockchip/misc.h b/arch/arm/include/asm/arch-rockchip/misc.h index b6b03c934e..4155af8c3b 100644 --- a/arch/arm/include/asm/arch-rockchip/misc.h +++ b/arch/arm/include/asm/arch-rockchip/misc.h @@ -11,3 +11,4 @@ int rockchip_cpuid_from_efuse(const u32 cpuid_offset, u8 *cpuid); int rockchip_cpuid_set(const u8 *cpuid, const u32 cpuid_length); int rockchip_setup_macaddr(void); +void rockchip_capsule_update_board_setup(void); diff --git a/board/rockchip/evb_rk3399/evb-rk3399.c b/board/rockchip/evb_rk3399/evb-rk3399.c index abb76585cf..769d374f86 100644 --- a/board/rockchip/evb_rk3399/evb-rk3399.c +++ b/board/rockchip/evb_rk3399/evb-rk3399.c @@ -5,11 +5,25 @@
#include <common.h> #include <dm.h> +#include <efi_loader.h> #include <init.h> #include <log.h> #include <asm/arch-rockchip/periph.h> +#include <linux/kernel.h> #include <power/regulator.h>
+#define ROCKPI4_UPDATABLE_IMAGES 2
+#if CONFIG_IS_ENABLED(EFI_HAVE_CAPSULE_SUPPORT) +struct efi_fw_image fw_images[ROCKPI4_UPDATABLE_IMAGES] = {0};
+struct efi_capsule_update_info update_info = {
- .images = fw_images,
+};
+u8 num_image_type_guids = ARRAY_SIZE(fw_images); +#endif
- #ifndef CONFIG_SPL_BUILD int board_early_init_f(void) {
@@ -29,4 +43,43 @@ int board_early_init_f(void) out: return 0; } -#endif
+#if defined(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) && defined(CONFIG_EFI_PARTITION) +static bool board_is_rockpi_4b(void) +{
- return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) &&
of_machine_is_compatible("radxa,rockpi4b");
+}
+static bool board_is_rockpi_4c(void) +{
- return CONFIG_IS_ENABLED(TARGET_EVB_RK3399) &&
of_machine_is_compatible("radxa,rockpi4c");
+}
+void rockchip_capsule_update_board_setup(void) +{
- if (board_is_rockpi_4b()) {
efi_guid_t idbldr_image_type_guid =
ROCKPI_4B_IDBLOADER_IMAGE_GUID;
efi_guid_t uboot_image_type_guid = ROCKPI_4B_UBOOT_IMAGE_GUID;
guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
fw_images[0].fw_name = u"ROCKPI4B-IDBLOADER";
fw_images[1].fw_name = u"ROCKPI4B-UBOOT";
- } else if (board_is_rockpi_4c()) {
efi_guid_t idbldr_image_type_guid =
ROCKPI_4C_IDBLOADER_IMAGE_GUID;
efi_guid_t uboot_image_type_guid = ROCKPI_4C_UBOOT_IMAGE_GUID;
guidcpy(&fw_images[0].image_type_id, &idbldr_image_type_guid);
guidcpy(&fw_images[1].image_type_id, &uboot_image_type_guid);
fw_images[0].fw_name = u"ROCKPI4C-IDBLOADER";
fw_images[1].fw_name = u"ROCKPI4C-UBOOT";
- }
+} +#endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT && CONFIG_EFI_PARTITION */ +#endif /* !CONFIG_SPL_BUILD */ diff --git a/include/configs/rk3399_common.h b/include/configs/rk3399_common.h index 2f9aee5819..f0a9ab8f83 100644 --- a/include/configs/rk3399_common.h +++ b/include/configs/rk3399_common.h @@ -24,6 +24,22 @@ #define CONFIG_SYS_SDRAM_BASE 0 #define SDRAM_MAX_SIZE 0xf8000000
+#define ROCKPI_4B_IDBLOADER_IMAGE_GUID \
- EFI_GUID(0x02f4d760, 0xcfd5, 0x43bd, 0x8e, 0x2d, \
0xa4, 0x2a, 0xcb, 0x33, 0xc6, 0x60)
+#define ROCKPI_4B_UBOOT_IMAGE_GUID \
- EFI_GUID(0x4ce292da, 0x1dd8, 0x428d, 0xa1, 0xc2, \
0x77, 0x74, 0x3e, 0xf8, 0xb9, 0x6e)
+#define ROCKPI_4C_IDBLOADER_IMAGE_GUID \
- EFI_GUID(0xfd68510c, 0x12d3, 0x4f0a, 0xb8, 0xd3, \
0xd8, 0x79, 0xe1, 0xd3, 0xa5, 0x40)
+#define ROCKPI_4C_UBOOT_IMAGE_GUID \
EFI_GUID(0xb81fb4ae, 0xe4f3, 0x471b, 0x99, 0xb4, \
0x0b, 0x3d, 0xa5, 0x49, 0xce, 0x13)
#ifndef CONFIG_SPL_BUILD
#define ENV_MEM_LAYOUT_SETTINGS \

Enable the UEFI capsule update functionality on the RockPi4B and RockPi4C boards. Support is being enabled for updating the idbloader and u-boot firmware images residing on GPT partitioned uSD card storage device.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org --- Changes since V2: None
configs/rock-pi-4-rk3399_defconfig | 8 ++++++++ configs/rock-pi-4c-rk3399_defconfig | 8 ++++++++ 2 files changed, 16 insertions(+)
diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4-rk3399_defconfig index f8a57f6838..4e253196a3 100644 --- a/configs/rock-pi-4-rk3399_defconfig +++ b/configs/rock-pi-4-rk3399_defconfig @@ -30,6 +30,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_TPL=y CONFIG_CMD_BOOTZ=y +CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_PCI=y @@ -40,6 +41,7 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DFU_MMC=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y @@ -84,3 +86,9 @@ CONFIG_VIDEO_ROCKCHIP=y CONFIG_DISPLAY_ROCKCHIP_HDMI=y CONFIG_SPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y +CONFIG_CMD_NVEDIT_EFI=y +CONFIG_CMD_EFIDEBUG=y +CONFIG_TOOLS_MKEFICAPSULE=y +CONFIG_HEXDUMP=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y diff --git a/configs/rock-pi-4c-rk3399_defconfig b/configs/rock-pi-4c-rk3399_defconfig index 9aa7809bd0..ee500a7d58 100644 --- a/configs/rock-pi-4c-rk3399_defconfig +++ b/configs/rock-pi-4c-rk3399_defconfig @@ -30,6 +30,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_TPL=y CONFIG_CMD_BOOTZ=y +CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_PCI=y @@ -40,6 +41,7 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DFU_MMC=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y @@ -84,3 +86,9 @@ CONFIG_VIDEO_ROCKCHIP=y CONFIG_DISPLAY_ROCKCHIP_HDMI=y CONFIG_SPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y +CONFIG_CMD_NVEDIT_EFI=y +CONFIG_CMD_EFIDEBUG=y +CONFIG_TOOLS_MKEFICAPSULE=y +CONFIG_HEXDUMP=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y

On 2022/9/14 18:09, Sughosh Ganu wrote:
Enable the UEFI capsule update functionality on the RockPi4B and RockPi4C boards. Support is being enabled for updating the idbloader and u-boot firmware images residing on GPT partitioned uSD card storage device.
Signed-off-by: Sughosh Ganu sughosh.ganu@linaro.org
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
Changes since V2: None
configs/rock-pi-4-rk3399_defconfig | 8 ++++++++ configs/rock-pi-4c-rk3399_defconfig | 8 ++++++++ 2 files changed, 16 insertions(+)
diff --git a/configs/rock-pi-4-rk3399_defconfig b/configs/rock-pi-4-rk3399_defconfig index f8a57f6838..4e253196a3 100644 --- a/configs/rock-pi-4-rk3399_defconfig +++ b/configs/rock-pi-4-rk3399_defconfig @@ -30,6 +30,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_TPL=y CONFIG_CMD_BOOTZ=y +CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_PCI=y @@ -40,6 +41,7 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DFU_MMC=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y @@ -84,3 +86,9 @@ CONFIG_VIDEO_ROCKCHIP=y CONFIG_DISPLAY_ROCKCHIP_HDMI=y CONFIG_SPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y +CONFIG_CMD_NVEDIT_EFI=y +CONFIG_CMD_EFIDEBUG=y +CONFIG_TOOLS_MKEFICAPSULE=y +CONFIG_HEXDUMP=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y diff --git a/configs/rock-pi-4c-rk3399_defconfig b/configs/rock-pi-4c-rk3399_defconfig index 9aa7809bd0..ee500a7d58 100644 --- a/configs/rock-pi-4c-rk3399_defconfig +++ b/configs/rock-pi-4c-rk3399_defconfig @@ -30,6 +30,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_TPL=y CONFIG_CMD_BOOTZ=y +CONFIG_CMD_DFU=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_PCI=y @@ -40,6 +41,7 @@ CONFIG_SPL_OF_CONTROL=y CONFIG_OF_SPL_REMOVE_PROPS="pinctrl-0 pinctrl-names clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents" CONFIG_ENV_IS_IN_MMC=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_DFU_MMC=y CONFIG_ROCKCHIP_GPIO=y CONFIG_SYS_I2C_ROCKCHIP=y CONFIG_MISC=y @@ -84,3 +86,9 @@ CONFIG_VIDEO_ROCKCHIP=y CONFIG_DISPLAY_ROCKCHIP_HDMI=y CONFIG_SPL_TINY_MEMSET=y CONFIG_ERRNO_STR=y +CONFIG_CMD_NVEDIT_EFI=y +CONFIG_CMD_EFIDEBUG=y +CONFIG_TOOLS_MKEFICAPSULE=y +CONFIG_HEXDUMP=y +CONFIG_EFI_CAPSULE_ON_DISK=y +CONFIG_EFI_CAPSULE_FIRMWARE_RAW=y

hi Tom,
On Wed, 14 Sept 2022 at 15:40, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add capsule update support for the RockPi4B and RockPi4C boards. Support is being added for updating the idbloader.img and u-boot.itb firmware images on configurations with the firmware images stored on GPT partitioned uSD card device.
Changes since V2:
- Use rockchip in the commit message summary instead of rockpi
- Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro
- Move the board specific code out of this file into evb_rk3399.c
- Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
These patches have been given a R-b by Kever. I see them being assigned to you. Can these be merged into master. Thanks.
-sughosh
Sughosh Ganu (3): rockchip: capsule: Add functions for supporting capsule updates rockpi4: board: Add firmware image information for capsule updates rockpi4: capsule: Enable UEFI capsule update on RockPi4 boards
arch/arm/include/asm/arch-rockchip/misc.h | 1 + arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/board.c | 152 ++++++++++++++++++++++ board/rockchip/evb_rk3399/evb-rk3399.c | 55 +++++++- configs/rock-pi-4-rk3399_defconfig | 8 ++ configs/rock-pi-4c-rk3399_defconfig | 8 ++ include/configs/rk3399_common.h | 16 +++ 7 files changed, 240 insertions(+), 1 deletion(-)
-- 2.34.1

On 2022/11/2 14:21, Sughosh Ganu wrote:
hi Tom,
On Wed, 14 Sept 2022 at 15:40, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add capsule update support for the RockPi4B and RockPi4C boards. Support is being added for updating the idbloader.img and u-boot.itb firmware images on configurations with the firmware images stored on GPT partitioned uSD card device.
Changes since V2:
- Use rockchip in the commit message summary instead of rockpi
- Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro
- Move the board specific code out of this file into evb_rk3399.c
- Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
These patches have been given a R-b by Kever. I see them being assigned to you. Can these be merged into master. Thanks.
Interesting, I don't think I had re-assign this patch set to Tom after I give the review tag,
I can take it later if there is no objection to this from Tom.
Thanks,
- Kever
-sughosh
Sughosh Ganu (3): rockchip: capsule: Add functions for supporting capsule updates rockpi4: board: Add firmware image information for capsule updates rockpi4: capsule: Enable UEFI capsule update on RockPi4 boards
arch/arm/include/asm/arch-rockchip/misc.h | 1 + arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/board.c | 152 ++++++++++++++++++++++ board/rockchip/evb_rk3399/evb-rk3399.c | 55 +++++++- configs/rock-pi-4-rk3399_defconfig | 8 ++ configs/rock-pi-4c-rk3399_defconfig | 8 ++ include/configs/rk3399_common.h | 16 +++ 7 files changed, 240 insertions(+), 1 deletion(-)
-- 2.34.1

On Wed, Nov 02, 2022 at 05:23:48PM +0800, Kever Yang wrote:
On 2022/11/2 14:21, Sughosh Ganu wrote:
hi Tom,
On Wed, 14 Sept 2022 at 15:40, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add capsule update support for the RockPi4B and RockPi4C boards. Support is being added for updating the idbloader.img and u-boot.itb firmware images on configurations with the firmware images stored on GPT partitioned uSD card device.
Changes since V2:
- Use rockchip in the commit message summary instead of rockpi
- Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro
- Move the board specific code out of this file into evb_rk3399.c
- Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
These patches have been given a R-b by Kever. I see them being assigned to you. Can these be merged into master. Thanks.
Interesting, I don't think I had re-assign this patch set to Tom after I give the review tag,
I can take it later if there is no objection to this from Tom.
Is there any refactoring / updating to these patches required based on the overall feedback given either (a) as part of the follow-up changes to the FWU core that've been done or (b) that is similar to the feedback given to the Developerbox series?

hi Tom,
On Wed, 2 Nov 2022 at 18:52, Tom Rini trini@konsulko.com wrote:
On Wed, Nov 02, 2022 at 05:23:48PM +0800, Kever Yang wrote:
On 2022/11/2 14:21, Sughosh Ganu wrote:
hi Tom,
On Wed, 14 Sept 2022 at 15:40, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add capsule update support for the RockPi4B and RockPi4C boards. Support is being added for updating the idbloader.img and u-boot.itb firmware images on configurations with the firmware images stored on GPT partitioned uSD card device.
Changes since V2:
- Use rockchip in the commit message summary instead of rockpi
- Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro
- Move the board specific code out of this file into evb_rk3399.c
- Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
These patches have been given a R-b by Kever. I see them being assigned to you. Can these be merged into master. Thanks.
Interesting, I don't think I had re-assign this patch set to Tom after I give the review tag,
I can take it later if there is no objection to this from Tom.
Is there any refactoring / updating to these patches required based on the overall feedback given either (a) as part of the follow-up changes to the FWU core that've been done or (b) that is similar to the feedback given to the Developerbox series?
These patches are enabling capsule update support on the boards, and are not related to the FWU update functionality.
-sughosh
-- Tom

On Wed, Nov 02, 2022 at 08:12:23PM +0530, Sughosh Ganu wrote:
hi Tom,
On Wed, 2 Nov 2022 at 18:52, Tom Rini trini@konsulko.com wrote:
On Wed, Nov 02, 2022 at 05:23:48PM +0800, Kever Yang wrote:
On 2022/11/2 14:21, Sughosh Ganu wrote:
hi Tom,
On Wed, 14 Sept 2022 at 15:40, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add capsule update support for the RockPi4B and RockPi4C boards. Support is being added for updating the idbloader.img and u-boot.itb firmware images on configurations with the firmware images stored on GPT partitioned uSD card device.
Changes since V2:
- Use rockchip in the commit message summary instead of rockpi
- Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro
- Move the board specific code out of this file into evb_rk3399.c
- Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
These patches have been given a R-b by Kever. I see them being assigned to you. Can these be merged into master. Thanks.
Interesting, I don't think I had re-assign this patch set to Tom after I give the review tag,
I can take it later if there is no objection to this from Tom.
Is there any refactoring / updating to these patches required based on the overall feedback given either (a) as part of the follow-up changes to the FWU core that've been done or (b) that is similar to the feedback given to the Developerbox series?
These patches are enabling capsule update support on the boards, and are not related to the FWU update functionality.
OK, I just had them mentally conflated then, I'll re-assign them to Kever shortly.

hi Kever,
On Wed, 2 Nov 2022 at 14:53, Kever Yang kever.yang@rock-chips.com wrote:
On 2022/11/2 14:21, Sughosh Ganu wrote:
hi Tom,
On Wed, 14 Sept 2022 at 15:40, Sughosh Ganu sughosh.ganu@linaro.org wrote:
Add capsule update support for the RockPi4B and RockPi4C boards. Support is being added for updating the idbloader.img and u-boot.itb firmware images on configurations with the firmware images stored on GPT partitioned uSD card device.
Changes since V2:
- Use rockchip in the commit message summary instead of rockpi
- Use num_image_type_guids instead of ROCKPI4_UPDATABLE_IMAGES macro
- Move the board specific code out of this file into evb_rk3399.c
- Add a function rockchip_capsule_update_board_setup() for setting up the board specific part needed for capsule updates
These patches have been given a R-b by Kever. I see them being assigned to you. Can these be merged into master. Thanks.
Interesting, I don't think I had re-assign this patch set to Tom after I give the review tag,
I can take it later if there is no objection to this from Tom.
I need to rebase the patches, as one of the API (blk_get_if_type_name) used has changed since 8149b1500d8. I will send a rebased V4. Please merge that version. Thanks.
-sughosh
Thanks,
- Kever
-sughosh
Sughosh Ganu (3): rockchip: capsule: Add functions for supporting capsule updates rockpi4: board: Add firmware image information for capsule updates rockpi4: capsule: Enable UEFI capsule update on RockPi4 boards
arch/arm/include/asm/arch-rockchip/misc.h | 1 + arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/board.c | 152 ++++++++++++++++++++++ board/rockchip/evb_rk3399/evb-rk3399.c | 55 +++++++- configs/rock-pi-4-rk3399_defconfig | 8 ++ configs/rock-pi-4c-rk3399_defconfig | 8 ++ include/configs/rk3399_common.h | 16 +++ 7 files changed, 240 insertions(+), 1 deletion(-)
-- 2.34.1
participants (3)
-
Kever Yang
-
Sughosh Ganu
-
Tom Rini