U-Boot ENV in EXT4 support for Espressobin
PATCH 1/1 U-Boot ENV in EXT4 support for Espressobin
Hi
I was attemting to boot from SATA on an Espressobin. As such I wanted to store the Environment in a SATA partition and not in the SPI flash. In order to get this running I had to make a few changes, as the original code assumes the Environment is always in SPI flash. Additionally I also had to force scsci_scan to ensure the AHCI disk / partitions could be found.
Hope it will be considered to merge
Regards
Rogier Stam
From 460eb1fc6d5189750d2ce791e45c89792c476167 Mon Sep 17 00:00:00 2001
From: Rogier Stam <[email protected]>
Date: Mon, 31 Jan 2022 23:06:19 +0100
Subject: [PATCH] Fix Espressobin build for configs where ENV is not in SPI
When storing the UBoot Environment in for example EXT4, the U-Boot build is broken for several reasons:
1. armada-385-turris-omnia-u-boot.dtsi will not allow CONFIG_ENV_OFFSET and CONFIG_ENV_SIZE to be undefined
2. armada-37xx/board.c ft_board_setup function does not exist if CONFIG_ENV_IS_IN_SPI_FLASH is not defined
3. When defining CONFIG_ENV_IS_IN_EXT4 and using AHCI SCSI scan is not performed and hence the partition on AHCI is not available when the environment is loaded.
This change fixes these 3 points so that the UBoot config can be on a AHCI (SATA) drive partition instead of enforced in SPI flash.
--- arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi | 2 ++ board/Marvell/mvebu_armada-37xx/board.c | 4 ++-- env/ext4.c | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-)
arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi +2 -0
@@ -41,6 +41,7 @@ &spi0 { u-boot,dm-pre-reloc; +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH spi-nor@0 { u-boot,dm-pre-reloc;
@@ -55,6 +56,7 @@ }; }; }; +#endif }; &uart0 {
board/Marvell/mvebu_armada-37xx/board.c +2 -2
@@ -328,7 +328,6 @@ int board_network_enable(struct mii_dev *bus)return 0 ; } -#if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_ENV_IS_IN_SPI_FLASH )int ft_board_setup (void *blob,struct bd_info *bd) {int ret;
@@ -340,6 +339,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)if (!of_machine_is_compatible ("globalscale,espressobin" ))return 0 ; +#if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_ENV_IS_IN_SPI_FLASH ) spi_off =fdt_node_offset_by_compatible (blob,-1 ,"jedec,spi-nor" );if (spi_off <0 )return 0 ;
@@ -424,6 +424,6 @@ int ft_board_setup(void *blob, struct bd_info *bd) return 0; } +#endif return 0 ; } -#endif
env/ext4.c +4 -0
@@ -146,6 +146,10 @@ static int env_ext4_load(void)if (!strcmp (ifname,"mmc" ))mmc_initialize (NULL );#endif +#ifdef CONFIG_AHCI +if (!strcmp (ifname,"scsi" )) +scsi_scan (true); +#endif part =blk_get_device_part_str (ifname, dev_and_part, &dev_desc, &info,1 );
Signature · 1 line
2.7.4
Hello! See inline comments below.
Quoted 46 lines · On Monday 07 February 2022 09:11:06 Rogier Stam wrote:
Hi
I was attemting to boot from SATA on an Espressobin. As such I wanted to store the Environment in a SATA partition and not in the SPI flash. In order to get this running I had to make a few changes, as the original code assumes the Environment is always in SPI flash. Additionally I also had to force
scsci_scanto ensure the AHCI disk / partitions could be found.Hope it will be considered to merge
Regards
Rogier Stam
From
460eb1fc6d5189750d2ce791e45c89792c476167Mon Sep 17 00:00:00 2001
From: Rogier Stam <[email protected]>
Date: Mon, 31 Jan 2022 23:06:19 +0100
Subject: [PATCH] Fix Espressobin build for configs where ENV is not in SPIWhen storing the UBoot Environment in for example EXT4, the U-Boot build is broken for several reasons:
1.armada-385-turris-omnia-u-boot.dtsiwill not allowCONFIG_ENV_OFFSETandCONFIG_ENV_SIZEto be undefined
2.armada-37xx/board.cft_board_setupfunction does not exist ifCONFIG_ENV_IS_IN_SPI_FLASHis not defined
3. When definingCONFIG_ENV_IS_IN_EXT4and using AHCI SCSI scan is not performed and hence the partition on AHCI is not available when the environment is loaded.This change fixes these 3 points so that the UBoot config can be on a AHCI (SATA) drive partition instead of enforced in SPI flash.
Signed-off-by Rogier Stam <[email protected]>--- arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi | 2 ++ board/Marvell/mvebu_armada-37xx/board.c | 4 ++-- env/ext4.c | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-)arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi +0
-0
arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi line 44
Quoted 4 lines
arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi +1
-0@@ -41,6 +41,7 @@ &spi0 { u-boot,dm-pre-reloc; +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
In my opinion this #ifdef should be put above "&spi0 {" line.
But I will let this change to Marek for review (CCed).
Quoted 24 lines
arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi +1
-0spi-nor@0 { u-boot,dm-pre-reloc;@@ -55,6 +56,7 @@ }; }; }; +#endif }; &uart0 {board/Marvell/mvebu_armada-37xx/board.c +0
-1@@ -328,7 +328,6 @@ int board_network_enable(struct mii_dev *bus)return 0 ; } -#if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_ENV_IS_IN_SPI_FLASH )int ft_board_setup (void *blob,struct bd_info *bd) {int ret;
board/Marvell/mvebu_armada-37xx/board.c int ft_board_setup(void *blob, struct bd_info *bd) · line 342
Quoted 4 lines
board/Marvell/mvebu_armada-37xx/board.c +1
-0@@ -340,6 +339,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)if (!of_machine_is_compatible ("globalscale,espressobin" ))return 0 ; +#if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_ENV_IS_IN_SPI_FLASH )
Even this change is not logically correct. Function ft_board_setup() should be defined only when CONFIG_OF_BOARD_SETUP is enabled.
So correct change should look like:
#ifdef CONFIG_OF_BOARD_SETUP
int ft_board_setup(void *blob, struct bd_info *bd) {
#ifdef CONFIG_ENV_IS_IN_SPI_FLASH int ret; int spi_off; ... #endif return 0; }
#endif
Quoted 16 lines
board/Marvell/mvebu_armada-37xx/board.c +1
-1spi_off =fdt_node_offset_by_compatible (blob,-1 ,"jedec,spi-nor" );if (spi_off <0 )return 0 ;@@ -424,6 +424,6 @@ int ft_board_setup(void *blob, struct bd_info *bd) return 0; } +#endif return 0 ; } -#endif env/ext4.c +0
-0
env/ext4.c static int env_ext4_load(void) · line 152
Quoted 7 lines
env/ext4.c +4
-0@@ -146,6 +146,10 @@ static int env_ext4_load(void)if (!strcmp (ifname,"mmc" ))mmc_initialize (NULL );#endif +#ifdef CONFIG_AHCI +if (!strcmp (ifname,"scsi" )) +scsi_scan (true); +#endif
I guess that same change is required also for env/fat.c driver.
Quoted 6 lines
env/ext4.c +0
-0part =blk_get_device_part_str (ifname, dev_and_part, &dev_desc, &info,1 );Signature · 1 line
2.7.4
Hi
Per Pali's comments adapted the patch. This one also includes the changes necessary for storing ENV in FAT. I also added CONFIG_SCSI for both ext4 and fat should anyone want to use SCSI instead of AHCI.
Regards
Rogier
Quoted 10 lines · Rogier Stam
Hi
I was attemting to boot from SATA on an Espressobin. As such I wanted to store the Environment in a SATA partition and not in the SPI flash. In order to get this running I had to make a few changes, as the original code assumes the Environment is always in SPI flash. Additionally I also had to force
scsci_scanto ensure the AHCI disk / partitions could be found.Hope it will be considered to merge
Regards
Rogier Stam
From e2c1b825700b6356b8b0758dcbe8c3c64bd79805 Mon Sep 17 00:00:00 2001
From: Rogier Stam <[email protected]>
Date: Mon, 31 Jan 2022 23:06:19 +0100
Subject: [PATCH] Fix Espressobin build for configs where ENV is not in SPI
When storing the UBoot Environment in for example EXT4, the U-Boot build is broken for several reasons:
1. armada-385-turris-omnia-u-boot.dtsi will not allow CONFIG_ENV_OFFSET and CONFIG_ENV_SIZE to be undefined
2. armada-37xx/board.c ft_board_setup function does not exist if CONFIG_ENV_IS_IN_SPI_FLASH is not defined
3. When defining CONFIG_ENV_IS_IN_EXT4 and using AHCI SCSI scan is not performed and hence the partition on AHCI is not available when the environment is loaded.
4. Same for CONFIG_ENV_IS_IN_FAT and using AHCI. SCSI scan is not performed.
This change fixes these 4 points so that the UBoot config can be on a AHCI (SATA) drive partition instead of enforced in SPI flash.
--- arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi | 2 ++ board/Marvell/mvebu_armada-37xx/board.c | 4 +++- env/ext4.c | 5 +++++ env/fat.c | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-)
arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi +2 -0
@@ -38,6 +38,7 @@ }; }; +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH &spi0 { u-boot,dm-pre-reloc;
@@ -56,6 +57,7 @@ }; }; }; +#endif &uart0 { u-boot,dm-pre-reloc;
board/Marvell/mvebu_armada-37xx/board.c +3 -1
@@ -328,9 +328,10 @@ int board_network_enable(struct mii_dev *bus)return 0 ; } -#if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_ENV_IS_IN_SPI_FLASH ) +#ifdef CONFIG_OF_BOARD_SETUP int ft_board_setup (void *blob,struct bd_info *bd) { +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH int ret;int spi_off;int parts_off;
@@ -424,6 +425,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)return 0 ; } +#endif return 0 ; }#endif
env/ext4.c +5 -0
@@ -31,6 +31,7 @@#include <errno.h> #include <ext4fs.h> #include <mmc.h> +#include <scsi.h> #include <asm/global_data.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -146,6 +147,10 @@ static int env_ext4_load(void)if (!strcmp (ifname,"mmc" ))mmc_initialize (NULL );#endif +#if defined(CONFIG_AHCI ) || defined(CONFIG_SCSI ) +if (!strcmp (ifname,"scsi" )) +scsi_scan (true); +#endif part =blk_get_device_part_str (ifname, dev_and_part, &dev_desc, &info,1 );
env/fat.c +5 -0
@@ -17,6 +17,7 @@#include <errno.h> #include <fat.h> #include <mmc.h> +#include <scsi.h> #include <asm/cache.h> #include <asm/global_data.h> #include <linux/stddef.h>
@@ -122,6 +123,10 @@ static int env_fat_load(void)if (!strcmp (CONFIG_ENV_FAT_INTERFACE ,"mmc" ))mmc_initialize (NULL );#endif +#if defined(CONFIG_AHCI ) || defined(CONFIG_SCSI ) +if (!strcmp (CONFIG_ENV_FAT_INTERFACE ,"scsi" )) +scsi_scan (true); +#endif part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, env_fat_device_and_part(),
Signature · 1 line
2.7.4
Pali Rohár
Reviewed-byQuoted 6 lines · On Monday 07 February 2022 23:56:25 Rogier Stam wrote:
Hi
Per Pali's comments adapted the patch. This one also includes the changes necessary for storing ENV in FAT. I also added
CONFIG_SCSIfor both ext4 and fat should anyone want to use SCSI instead of AHCI.
Quoted 20 lines
Regards
Rogier
Quoted 15 lines · Rogier Stam
Hi
I was attemting to boot from SATA on an Espressobin. As such I wanted to store the Environment in a SATA partition and not in the SPI flash. In order to get this running I had to make a few changes, as the original code assumes the Environment is always in SPI flash. Additionally I also had to force
scsci_scanto ensure the AHCI disk / partitions could be found.Hope it will be considered to merge
Regards
Rogier Stam
+ Marek
Quoted 17 lines
From
e2c1b825700b6356b8b0758dcbe8c3c64bd79805Mon Sep 17 00:00:00 2001
From: Rogier Stam <[email protected]>
Date: Mon, 31 Jan 2022 23:06:19 +0100
Subject: [PATCH] Fix Espressobin build for configs where ENV is not in SPIWhen storing the UBoot Environment in for example EXT4, the U-Boot build is broken for several reasons:
1.armada-385-turris-omnia-u-boot.dtsiwill not allowCONFIG_ENV_OFFSETandCONFIG_ENV_SIZEto be undefined
2.armada-37xx/board.cft_board_setupfunction does not exist ifCONFIG_ENV_IS_IN_SPI_FLASHis not defined
3. When definingCONFIG_ENV_IS_IN_EXT4and using AHCI SCSI scan is not performed and hence the partition on AHCI is not available when the environment is loaded.
4. Same forCONFIG_ENV_IS_IN_FATand using AHCI. SCSI scan is not performed.
Quoted 5 lines
This change fixes these 4 points so that the UBoot config can be on a AHCI (SATA) drive partition instead of enforced in SPI flash.
Signed-off-by Rogier Stam <[email protected]>
Quoted 100 lines
--- arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi | 2 ++ board/Marvell/mvebu_armada-37xx/board.c | 4 +++- env/ext4.c | 5 +++++ env/fat.c | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-)arch/arm/dts/armada-385-turris-omnia-u-boot.dtsi +2
-0@@ -38,6 +38,7 @@ }; }; +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH &spi0 { u-boot,dm-pre-reloc;@@ -56,6 +57,7 @@ }; }; }; +#endif &uart0 { u-boot,dm-pre-reloc;board/Marvell/mvebu_armada-37xx/board.c +3
-1@@ -328,9 +328,10 @@ int board_network_enable(struct mii_dev *bus)return 0 ; } -#if defined(CONFIG_OF_BOARD_SETUP ) && defined(CONFIG_ENV_IS_IN_SPI_FLASH ) +#ifdef CONFIG_OF_BOARD_SETUP int ft_board_setup (void *blob,struct bd_info *bd) { +#ifdef CONFIG_ENV_IS_IN_SPI_FLASH int ret;int spi_off;int parts_off;@@ -424,6 +425,7 @@ int ft_board_setup(void *blob, struct bd_info *bd)return 0 ; } +#endif return 0 ; }#endif env/ext4.c +5
-0@@ -31,6 +31,7 @@#include <errno.h> #include <ext4fs.h> #include <mmc.h> +#include <scsi.h> #include <asm/global_data.h> DECLARE_GLOBAL_DATA_PTR ;@@ -146,6 +147,10 @@ static int env_ext4_load(void)if (!strcmp (ifname,"mmc" ))mmc_initialize (NULL );#endif +#if defined(CONFIG_AHCI ) || defined(CONFIG_SCSI ) +if (!strcmp (ifname,"scsi" )) +scsi_scan (true); +#endif part =blk_get_device_part_str (ifname, dev_and_part, &dev_desc, &info,1 );env/fat.c +5
-0@@ -17,6 +17,7 @@#include <errno.h> #include <fat.h> #include <mmc.h> +#include <scsi.h> #include <asm/cache.h> #include <asm/global_data.h> #include <linux/stddef.h> @@ -122,6 +123,10 @@ static int env_fat_load(void)if (!strcmp (CONFIG_ENV_FAT_INTERFACE ,"mmc" ))mmc_initialize (NULL );#endif +#if defined(CONFIG_AHCI ) || defined(CONFIG_SCSI ) +if (!strcmp (CONFIG_ENV_FAT_INTERFACE ,"scsi" )) +scsi_scan (true); +#endif part = blk_get_device_part_str(CONFIG_ENV_FAT_INTERFACE, env_fat_device_and_part(),Signature · 1 line
2.7.4
Hi Rogier
Quoted 3 lines · Rogier Stam
Hi
Per Pali's comments adapted the patch. This one also includes the changes necessary for storing ENV in FAT. I also added
CONFIG_SCSIfor both ext4 and fat should anyone want to use SCSI instead of AHCI.
I have 2 comments, more related to formal patch submission.
a) Could you please send patches in-lined, best formatted via "git format-patch" and sent via "git send-email". Otherwise its harder to review and comment the patches.
b) Split you patch into 2 logically separated patches. One handling the common "env" files and one handling the Espressobin related files.
Thanks,
Stefan
Quoted 15 lines
Regards
Rogier
Quoted 10 lines · Rogier Stam
Hi
I was attemting to boot from SATA on an Espressobin. As such I wanted to store the Environment in a SATA partition and not in the SPI flash. In order to get this running I had to make a few changes, as the original code assumes the Environment is always in SPI flash. Additionally I also had to force
scsci_scanto ensure the AHCI disk / partitions could be found.Hope it will be considered to merge
Regards
Rogier Stam
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]