]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
env: scsi: add CONFIG_ENV_SCSI_HW_PARTITION
authorDavid Lechner <dlechner@baylibre.com>
Thu, 26 Mar 2026 22:59:27 +0000 (17:59 -0500)
committerTom Rini <trini@konsulko.com>
Wed, 8 Apr 2026 17:07:07 +0000 (11:07 -0600)
Add CONFIG_ENV_SCSI_HW_PARTITION and supporting code to allow loading
the environment directly from a SCSI device without a partition table.
Some platforms store the environment directly on the SCSI device without
a way to look it up by partition UUID.

Signed-off-by: David Lechner <dlechner@baylibre.com>
env/Kconfig
env/scsi.c

index 5824f762870895095fc235682c24978f1fd6939b..ffaf16c581cee166256d185ccee4954e5a4b36fc 100644 (file)
@@ -762,6 +762,17 @@ config ENV_MMC_USE_DT
          The 2 defines CONFIG_ENV_OFFSET, CONFIG_ENV_OFFSET_REDUND
          are not used as fallback.
 
+config ENV_SCSI_HW_PARTITION
+       string "SCSI hardware partition number"
+       depends on ENV_IS_IN_SCSI
+       default 0
+       help
+         SCSI hardware partition device number on the platform where the
+         environment is stored.  Note that this is not related to any software
+         defined partition table but instead if we are in the user area, which is
+         partition 0 or the first boot partition, which is 1 or some other defined
+         partition.
+
 config ENV_SCSI_PART_UUID
        string "SCSI partition UUID for saving environment"
        depends on ENV_IS_IN_SCSI
index 1787dcca92ab43ea321ad6c9d1f2e1a2c974284f..f4986353da5cb393453c8858b91beaac8c86fb74 100644 (file)
@@ -41,8 +41,14 @@ static inline struct env_scsi_info *env_scsi_get_part(void)
                is_scsi_scanned = true;
        }
 
-       if (scsi_get_blk_by_uuid(CONFIG_ENV_SCSI_PART_UUID, &ep->blk, &ep->part))
-               return NULL;
+       if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0') {
+               if (blk_get_device_part_str("scsi", CONFIG_ENV_SCSI_HW_PARTITION,
+                                           &ep->blk, &ep->part, true))
+                       return NULL;
+       } else {
+               if (scsi_get_blk_by_uuid(CONFIG_ENV_SCSI_PART_UUID, &ep->blk, &ep->part))
+                       return NULL;
+       }
 
        ep->count = CONFIG_ENV_SIZE / ep->part.blksz;
 
@@ -89,12 +95,20 @@ static int env_scsi_load(void)
        int ret;
 
        if (!ep) {
-               env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition not found", 0);
+               if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0')
+                       env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " not found", 0);
+               else
+                       env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition not found", 0);
+
                return -ENOENT;
        }
 
        if (blk_dread(ep->blk, ep->part.start, ep->count, &envbuf) != ep->count) {
-               env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition read failed", 0);
+               if (CONFIG_ENV_SCSI_PART_UUID[0] == '\0')
+                       env_set_default("SCSI partition " CONFIG_ENV_SCSI_HW_PARTITION " read failed", 0);
+               else
+                       env_set_default(CONFIG_ENV_SCSI_PART_UUID " partition read failed", 0);
+
                return -EIO;
        }