From 269d80105d22ec4a0293c45df44c2c93769725ae Mon Sep 17 00:00:00 2001 From: Mike Engel Date: Mon, 19 Aug 2024 15:54:40 +0200 Subject: [PATCH] recovery-utils: add preprocessor flag to change recovery tool usage help This commit adds a compiler flag to remove certain options from the recovery-utils, because some features rely on functionality that is not supported by the CCMP1 platforms. https://onedigi.atlassian.net/browse/DEL-9116 Signed-off-by: Mike Engel --- .../recipes-core/recovery/recovery-utils.bb | 5 ++- .../recovery-reboot/recovery-reboot.c | 45 ++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/meta-digi-dey/recipes-core/recovery/recovery-utils.bb b/meta-digi-dey/recipes-core/recovery/recovery-utils.bb index 28a148903..a90aeec5a 100644 --- a/meta-digi-dey/recipes-core/recovery/recovery-utils.bb +++ b/meta-digi-dey/recipes-core/recovery/recovery-utils.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2017, Digi International Inc. +# Copyright (C) 2017-2024, Digi International Inc. SUMMARY = "Recovery reboot utilities" LICENSE = "MPL-2.0" @@ -12,6 +12,9 @@ SRC_URI = "file://${BPN}" S = "${WORKDIR}/${BPN}" +# Set compilation flag to disable some recovery features that are not supported +CFLAGS = "${@oe.utils.conditional('DEY_SOC_VENDOR', 'NXP', ' -DSUPPORTS_FS_ENCRYPTION', '', d)}" + do_install() { oe_runmake DESTDIR=${D} install } 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 549aeb33f..a7b97f5c5 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2021, Digi International Inc. + * Copyright (c) 2017-2024, Digi International Inc. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -26,7 +26,7 @@ #include -#define VERSION "0.3" GIT_REVISION +#define VERSION "0.4" GIT_REVISION #define REBOOT_TIMEOUT 10 @@ -34,6 +34,17 @@ #define CMD_UPDATEFW "update-firmware" #define CMD_ENCRYPT "encrypt-partitions" +#ifdef SUPPORTS_FS_ENCRYPTION +#define HELP_ENCRYPT " -e --encrypt= Encrypt the list of provided partitions.\n" +#define HELP_UNENCRYPT " -d --unencrypt= Un-encrypt the list of provided partitions.\n" +#define HELP_KEY " -k [] --encryption-key[=] Set as file system encryption key.\n" \ + " Empty to generate a random key.\n" +#else +#define HELP_ENCRYPT "" +#define HELP_UNENCRYPT "" +#define HELP_KEY "" +#endif /* CCMP_RECOVERY_SUPPORT */ + #define RECOVERY_USAGE \ "Reboot into recovery mode setting recovery commands.\n" \ "Copyright(c) Digi International Inc.\n" \ @@ -43,10 +54,9 @@ "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" \ - " Empty to generate a random key.\n" \ + HELP_ENCRYPT \ + HELP_UNENCRYPT \ + HELP_KEY \ " -w --wipe-update-partition Wipe 'update' partition\n" \ " -T --reboot-timeout= Reboot after N seconds (default %d)\n" \ " -f --force Force (un)encryption and key change operations.\n" \ @@ -63,8 +73,7 @@ "\n" \ "Usage: %s [options] \n\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" \ + HELP_KEY \ " -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" \ @@ -79,10 +88,9 @@ "Version: %s\n" \ "\n" \ "Usage: %s [-e ] [-d ] [options]\n\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" \ - " Empty to generate a random key.\n" \ + HELP_ENCRYPT \ + HELP_UNENCRYPT \ + HELP_KEY \ " -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" \ @@ -133,6 +141,7 @@ static void usage_and_exit(int exitval) static void parse_options(int argc, char *argv[]) { static int opt_index, opt; +#ifdef SUPPORTS_FS_ENCRYPTION static const char *short_options = "ui:k::wT:e:d:f"; static const struct option long_options[] = { {"update-firmware", no_argument, NULL, 'u'}, @@ -146,6 +155,18 @@ static void parse_options(int argc, char *argv[]) {"help", no_argument, NULL, 'h'}, {NULL, 0, NULL, 0} }; +#else + static const char *short_options = "ui:wT:f"; + static const struct option long_options[] = { + {"update-firmware", no_argument, NULL, 'u'}, + {"image_set", required_argument, NULL, 'i'}, + {"wipe-update-partition", no_argument, NULL, 'w'}, + {"reboot-timeout", required_argument, NULL, 'T'}, + {"force", no_argument, NULL, 'f'}, + {"help", no_argument, NULL, 'h'}, + {NULL, 0, NULL, 0} + }; +#endif char *endptr; if (argc == 1)