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=*)
|
||||||
update_package_bool=true;
|
update_package_bool=true;
|
||||||
eval "${arg}";;
|
eval "${arg}";;
|
||||||
|
swu_image_set=*)
|
||||||
|
update_image_set_bool=true;
|
||||||
|
eval "${arg}";;
|
||||||
encrypt_partitions=*)
|
encrypt_partitions=*)
|
||||||
eval "${arg}";
|
eval "${arg}";
|
||||||
DEFAULT_ENC_PARTS="no";
|
DEFAULT_ENC_PARTS="no";
|
||||||
|
|
@ -595,9 +598,9 @@ done
|
||||||
|
|
||||||
# Select update package image
|
# Select update package image
|
||||||
if [ "$(is_nand)" = "yes" ]; then
|
if [ "$(is_nand)" = "yes" ]; then
|
||||||
SWUPDATE_IMAGE_SET="mtd,single"
|
SWUPDATE_IMAGE_SET="${swu_image_set:-mtd,single}"
|
||||||
else
|
else
|
||||||
SWUPDATE_IMAGE_SET="mmc,single"
|
SWUPDATE_IMAGE_SET="${swu_image_set:-mmc,single}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# On eMMC, if the 'update' partition is encrypted, we need to mount it manually
|
# 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);
|
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.
|
* Reboot into recovery mode.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -659,6 +659,41 @@ err:
|
||||||
return ret ? -1 : 0;
|
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
|
* Function: reboot_recovery
|
||||||
* Description: reboot into recovery mode
|
* Description: reboot into recovery mode
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@
|
||||||
"\n" \
|
"\n" \
|
||||||
"Usage: %s [options] [<SWU-package-path>]\n\n" \
|
"Usage: %s [options] [<SWU-package-path>]\n\n" \
|
||||||
" -u --update-firmware Perform firmware update\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" \
|
" -e <partitions> --encrypt=<partitions> Encrypt the list of provided partitions.\n" \
|
||||||
" -d <partitions> --unencrypt=<partitions> Un-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" \
|
" -k [<key>] --encryption-key[=<key>] Set <key> as file system encryption key.\n" \
|
||||||
|
|
@ -61,11 +62,12 @@
|
||||||
"Version: %s\n" \
|
"Version: %s\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
"Usage: %s [options] <SWU-package-path>\n\n" \
|
"Usage: %s [options] <SWU-package-path>\n\n" \
|
||||||
" -k [<key>] --encryption-key[=<key>] Set <key> as file system encryption key.\n" \
|
" -i <image> --image-set=<image> Use the specified image-set from sw-description.\n" \
|
||||||
" Empty to generate a random key.\n" \
|
" -k [<key>] --encryption-key[=<key>] Set <key> as file system encryption key.\n" \
|
||||||
" -T <N> --reboot-timeout=<N> Reboot after N seconds (default %d)\n" \
|
" Empty to generate a random key.\n" \
|
||||||
" -f --force Force (un)encryption and key change operations.\n" \
|
" -T <N> --reboot-timeout=<N> Reboot after N seconds (default %d)\n" \
|
||||||
" --help Print help and exit\n" \
|
" -f --force Force (un)encryption and key change operations.\n" \
|
||||||
|
" --help Print help and exit\n" \
|
||||||
"\n" \
|
"\n" \
|
||||||
"<SWU-package-path> Absolute path to the firmware update package\n" \
|
"<SWU-package-path> Absolute path to the firmware update package\n" \
|
||||||
"\n"
|
"\n"
|
||||||
|
|
@ -95,6 +97,7 @@ static char *cmd_name;
|
||||||
|
|
||||||
/* Command line options */
|
/* Command line options */
|
||||||
static char *swu_package;
|
static char *swu_package;
|
||||||
|
static char *swu_image_set = NULL;
|
||||||
static char *key = NULL;
|
static char *key = NULL;
|
||||||
static char *to_encrypt = NULL;
|
static char *to_encrypt = NULL;
|
||||||
static char *to_unencrypt = 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 void parse_options(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
static int opt_index, opt;
|
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[] = {
|
static const struct option long_options[] = {
|
||||||
{"update-firmware", no_argument, NULL, 'u'},
|
{"update-firmware", no_argument, NULL, 'u'},
|
||||||
|
{"image_set", required_argument, NULL, 'i'},
|
||||||
{"encryption-key", optional_argument, NULL, 'k'},
|
{"encryption-key", optional_argument, NULL, 'k'},
|
||||||
{"wipe-update-partition", no_argument, NULL, 'w'},
|
{"wipe-update-partition", no_argument, NULL, 'w'},
|
||||||
{"reboot-timeout", required_argument, NULL, 'T'},
|
{"reboot-timeout", required_argument, NULL, 'T'},
|
||||||
|
|
@ -158,6 +162,9 @@ static void parse_options(int argc, char *argv[])
|
||||||
case 'u':
|
case 'u':
|
||||||
update_fw = 1;
|
update_fw = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
swu_image_set = optarg;
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
wipe_update = 1;
|
wipe_update = 1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -246,11 +253,18 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (swu_package) {
|
if (swu_package) {
|
||||||
/* Configure recovery commands to update the firmware */
|
/* Configure recovery commands to update the firmware */
|
||||||
ret = update_firmware(swu_package);
|
if (!swu_image_set) {
|
||||||
if (ret) {
|
ret = update_firmware(swu_package);
|
||||||
printf("Error: update_firmware\n");
|
if (ret)
|
||||||
goto out;
|
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++;
|
need_reboot++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue