From 46836a4b1e3df604cd26e5b274201cd55cc8b472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Iwanicki?= Date: Wed, 24 Sep 2025 10:16:38 +0200 Subject: [PATCH] dasharo-deploy: create smmstore_migrate helper and reword question MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MichaƂ Iwanicki --- include/dts-functions.sh | 4 ++-- scripts/dasharo-deploy.sh | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/dts-functions.sh b/include/dts-functions.sh index 34b9712..711782b 100644 --- a/include/dts-functions.sh +++ b/include/dts-functions.sh @@ -1588,7 +1588,7 @@ footer_options() { # send_dts_logs_main [ask] # Use send_dts_logs which calls this function. # Create and upload archive with logs if SEND_LOGS_ACTIVE is true or first -# argument is "ask" and user confirms that he wants to send logs +# argument is "ask" and user confirms that they want to send logs send_dts_logs_main() { local ask="$1" local send_logs="false" @@ -1672,7 +1672,7 @@ send_dts_logs_main() { # send_dts_logs [ask] # Create and upload archive with logs if SEND_LOGS_ACTIVE is true or first -# argument is "ask" and user confirms that he wants to send logs +# argument is "ask" and user confirms that they want to send logs send_dts_logs() { local ask="$1" if ! send_dts_logs_main "$@"; then diff --git a/scripts/dasharo-deploy.sh b/scripts/dasharo-deploy.sh index b64a159..fe404e0 100644 --- a/scripts/dasharo-deploy.sh +++ b/scripts/dasharo-deploy.sh @@ -633,13 +633,24 @@ smbios_migration() { [[ "$_the_image_was_changed" == "true" ]] && return 0 || return 1 } +# smmstore_migrate +# helper function for smmstore_migration. Returns non-zero if any command failed +smmstore_migrate() { + $FLASHROM read_firm_mock -p "$PROGRAMMER_BIOS" ${FLASH_CHIP_SELECT} \ + -r /tmp/dasharo_dump.rom ${FLASHROM_ADD_OPT_READ} --fmap -i FMAP \ + -i SMMSTORE >>$FLASHROM_LOG_FILE 2>>$ERR_LOG_FILE && + $CBFSTOOL read_smmstore_mock /tmp/dasharo_dump.rom read -r SMMSTORE \ + -f /tmp/smmstore.bin >>$ERR_LOG_FILE 2>&1 && + $CBFSTOOL write_smmstore_mock "$BIOS_UPDATE_FILE" write -r SMMSTORE \ + -f /tmp/smmstore.bin -u >>$ERR_LOG_FILE 2>&1 +} + smmstore_migration() { echo -n "Backing up firmware configuration... " - if ! $FLASHROM read_firm_mock -p "$PROGRAMMER_BIOS" ${FLASH_CHIP_SELECT} -r /tmp/dasharo_dump.rom ${FLASHROM_ADD_OPT_READ} --fmap -i FMAP -i SMMSTORE >>$FLASHROM_LOG_FILE 2>>$ERR_LOG_FILE || - ! $CBFSTOOL read_smmstore_mock /tmp/dasharo_dump.rom read -r SMMSTORE -f /tmp/smmstore.bin >>$ERR_LOG_FILE 2>&1 || - ! $CBFSTOOL write_smmstore_mock "$BIOS_UPDATE_FILE" write -r SMMSTORE -f /tmp/smmstore.bin -u >>$ERR_LOG_FILE 2>&1; then + if ! smmstore_migrate; then if ask_for_confirmation "Couldn't migrate BIOS configuration. -Do you want to continue update, which will result in restoring all BIOS configuration to default?"; then +Updating BIOS will result in all configuration being restored to default. +Do you want to continue update?"; then print_warning "Continuing update without migrating BIOS configuration" else error_exit "Aborting..."