recovery: add support to update a specific image set
Add a new parameter '-i' to update-firmware to let the user select a specific image_set of the sw-description file to use during the swu update. This allows adding different image_sets on the sw-description and reduce the number of images to build. It also adds more future-proof flexibility. Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com> Signed-off-by: Hector Palacios <hector.palacios@digi.com> https://onedigi.atlassian.net/browse/DEL-8199
This commit is contained in:
parent
deed93cfb3
commit
0792b45a80
|
|
@ -563,6 +563,9 @@ for arg in ${COMMAND}; do
|
|||
update_package=*)
|
||||
update_package_bool=true;
|
||||
eval "${arg}";;
|
||||
swu_image_set=*)
|
||||
update_image_set_bool=true;
|
||||
eval "${arg}";;
|
||||
encrypt_partitions=*)
|
||||
eval "${arg}";
|
||||
DEFAULT_ENC_PARTS="no";
|
||||
|
|
@ -595,9 +598,9 @@ done
|
|||
|
||||
# Select update package image
|
||||
if [ "$(is_nand)" = "yes" ]; then
|
||||
SWUPDATE_IMAGE_SET="mtd,single"
|
||||
SWUPDATE_IMAGE_SET="${swu_image_set:-mtd,single}"
|
||||
else
|
||||
SWUPDATE_IMAGE_SET="mmc,single"
|
||||
SWUPDATE_IMAGE_SET="${swu_image_set:-mmc,single}"
|
||||
fi
|
||||
|
||||
# On eMMC, if the 'update' partition is encrypted, we need to mount it manually
|
||||
|
|
|
|||
|
|
@ -30,6 +30,17 @@
|
|||
*/
|
||||
int update_firmware(const char *swu_path);
|
||||
|
||||
/*
|
||||
* Configure recovery commands to update the firmware of a swu image_set.
|
||||
*
|
||||
* Params:
|
||||
* 'swu_path' (input) Path to the update package
|
||||
* 'swu_image_set' (input) Name of the image set to update
|
||||
*
|
||||
* Return: 0 on sucess, -1 on failure
|
||||
*/
|
||||
int update_image_set_firmware(const char *swu_path, const char *swu_image_set);
|
||||
|
||||
/*
|
||||
* Reboot into recovery mode.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -659,6 +659,41 @@ err:
|
|||
return ret ? -1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: update_image_set_firmware
|
||||
* Description: configure recovery commands to update the firmware of a swu
|
||||
* image set
|
||||
*/
|
||||
int update_image_set_firmware(const char *swu_path, const char *swu_image_set)
|
||||
{
|
||||
char *cmd = NULL;
|
||||
int ret = update_firmware(swu_path);
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Verify input parameter */
|
||||
if (!swu_image_set) {
|
||||
fprintf(stderr, "Error: NULL 'swu_image_set'\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
cmd = calloc(1, strlen("swu_image_set=") + strlen(swu_image_set) + 1);
|
||||
if (!cmd) {
|
||||
fprintf(stderr, "Error: calloc 'swu_image_set'\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
sprintf(cmd, "swu_image_set=%s", swu_image_set);
|
||||
|
||||
ret = append_recovery_command(cmd);
|
||||
|
||||
free(cmd);
|
||||
|
||||
err:
|
||||
return ret ? -1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: reboot_recovery
|
||||
* Description: reboot into recovery mode
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
"\n" \
|
||||
"Usage: %s [options] [<SWU-package-path>]\n\n" \
|
||||
" -u --update-firmware Perform firmware update\n" \
|
||||
" -i <image> --image-set=<image> Use the specified image-set from sw-description (only together with -u).\n" \
|
||||
" -e <partitions> --encrypt=<partitions> Encrypt the list of provided partitions.\n" \
|
||||
" -d <partitions> --unencrypt=<partitions> Un-encrypt the list of provided partitions.\n" \
|
||||
" -k [<key>] --encryption-key[=<key>] Set <key> as file system encryption key.\n" \
|
||||
|
|
@ -61,11 +62,12 @@
|
|||
"Version: %s\n" \
|
||||
"\n" \
|
||||
"Usage: %s [options] <SWU-package-path>\n\n" \
|
||||
" -k [<key>] --encryption-key[=<key>] Set <key> as file system encryption key.\n" \
|
||||
" Empty to generate a random key.\n" \
|
||||
" -T <N> --reboot-timeout=<N> Reboot after N seconds (default %d)\n" \
|
||||
" -f --force Force (un)encryption and key change operations.\n" \
|
||||
" --help Print help and exit\n" \
|
||||
" -i <image> --image-set=<image> Use the specified image-set from sw-description.\n" \
|
||||
" -k [<key>] --encryption-key[=<key>] Set <key> as file system encryption key.\n" \
|
||||
" Empty to generate a random key.\n" \
|
||||
" -T <N> --reboot-timeout=<N> Reboot after N seconds (default %d)\n" \
|
||||
" -f --force Force (un)encryption and key change operations.\n" \
|
||||
" --help Print help and exit\n" \
|
||||
"\n" \
|
||||
"<SWU-package-path> Absolute path to the firmware update package\n" \
|
||||
"\n"
|
||||
|
|
@ -95,6 +97,7 @@ static char *cmd_name;
|
|||
|
||||
/* Command line options */
|
||||
static char *swu_package;
|
||||
static char *swu_image_set = NULL;
|
||||
static char *key = NULL;
|
||||
static char *to_encrypt = NULL;
|
||||
static char *to_unencrypt = NULL;
|
||||
|
|
@ -130,9 +133,10 @@ static void usage_and_exit(int exitval)
|
|||
static void parse_options(int argc, char *argv[])
|
||||
{
|
||||
static int opt_index, opt;
|
||||
static const char *short_options = "uk::wT:e:d:f";
|
||||
static const char *short_options = "ui:k::wT:e:d:f";
|
||||
static const struct option long_options[] = {
|
||||
{"update-firmware", no_argument, NULL, 'u'},
|
||||
{"image_set", required_argument, NULL, 'i'},
|
||||
{"encryption-key", optional_argument, NULL, 'k'},
|
||||
{"wipe-update-partition", no_argument, NULL, 'w'},
|
||||
{"reboot-timeout", required_argument, NULL, 'T'},
|
||||
|
|
@ -158,6 +162,9 @@ static void parse_options(int argc, char *argv[])
|
|||
case 'u':
|
||||
update_fw = 1;
|
||||
break;
|
||||
case 'i':
|
||||
swu_image_set = optarg;
|
||||
break;
|
||||
case 'w':
|
||||
wipe_update = 1;
|
||||
break;
|
||||
|
|
@ -246,11 +253,18 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (swu_package) {
|
||||
/* Configure recovery commands to update the firmware */
|
||||
ret = update_firmware(swu_package);
|
||||
if (ret) {
|
||||
printf("Error: update_firmware\n");
|
||||
goto out;
|
||||
if (!swu_image_set) {
|
||||
ret = update_firmware(swu_package);
|
||||
if (ret)
|
||||
printf("Error: update_firmware\n");
|
||||
} else {
|
||||
ret = update_image_set_firmware(swu_package,
|
||||
swu_image_set);
|
||||
if (ret)
|
||||
printf("Error: update_image_set_firmware\n");
|
||||
}
|
||||
if (ret)
|
||||
goto out;
|
||||
need_reboot++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue