diff --git a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init index 0655579c3..9c02e310c 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init +++ b/meta-digi-dey/recipes-core/recovery/recovery-initramfs/recovery-initramfs-init @@ -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 diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h index e73a86951..768ce059c 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/include/recovery.h @@ -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. * diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c index 69fb29667..5e9833e15 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/lib/recovery.c @@ -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 diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/recovery-reboot/recovery-reboot.c b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/recovery-reboot/recovery-reboot.c index 7e2a360d1..549aeb33f 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/recovery-reboot/recovery-reboot.c +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils/recovery-utils/recovery-reboot/recovery-reboot.c @@ -42,6 +42,7 @@ "\n" \ "Usage: %s [options] []\n\n" \ " -u --update-firmware Perform firmware update\n" \ + " -i --image-set= Use the specified image-set from sw-description (only together with -u).\n" \ " -e --encrypt= Encrypt the list of provided partitions.\n" \ " -d --unencrypt= Un-encrypt the list of provided partitions.\n" \ " -k [] --encryption-key[=] Set as file system encryption key.\n" \ @@ -61,11 +62,12 @@ "Version: %s\n" \ "\n" \ "Usage: %s [options] \n\n" \ - " -k [] --encryption-key[=] Set as file system encryption key.\n" \ - " Empty to generate a random key.\n" \ - " -T --reboot-timeout= 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-set= Use the specified image-set from sw-description.\n" \ + " -k [] --encryption-key[=] Set as file system encryption key.\n" \ + " Empty to generate a random key.\n" \ + " -T --reboot-timeout= Reboot after N seconds (default %d)\n" \ + " -f --force Force (un)encryption and key change operations.\n" \ + " --help Print help and exit\n" \ "\n" \ " 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++; }