From afbed1ba2f8776b06ef821212b14a3e34bdcd2bd Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 12 Aug 2025 14:46:10 -0300 Subject: env: fat: Add support for NVME Add support for retrieving the FAT environment from an NVME device, the same way it can be retrieved from MMC, SCSI, or VIRTIO. To use the FAT environment from an NVME device, pass CONFIG_ENV_FAT_INTERFACE="nvme" in the defconfig. Signed-off-by: Fabio Estevam --- env/fat.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'env') diff --git a/env/fat.c b/env/fat.c index 65ee1c8e086..412d95dc305 100644 --- a/env/fat.c +++ b/env/fat.c @@ -14,8 +14,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -136,6 +138,14 @@ static int env_fat_load(void) if (!strcmp(ifname, "virtio")) virtio_init(); #endif +#if defined(CONFIG_NVME) + if (!strcmp(ifname, "nvme")) { + if (IS_ENABLED(CONFIG_PCI)) + pci_init(); + + nvme_scan_namespace(); + } +#endif #endif part = blk_get_device_part_str(ifname, dev_and_part, &dev_desc, &info, 1); -- cgit v1.2.3 From 7b21bf086053679c5ef1ea612072a78018370281 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 12 Aug 2025 14:46:11 -0300 Subject: env: ext4: Add support for NVME Add support for retrieving the EXT4 environment from an NVME device, the same way it can be retrieved from MMC, SCSI, or VIRTIO. To use the EXT4 environment from an NVME device, pass CONFIG_ENV_EXT4_INTERFACE="nvme" in the defconfig. Signed-off-by: Fabio Estevam --- env/ext4.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'env') diff --git a/env/ext4.c b/env/ext4.c index d92c844ea6c..c8122b4d22c 100644 --- a/env/ext4.c +++ b/env/ext4.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +158,14 @@ static int env_ext4_load(void) virtio_init(); #endif +#if defined(CONFIG_NVME) + if (!strcmp(ifname, "nvme")) { + if (IS_ENABLED(CONFIG_PCI)) + pci_init(); + + nvme_scan_namespace(); + } +#endif part = blk_get_device_part_str(ifname, dev_and_part, &dev_desc, &info, 1); if (part < 0) -- cgit v1.2.3 From 82444e3ecd0ea8404ed6fd1dd3710bfd8d641f52 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 12 Aug 2025 14:46:12 -0300 Subject: env: fat: Standardize the interface type check Make the interface type check consistent among the other interface types by checking it agains the ifname string. The ifname string contains the string returned by env_fat_get_intf(), which returns the CONFIG_ENV_FAT_INTERFACE value. No functional change. Signed-off-by: Fabio Estevam --- env/fat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'env') diff --git a/env/fat.c b/env/fat.c index 412d95dc305..58c279ff769 100644 --- a/env/fat.c +++ b/env/fat.c @@ -131,7 +131,7 @@ static int env_fat_load(void) #endif #ifndef CONFIG_XPL_BUILD #if defined(CONFIG_AHCI) || defined(CONFIG_SCSI) - if (!strcmp(CONFIG_ENV_FAT_INTERFACE, "scsi")) + if (!strcmp(ifname, "scsi")) scsi_scan(true); #endif #if defined(CONFIG_VIRTIO) -- cgit v1.2.3 From e589d5822cac10915ec04e8d9044d2460aec8924 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Mon, 22 Sep 2025 18:03:39 +0200 Subject: env: spi: Fix gd->env_valid for the first write When both SPI environment locations are invalid (gd->env_valid == ENV_INVALID), the first call to saveenv writes to the primary location and sets the active flag. However, the logic for updating gd->env_valid incorrectly sets it to ENV_REDUND, which does not match the actual location written. This causes the first two writes to target the same location, and alternation only begins after the second write. Update the logic to alternate gd->env_valid based on whether the last write was to the primary or redundant location, ensuring the first write sets ENV_VALID and subsequent writes alternate as expected. This aligns env_valid with the actual storage location and fixes the alternation sequence from the first write. With this change, the "Valid environment" printout correctly reflects the active location after each save, and the alternation between primary and redundant locations works as intended from the start. Signed-off-by: Michal Simek Reviewed-by: Marek Vasut Acked-by: E Shattow --- env/sf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'env') diff --git a/env/sf.c b/env/sf.c index 0b70e18b9af..0e27a020643 100644 --- a/env/sf.c +++ b/env/sf.c @@ -148,7 +148,7 @@ static int env_sf_save(void) puts("done\n"); - gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND; + gd->env_valid = gd->env_valid == ENV_VALID ? ENV_REDUND : ENV_VALID; printf("Valid environment: %d\n", (int)gd->env_valid); -- cgit v1.2.3