summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-11-01 10:56:37 -0500
committerTom Rini <trini@konsulko.com>2020-11-01 10:56:37 -0500
commit41cab8edbcf38bce5cddf54957618dd4205d008f (patch)
treeefe29a6e552133360d8303fc44b025ecf2cc1b95 /common
parent2c31d7e746766f47a007f39c030706e493a9cc77 (diff)
parentaf11423eb06d68784647b879cac57d7b6619d095 (diff)
Merge tag 'efi-2020-01-rc2-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2021-01-rc2 (2) The series contains the following enhancements * preparatory patches for UEFI capsule updates * initialization of the emulated RTC using an environment variable and a bug fix * If DisconnectController() is called for a child controller that is the only child of the driver, the driver must be disconnected.
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig15
-rw-r--r--common/Makefile3
-rw-r--r--common/board_r.c6
-rw-r--r--common/update.c77
4 files changed, 97 insertions, 4 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 318d372a48..2bce8c9ba1 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -599,9 +599,15 @@ endmenu
menu "Update support"
+config UPDATE_COMMON
+ bool
+ default n
+ select DFU_WRITE_ALT
+
config UPDATE_TFTP
bool "Auto-update using fitImage via TFTP"
depends on FIT
+ select UPDATE_COMMON
help
This option allows performing update of NOR with data in fitImage
sent via TFTP boot.
@@ -616,6 +622,15 @@ config UPDATE_TFTP_MSEC_MAX
default 100
depends on UPDATE_TFTP
+config UPDATE_FIT
+ bool "Firmware update using fitImage"
+ depends on FIT
+ depends on DFU
+ select UPDATE_COMMON
+ help
+ This option allows performing update of DFU-capable storage with
+ data in fitImage.
+
config ANDROID_AB
bool "Android A/B updates"
default n
diff --git a/common/Makefile b/common/Makefile
index 2e7a090588..bcf352d016 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -53,8 +53,7 @@ obj-$(CONFIG_LCD_ROTATION) += lcd_console_rotation.o
obj-$(CONFIG_LCD_DT_SIMPLEFB) += lcd_simplefb.o
obj-$(CONFIG_LYNXKDI) += lynxkdi.o
obj-$(CONFIG_MENU) += menu.o
-obj-$(CONFIG_UPDATE_TFTP) += update.o
-obj-$(CONFIG_DFU_TFTP) += update.o
+obj-$(CONFIG_UPDATE_COMMON) += update.o
obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
obj-$(CONFIG_CMDLINE) += cli_readline.o cli_simple.o
diff --git a/common/board_r.c b/common/board_r.c
index 0829622d0d..29dd7d26d9 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -73,6 +73,9 @@
#if defined(CONFIG_GPIO_HOG)
#include <asm/gpio.h>
#endif
+#ifdef CONFIG_EFI_SETUP_EARLY
+#include <efi_loader.h>
+#endif
DECLARE_GLOBAL_DATA_PTR;
@@ -889,6 +892,9 @@ static init_fnc_t init_sequence_r[] = {
#if defined(CONFIG_PRAM)
initr_mem,
#endif
+#ifdef CONFIG_EFI_SETUP_EARLY
+ (init_fnc_t)efi_init_obj_list,
+#endif
run_main_loop,
};
diff --git a/common/update.c b/common/update.c
index 36b6b7523d..808be0880d 100644
--- a/common/update.c
+++ b/common/update.c
@@ -29,6 +29,7 @@
#include <errno.h>
#include <mtd/cfi_flash.h>
+#ifdef CONFIG_DFU_TFTP
/* env variable holding the location of the update file */
#define UPDATE_FILE_ENV "updatefile"
@@ -98,6 +99,7 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
return rv;
}
+#endif /* CONFIG_DFU_TFTP */
#ifdef CONFIG_MTD_NOR_FLASH
static int update_flash_protect(int prot, ulong addr_first, ulong addr_last)
@@ -231,6 +233,7 @@ static int update_fit_getparams(const void *fit, int noffset, ulong *addr,
return 0;
}
+#ifdef CONFIG_DFU_TFTP
int update_tftp(ulong addr, char *interface, char *devstring)
{
char *filename, *env_addr, *fit_image_name;
@@ -324,8 +327,10 @@ got_update_file:
}
} else if (fit_image_check_type(fit, noffset,
IH_TYPE_FIRMWARE)) {
- ret = dfu_tftp_write(fit_image_name, update_addr,
- update_size, interface, devstring);
+ ret = dfu_write_by_name(fit_image_name,
+ (void *)update_addr,
+ update_size, interface,
+ devstring);
if (ret)
return ret;
}
@@ -335,3 +340,71 @@ next_node:
return ret;
}
+#endif /* CONFIG_DFU_UPDATE */
+
+#ifdef CONFIG_UPDATE_FIT
+/**
+ * fit_update - update storage with FIT image
+ * @fit: Pointer to FIT image
+ *
+ * Update firmware on storage using FIT image as input.
+ * The storage area to be update will be identified by the name
+ * in FIT and matching it to "dfu_alt_info" variable.
+ *
+ * Return: 0 - on success, non-zero - otherwise
+ */
+int fit_update(const void *fit)
+{
+ char *fit_image_name;
+ ulong update_addr, update_fladdr, update_size;
+ int images_noffset, ndepth, noffset;
+ int ret = 0;
+
+ if (!fit)
+ return -EINVAL;
+
+ if (!fit_check_format((void *)fit)) {
+ printf("Bad FIT format of the update file, aborting auto-update\n");
+ return -EINVAL;
+ }
+
+ /* process updates */
+ images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
+
+ ndepth = 0;
+ noffset = fdt_next_node(fit, images_noffset, &ndepth);
+ while (noffset >= 0 && ndepth > 0) {
+ if (ndepth != 1)
+ goto next_node;
+
+ fit_image_name = (char *)fit_get_name(fit, noffset, NULL);
+ printf("Processing update '%s' :", fit_image_name);
+
+ if (!fit_image_verify(fit, noffset)) {
+ printf("Error: invalid update hash, aborting\n");
+ ret = 1;
+ goto next_node;
+ }
+
+ printf("\n");
+ if (update_fit_getparams(fit, noffset, &update_addr,
+ &update_fladdr, &update_size)) {
+ printf("Error: can't get update parameters, aborting\n");
+ ret = 1;
+ goto next_node;
+ }
+
+ if (fit_image_check_type(fit, noffset, IH_TYPE_FIRMWARE)) {
+ ret = dfu_write_by_name(fit_image_name,
+ (void *)update_addr,
+ update_size, NULL, NULL);
+ if (ret)
+ return ret;
+ }
+next_node:
+ noffset = fdt_next_node(fit, noffset, &ndepth);
+ }
+
+ return ret;
+}
+#endif /* CONFIG_UPDATE_FIT */