[PATCH v2] efi_loader: change the error message when storing EFI variables

Ilias Apalodimas ilias.apalodimas at linaro.org
Fri Apr 19 11:45:45 CEST 2024


When we try to store EFI variables on a file, we need to use an ESP.
if an ESP is not found, variables will change in memory, but U-Boot
won't be able to restore them across reboots.

Adjust the error message so users can understand what's going on

Signed-off-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>
---
Changes since v1:
- print different messages if ESP is missing or write to file failed

 lib/efi_loader/efi_var_file.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index 413e1794e88c..d5d347d50f8d 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -73,16 +73,20 @@ efi_status_t efi_var_to_file(void)
 		goto error;

 	ret = efi_set_blk_dev_to_system_partition();
-	if (ret != EFI_SUCCESS)
+	if (ret != EFI_SUCCESS) {
+		log_err("ESP not found.");
 		goto error;
+	}

 	r = fs_write(EFI_VAR_FILE_NAME, map_to_sysmem(buf), 0, len, &actlen);
-	if (r || len != actlen)
+	if (r || len != actlen) {
+		log_err("Failed to store variables.");
 		ret = EFI_DEVICE_ERROR;
+	}

 error:
 	if (ret != EFI_SUCCESS)
-		log_err("Failed to persist EFI variables\n");
+		log_err(" UEFI variables won't persist reboot\n");
 	free(buf);
 	return ret;
 #else
--
2.43.0



More information about the U-Boot mailing list