xilinx: Add option to load environment from outside of
v2 cover xilinx: Add option to load environment from outside of
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded env_locations[] code.
- Add implementation with general arch_env_get_location(op, prio)
v1: https://lore.kernel.org/u-boot/[email protected]/
Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot media
board/xilinx/versal-net/board.c | 47 ++++++++++++++-------------- board/xilinx/versal/board.c | 47 ++++++++++++++-------------- board/xilinx/zynq/board.c | 49 +++++++++++++++-------------- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++---------------- 4 files changed, 101 insertions(+), 97 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/1 xilinx: Add option to load environment from outside of boot media
From: Vasileios Amoiridis <[email protected]>
Currently, if the environment is not in the current boot media, the env_get_location() is returning ENVL_UNKNOWN or ENVL_NOWHERE which is not true (i.e booting from FLASH with environment in eMMC). This commit adds an extra check to find the environment in the other supported boot media, keeping the same priority as of now.
--- board/xilinx/versal-net/board.c | 47 ++++++++++++++-------------- board/xilinx/versal/board.c | 47 ++++++++++++++-------------- board/xilinx/zynq/board.c | 49 +++++++++++++++-------------- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++---------------- 4 files changed, 101 insertions(+), 97 deletions(-)
board/xilinx/versal-net/board.c +24 -23
@@ -377,29 +377,30 @@ enum env_location env_get_location(enum env_operation op, int prio) {u8 bootmode =versal_net_get_bootmode (); -if (prio) -return ENVL_UNKNOWN ; - -switch (bootmode) { -case EMMC_MODE : -case SD_MODE : -case SD1_LSHFT_MODE : -case SD_MODE1 : -if (IS_ENABLED (CONFIG_ENV_IS_IN_FAT )) -return ENVL_FAT ; -if (IS_ENABLED (CONFIG_ENV_IS_IN_EXT4 )) -return ENVL_EXT4 ; -return ENVL_NOWHERE ; -case OSPI_MODE : -case QSPI_MODE_24BIT : -case QSPI_MODE_32BIT : -if (IS_ENABLED (CONFIG_ENV_IS_IN_SPI_FLASH )) -return ENVL_SPI_FLASH ; -return ENVL_NOWHERE ; -case JTAG_MODE : -case SELECTMAP_MODE : -default : -return ENVL_NOWHERE ; +if (!prio) { +switch (bootmode) { +case EMMC_MODE : +case SD_MODE : +case SD1_LSHFT_MODE : +case SD_MODE1 : +if (IS_ENABLED (CONFIG_ENV_IS_IN_FAT )) +return ENVL_FAT ; +if (IS_ENABLED (CONFIG_ENV_IS_IN_EXT4 )) +return ENVL_EXT4 ; +break ; +case OSPI_MODE : +case QSPI_MODE_24BIT : +case QSPI_MODE_32BIT : +if (IS_ENABLED (CONFIG_ENV_IS_IN_SPI_FLASH )) +return ENVL_SPI_FLASH ; +break ; +case JTAG_MODE : +case SELECTMAP_MODE : +default : +return ENVL_NOWHERE ; + } } + +return arch_env_get_location (op, prio); }#endif
board/xilinx/versal/board.c +24 -23
53 lines not on this page · raw message
board/xilinx/zynq/board.c +25 -24
56 lines not on this page · raw message
board/xilinx/zynqmp/zynqmp.c +28 -27
62 lines not on this page · raw message
Signature · 1 line
2.34.1
Quoted 8 lines · Vasileios Amoiridis
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded env_locations[] code.
- Add implementation with generalarch_env_get_location(op, prio)
Quoted 9 lines
Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot mediaboard/xilinx/versal-net/board.c | 47 ++++++++++++++-------------- board/xilinx/versal/board.c | 47 ++++++++++++++-------------- board/xilinx/zynq/board.c | 49 +++++++++++++++-------------- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++---------------- 4 files changed, 101 insertions(+), 97 deletions(-)
Applied.
M
Hi Vasileios,
út 4. 6. 2024 v 15:21 odesílatel Vasileios Amoiridis <[email protected]> napsal:
Quoted 12 lines
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded env_locations[] code.
- Add implementation with generalarch_env_get_location(op, prio)v1: https://lore.kernel.org/u-boot/[email protected]/
Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot media
Quoted 9 lines
board/xilinx/versal-net/board.c | 47 ++++++++++++++-------------- board/xilinx/versal/board.c | 47 ++++++++++++++-------------- board/xilinx/zynq/board.c | 49 +++++++++++++++-------------- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++---------------- 4 files changed, 101 insertions(+), 97 deletions(-)--
2.34.1
I have to remove this patch from my queue because it is actually breaking current behavior.
CI is reporting an issue with it and I did a closer look and what is happening is that if one location has no valid
data it goes and looks at another location from the list.
On Zynq it behaves like this.
MMC: mmc@e0100000: 0
prio 0
Loading Environment from SPIFlash... SF: Detected n25q128a13 with page size 256 Bytes, erase size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environment
prio 1
Loading Environment from NAND... *** Error - No Valid Environment Area found *** Warning - bad env area, using default environment
prio 2
Loading Environment from SPIFlash... *** Warning - bad CRC, using default environment
prio 3
Loading Environment from nowhere... OK
prio is my print to show where code is. Qemu boots out in QSPI boot mode and SPI is tried first and because
this is xilinx_zynq_virt defconfig drivers/env locations for other devices are present too. That's why it goes over the list and it always ends in nowhere which never fails.
If this runs on real HW then the same behavior is visible and I don't think it is right.
I think this solution should be rethought.
In product current behavior from our code is not the best and current U-Boot implementation is not allowing
flexibility too. We are enabling redundant variables which can be only on the same device but not that you have
one copy in QSPI and second in EMMC.
That's why I think location should be pretty much read from DT. There is options/u-boot node where location of variables should be described and this should replaceenv_get_location().
It is a lot of work that's why I think second solution is more reasonable for you which is simply create new Kconfig symbol to disable board env_get_location() implementation.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
Quoted 30 lines · Michal Simek
Hi Vasileios,
út 4. 6. 2024 v 15:21 odesílatel Vasileios Amoiridis <[email protected]> napsal:
Quoted 20 lines
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded env_locations[] code.
- Add implementation with generalarch_env_get_location(op, prio)v1:
https://lore.kernel.org/u-boot/[email protected]/Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot mediaboard/xilinx/versal-net/board.c | 47 ++++++++++++++-------------- board/xilinx/versal/board.c | 47 ++++++++++++++-------------- board/xilinx/zynq/board.c | 49 +++++++++++++++-------------- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++------------
----Quoted 5 lines
4 files changed, 101 insertions(+), 97 deletions(-)--
2.34.1
Quoted 6 lines
I have to remove this patch from my queue because it is actually breaking current behavior.
CI is reporting an issue with it and I did a closer look and what is happening is that if one location has no valid
data it goes and looks at another location from the list.
But that is the desired behavior, if the environment is not in one location to check to the others.
Quoted 14 lines
On Zynq it behaves like this.
MMC: mmc@e0100000: 0
prio 0
Loading Environment from SPIFlash... SF: Detected n25q128a13 with page
size 256 Bytes, erase size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environmentprio 1
Loading Environment from NAND... *** Error - No Valid Environment Area found
*** Warning - bad env area, using default environment
Quoted 8 lines
prio 2
Loading Environment from SPIFlash... *** Warning - bad CRC, using default environmentprio 3
Loading Environment from nowhere... OK
This is the message that we get as well when this patch is not added.
Quoted 6 lines
prio is my print to show where code is. Qemu boots out in QSPI boot mode and SPI is tried first and because
this isxilinx_zynq_virtdefconfigdrivers/envlocations for other devices are present too. That's why it goes over the list and it always ends in nowhere which never fails.
Quoted 13 lines
If this runs on real HW then the same behavior is visible and I don't think it is right.
I think this solution should be rethought.
In product current behavior from our code is not the best and current U-Boot implementation is not allowing
flexibility too. We are enabling redundant variables which can be only
on the same device but not that you have
one copy in QSPI and second in EMMC.
That's why I think location should be pretty much read from DT. There is options/u-boot node where location of variables should be described and this should replaceenv_get_location().
You mean that there should be some type of new U-Boot node that describes where the environment should be located and go and search in this device?
Quoted 7 lines
It is a lot of work that's why I think second solution is more reasonable for you which is simply create new
Kconfigsymbol to disable boardenv_get_location()implementation.Thanks,
Michal
You mean to basically disable the board env_get_location() that exists in board/xilinx/zynqmp/zynqmp.c for example?
Cheers,
Vasilis
Quoted 38 lines · Vasileios Amoiridis
Quoted 30 lines · Michal Simek
Hi Vasileios,
út 4. 6. 2024 v 15:21 odesílatel Vasileios Amoiridis <[email protected]> napsal:
Quoted 22 lines
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded env_locations[]
code.
- Add implementation with general arch_env_get_location(op,
prio)v1:
https://lore.kernel.org/u-boot/[email protected]/Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot mediaboard/xilinx/versal-net/board.c | 47 ++++++++++++++-------------- board/xilinx/versal/board.c | 47 ++++++++++++++-------------- board/xilinx/zynq/board.c | 49 +++++++++++++++-------------- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++------------ ---- 4 files changed, 101 insertions(+), 97 deletions(-)Quoted 3 lines
--
2.34.1Quoted 6 lines
I have to remove this patch from my queue because it is actually breaking current behavior.
CI is reporting an issue with it and I did a closer look and what is happening is that if one location has no valid
data it goes and looks at another location from the list.
Quoted 2 lines
But that is the desired behavior, if the environment is not in one location to check to the others.
That's how u-boot is written but if device doesn't exist or not accessible by u-boot it is clear that it shouldn't be used and then behavior is correct.
If device exists and simple varibles are not yet saved there going to different device is IMHO problematic.
Quoted 19 lines
Quoted 19 lines
On Zynq it behaves like this.
MMC: mmc@e0100000: 0
prio 0
Loading Environment from SPIFlash... SF: Detected n25q128a13 with page
size 256 Bytes, erase size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environmentprio 1
Loading Environment from NAND... *** Error - No Valid Environment Area found
*** Warning - bad env area, using default environmentprio 2
Loading Environment from SPIFlash... *** Warning - bad CRC, using default environment
Quoted 6 lines
Quoted 4 lines
prio 3
Loading Environment from nowhere... OKThis is the message that we get as well when this patch is not added.
It means you are booting out of QSPI but qspi is not accessible by u-boot. Correct?
Quoted 20 lines
Quoted 6 lines
prio is my print to show where code is. Qemu boots out in QSPI boot mode and SPI is tried first and because
this isxilinx_zynq_virtdefconfigdrivers/envlocations for other devices are present too. That's why it goes over the list and it always ends in nowhere which never fails.Quoted 13 lines
If this runs on real HW then the same behavior is visible and I don't think it is right.
I think this solution should be rethought.
In product current behavior from our code is not the best and current U-Boot implementation is not allowing
flexibility too. We are enabling redundant variables which can be only
on the same device but not that you have
one copy in QSPI and second in EMMC.
That's why I think location should be pretty much read from DT. There is options/u-boot node where location of variables should be described and this should replaceenv_get_location().
Quoted 3 lines
You mean that there should be some type of new U-Boot node that describes where the environment should be located and go and search in this device?
Not sure if node or just dt property which points where that variables are stored.
Quoted 10 lines
Quoted 7 lines
It is a lot of work that's why I think second solution is more reasonable for you which is simply create new
Kconfigsymbol to disable boardenv_get_location()implementation.Thanks,
MichalYou mean to basically disable the board
env_get_location()that exists inboard/xilinx/zynqmp/zynqmp.cfor example?
yes. Something like this.
config BOARD_ENV_LOCATION
bool "Use board defined ENV location" default y ...
if defined (BOARD_ENV_SETUP/LOCATION)
enum env_location env_get_location(enum env_operation op, int prio) {
...
}
endif
M
Signature · 6 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP/Versal ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal/Versal NET SoCs TF-A maintainer - Xilinx ZynqMP/Versal/Versal NET SoCs
Quoted 49 lines · Michal Simek
Quoted 46 lines · Vasileios Amoiridis
Quoted 44 lines · Michal Simek
Hi Vasileios,
út 4. 6. 2024 v 15:21 odesílatel Vasileios Amoiridis <[email protected]> napsal:
Quoted 27 lines
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded
env_locations[]
code.
- Add implementation with general
arch_env_get_location(op,
prio)v1:
https://lore.kernel.org/u-boot/[email protected]/Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot mediaboard/xilinx/versal-net/board.c | 47 ++++++++++++++----------
----
board/xilinx/versal/board.c | 47 ++++++++++++++----------
----
board/xilinx/zynq/board.c | 49 +++++++++++++++---------
-----
board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++-------
-----
----Quoted 5 lines
4 files changed, 101 insertions(+), 97 deletions(-)--
2.34.1I have to remove this patch from my queue because it is actually breaking current behavior.
CI is reporting an issue with it and I did a closer look and what is
happening is that if one location has no valid
data it goes and looks at another location from the list.
Quoted 8 lines
Quoted 2 lines
But that is the desired behavior, if the environment is not in one location to check to the others.
That's how u-boot is written but if device doesn't exist or not accessible by
u-boot it is clear that it shouldn't be used and then behavior is correct.
Hmmm, how can a device be not-accessible by u-boot but u-boot still tries to use it? How could that happen?
Also, I think that this is a problem of the user, no? If for example you have configure ENV_IS_IN_NAND but there is no NAND device, then with the patch you get a visible error that U-Boot tries to access NAND which is not there.
Quoted 4 lines
If device exists and simple varibles are not yet saved there going to different
device is IMHO problematic.
Maybe I am still a bit confused, but I think that if you have defined ENV_IS_IN_QSPI and ENV_IS_IN_NAND but the environment is not there then the behavior that we see is actually correct. U-Boot tries:
a) Get env from QSPI but fails because env is not there,
b) Get env from NAND but fails because NAND is not there,
c) Get env from nowhere.
To me, this looks like the correct behavior. Isn't it?
Quoted 24 lines
Quoted 24 lines
Quoted 23 lines
On Zynq it behaves like this.
MMC: mmc@e0100000: 0
prio 0
Loading Environment from SPIFlash... SF: Detected n25q128a13 with page
size 256 Bytes, erase size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environmentprio 1
Loading Environment from NAND... *** Error - No Valid Environment Area found
*** Warning - bad env area, using default environmentprio 2
Loading Environment from SPIFlash... *** Warning - bad CRC, using default environmentprio 3
Loading Environment from nowhere... OK
Quoted 7 lines
Quoted 2 lines
This is the message that we get as well when this patch is not added.
It means you are booting out of QSPI but qspi is not accessible by u- boot. Correct?
Well, we are booting from QSPI but environment is in eMMC. In our config, we have defined ENV_IS_IN_FAT and ENV_IS_NOWHERE but we have not defined ENV_IS_IN_QSPI.
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
prio is my print to show where code is. Qemu boots out in QSPI boot
mode and SPI is tried first and because
this isxilinx_zynq_virtdefconfigdrivers/envlocations for other
devices are present too. That's why it goes over the list and it always ends in nowhere which never fails.If this runs on real HW then the same behavior is visible and I don't
think it is right.
I think this solution should be rethought.
In product current behavior from our code is not the best and current
U-Boot implementation is not allowing
flexibility too. We are enabling redundant variables which can be only
on the same device but not that you have
one copy in QSPI and second in EMMC.
That's why I think location should be pretty much read from DT. There is options/u-boot node where location of variables should be
described and this should replaceenv_get_location().
Quoted 8 lines
Quoted 3 lines
You mean that there should be some type of new U-Boot node that describes where the environment should be located and go and search in this device?
Not sure if node or just dt property which points where that variables are stored.
This doesn't sound too difficult to do. Still, even if this was done, what would the priority be for looking for the environment? For now, the code is written in a way to check for the environment only in the bootmedia. My patch added a functionality that if the environment is not in the bootmedia to check somewhere else. This should be the order also if we had this u-boot node? Check first in the bootmedia and then check if there is a dt property?
Quoted 18 lines
Quoted 10 lines
Quoted 7 lines
It is a lot of work that's why I think second solution is more reasonable for you which is simply create new
Kconfigsymbol to disable boardenv_get_location()implementation.Thanks,
MichalYou mean to basically disable the board
env_get_location()that exists inboard/xilinx/zynqmp/zynqmp.cfor example?yes. Something like this.
config
BOARD_ENV_LOCATION
bool "Use board defined ENV location"
default y
...
Quoted 10 lines
if defined (BOARD_ENV_SETUP/LOCATION)
enumenv_locationenv_get_location(enum env_operation op, int prio){
...
}
endifM
This will be accepted by you in upstream?
Cheers,
Vasilis
Michal Simek
maintainerQuoted 53 lines · Vasileios Amoiridis
Quoted 52 lines · Michal Simek
Quoted 48 lines · Vasileios Amoiridis
Quoted 37 lines · Michal Simek
Hi Vasileios,
út 4. 6. 2024 v 15:21 odesílatel Vasileios Amoiridis <[email protected]> napsal:
Quoted 29 lines
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded
env_locations[]
code.
- Add implementation with general
arch_env_get_location(op,
prio)v1:
https://lore.kernel.org/u-boot/[email protected]/Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot
mediaboard/xilinx/versal-net/board.c | 47 ++++++++++++++---------- ---- board/xilinx/versal/board.c | 47 ++++++++++++++---------- ---- board/xilinx/zynq/board.c | 49 +++++++++++++++--------- ----- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++------- ----- ---- 4 files changed, 101 insertions(+), 97 deletions(-)Quoted 3 lines
--
2.34.1Quoted 7 lines
I have to remove this patch from my queue because it is actually breaking current behavior.
CI is reporting an issue with it and I did a closer look and what is
happening is that if one location has no valid
data it goes and looks at another location from the list.But that is the desired behavior, if the environment is not in one location to check to the others.
Quoted 8 lines
Quoted 5 lines
That's how u-boot is written but if device doesn't exist or not accessible by
u-boot it is clear that it shouldn't be used and then behavior is correct.Hmmm, how can a device be not-accessible by u-boot but u-boot still tries to use it? How could that happen?
That Xilinx virtual defconfig are setup in a way that all drivers are enabled via Kconfig but they are not present on all boards.
If you look below in defconfig we are have that variables can be in NAND but there is no NAND device on zc702 but still u-boot tries to reach nand and read variables from it.
Quoted 5 lines
Also, I think that this is a problem of the user, no? If for example you have configure
ENV_IS_IN_NANDbut there is no NAND device, then with the patch you get a visible error that U-Boot tries to access NAND which is not there.
For our platforms where you can burn boot.bin to any boot medium we had no choice that's why code was written like that that variables are saved all the time to boot medium. Also that I don't want to maintain other defconfigs for slightly different configurations.
On products customers should look at our all in one defconfig and disable things which are not needed. And where variables are saved is definitely one of them.
Quoted 10 lines
Quoted 5 lines
If device exists and simple varibles are not yet saved there going to different
device is IMHO problematic.Maybe I am still a bit confused, but I think that if you have defined
ENV_IS_IN_QSPIandENV_IS_IN_NANDbut the environment is not there then the behavior that we see is actually correct. U-Boot tries:
Quoted 5 lines
a) Get env from QSPI but fails because env is not there,
b) Get env from NAND but fails because NAND is not there,
c) Get env from nowhere.To me, this looks like the correct behavior. Isn't it?
This sequence is correct but what it is not correct is when you reach nowhere and you run saveenv you can't really save variables even they can be saved to QSPI. They can't be saved to NAND because it is not present on the board.
The issue is that none write initial variable to QSPI that's why there will be all the time bad CRC but location is correct.
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 15 lines
On Zynq it behaves like this.
MMC: mmc@e0100000: 0
prio 0
Loading Environment from SPIFlash... SF: Detected n25q128a13 with page
size 256 Bytes, erase size 64 KiB, total 16 MiB
*** Warning - bad CRC, using default environmentprio 1
Loading Environment from NAND... *** Error - No Valid Environment Area found
*** Warning - bad env area, using default environmentQuoted 8 lines
prio 2
Loading Environment from SPIFlash... *** Warning - bad CRC, using default environmentprio 3
Loading Environment from nowhere... OKThis is the message that we get as well when this patch is not added.
Quoted 8 lines
Quoted 4 lines
It means you are booting out of QSPI but qspi is not accessible by u- boot. Correct?
Well, we are booting from QSPI but environment is in eMMC. In our config, we have defined
ENV_IS_IN_FATandENV_IS_NOWHEREbut we have not definedENV_IS_IN_QSPI.
ok.
Quoted 34 lines
Quoted 25 lines
Quoted 25 lines
Quoted 24 lines
prio is my print to show where code is. Qemu boots out in QSPI boot
mode and SPI is tried first and because
this isxilinx_zynq_virtdefconfigdrivers/envlocations for other
devices are present too. That's why it goes over the list and it always ends in nowhere which never fails.If this runs on real HW then the same behavior is visible and I don't
think it is right.
I think this solution should be rethought.
In product current behavior from our code is not the best and current
U-Boot implementation is not allowing
flexibility too. We are enabling redundant variables which can be only
on the same device but not that you have
one copy in QSPI and second in EMMC.
That's why I think location should be pretty much read from DT. There is options/u-boot node where location of variables should be
described and this should replaceenv_get_location().Quoted 8 lines
Quoted 3 lines
You mean that there should be some type of new U-Boot node that describes where the environment should be located and go and search in this device?
Not sure if node or just dt property which points where that variables are stored.
Quoted 7 lines
This doesn't sound too difficult to do. Still, even if this was done, what would the priority be for looking for the environment? For now, the code is written in a way to check for the environment only in the bootmedia. My patch added a functionality that if the environment is not in the bootmedia to check somewhere else. This should be the order also if we had this u-boot node? Check first in the bootmedia and then check if there is a dt property?
I don't think this is going to be that simple. Especially to support redundant variables saved to two different devices.
Quoted 25 lines
Quoted 25 lines
Quoted 10 lines
Quoted 7 lines
It is a lot of work that's why I think second solution is more reasonable for you which is simply create new
Kconfigsymbol to disable boardenv_get_location()implementation.Thanks,
MichalYou mean to basically disable the board
env_get_location()that exists inboard/xilinx/zynqmp/zynqmp.cfor example?yes. Something like this.
config
BOARD_ENV_LOCATION
bool "Use board defined ENV location"
default y
...if defined (BOARD_ENV_SETUP/LOCATION)
enumenv_locationenv_get_location(enum env_operation op, int prio){
...
}
endif
Quoted 5 lines
Quoted 3 lines
M
This will be accepted by you in upstream?
I think it is reasonable compromise to pretty much disable bootmode media selection for storing variables.
Thanks,
Michal
Quoted 70 lines · Michal Simek
Quoted 67 lines · Vasileios Amoiridis
Quoted 65 lines · Michal Simek
Quoted 53 lines · Vasileios Amoiridis
Quoted 42 lines · Michal Simek
Hi Vasileios,
út 4. 6. 2024 v 15:21 odesílatel Vasileios Amoiridis <[email protected]> napsal:
Quoted 32 lines
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded env_locations[]
code.
- Add implementation with general arch_env_get_location(op,
prio)v1:
https://lore.kernel.org/u-boot/[email protected]/Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of boot
mediaboard/xilinx/versal-net/board.c | 47 ++++++++++++++-----
-----
----
board/xilinx/versal/board.c | 47 ++++++++++++++-----
-----
----
board/xilinx/zynq/board.c | 49 +++++++++++++++----
-----
-----
board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++--
-----
-----
----Quoted 5 lines
4 files changed, 101 insertions(+), 97 deletions(-)--
2.34.1Quoted 9 lines
I have to remove this patch from my queue because it is actually
breaking current behavior.
CI is reporting an issue with it and I did a closer look and what
is
happening is that if one location has no valid data it goes and looks at another location from the list.Quoted 3 lines
But that is the desired behavior, if the environment is not in one
location to check to the others.That's how u-boot is written but if device doesn't exist or not accessible by
u-boot it is clear that it shouldn't be used and then behavior is correct.
Quoted 6 lines
Quoted 2 lines
Hmmm, how can a device be not-accessible by u-boot but u-boot still tries to use it? How could that happen?
That Xilinx virtual defconfig are setup in a way that all drivers are enabled
viaKconfigbut they are not present on all boards.
Ok, now I understand how that happens.
Quoted 6 lines
If you look below in defconfig we are have that variables can be in NAND but
there is no NAND device on zc702 but still u-boot tries to reach nand and read
variables from it.
So, the ideal scenario would be to U-Boot never try to access the device? Because from what I see, is that since the device is not there, U-Boot throws an error, and moves on.
Quoted 7 lines
Quoted 6 lines
Also, I think that this is a problem of the user, no? If for example
you have configureENV_IS_IN_NANDbut there is no NAND device, then with the patch you get a visible error that U-Boot tries to access NAND which is not there.
Quoted 13 lines
For our platforms where you can burn boot.bin to any boot medium we had no
choice that's why code was written like that that variables are saved all the
time to boot medium.
Also that I don't want to maintain other defconfigs for slightly different
configurations.
On products customers should look at our all in one defconfig and disable things
which are not needed. And where variables are saved is definitely one of them.
Well, that makes sense.
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
If device exists and simple varibles are not yet saved there going to
different
device is IMHO problematic.Maybe I am still a bit confused, but I think that if you have defined
ENV_IS_IN_QSPIandENV_IS_IN_NANDbut the environment is not there then
the behavior that we see is actually correct. U-Boot tries:a) Get env from QSPI but fails because env is not there,
b) Get env from NAND but fails because NAND is not there,
c) Get env from nowhere.
Quoted 9 lines
Quoted 1 line
To me, this looks like the correct behavior. Isn't it?
This sequence is correct but what it is not correct is when you reach nowhere
and you run saveenv you can't really save variables even they can be saved to
QSPI. They can't be saved to NAND because it is not present on the board.
This can be solved by using the env_select command (cmd/nvedit.c) no?
Quoted 102 lines
The issue is that none write initial variable to QSPI that's why there will be
all the time bad CRC but location is correct.Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
On Zynq it behaves like this.
MMC: mmc@e0100000: 0
prio 0
Loading Environment from SPIFlash... SF: Detected n25q128a13 with
page
size 256 Bytes, erase size 64 KiB, total 16 MiB *** Warning - bad CRC, using default environmentprio 1
Loading Environment from NAND... *** Error - No Valid Environment
Area found
*** Warning - bad env area, using default environmentprio 2
Loading Environment from SPIFlash... *** Warning - bad CRC, using
default environmentprio 3
Loading Environment from nowhere... OKQuoted 8 lines
Quoted 2 lines
This is the message that we get as well when this patch is not added.
It means you are booting out of QSPI but qspi is not accessible by u-
boot. Correct?Quoted 4 lines
Well, we are booting from QSPI but environment is in eMMC. In our config, we have defined
ENV_IS_IN_FATandENV_IS_NOWHEREbut we have
not definedENV_IS_IN_QSPI.ok.
Quoted 39 lines
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines
prio is my print to show where code is. Qemu boots out in QSPI
boot
mode and SPI is tried first and because
this isxilinx_zynq_virtdefconfigdrivers/envlocations for other
devices are present too. That's why it goes over the list and it always ends in nowhere which never fails.If this runs on real HW then the same behavior is visible and I
don't
think it is right.
I think this solution should be rethought.
In product current behavior from our code is not the best and current
U-Boot implementation is not allowing
flexibility too. We are enabling redundant variables which can be
only
on the same device but not that you have
one copy in QSPI and second in EMMC.
That's why I think location should be pretty much read from DT.
There is options/u-boot node where location of variables should
be
described and this should replaceenv_get_location().Quoted 8 lines
Quoted 3 lines
You mean that there should be some type of new U-Boot node that describes where the environment should be located and go and search in this device?
Not sure if node or just dt property which points where that variables are stored.
Quoted 13 lines
This doesn't sound too difficult to do. Still, even if this was done,
what would the priority be for looking for the environment? For now,
the code is written in a way to check for the environment only in the
bootmedia. My patch added a functionality that if the environment is
not in the bootmedia to check somewhere else. This should be the order
also if we had this u-boot node? Check first in the bootmedia and then
check if there is a dt property?
Quoted 5 lines
I don't think this is going to be that simple. Especially to support redundant
variables saved to two different devices.
To my understanding, I think it is enough to have a dt property that says "emmc" or "nand" etc.. that can be read when the env_get_location() is executed and the correct env_location is selected. What am I missing that makes you think that it is not so trivial?
I don't have that much experience with the U-Boot sources themselves so my question might be stupid, I know.
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 11 lines
Quoted 8 lines
It is a lot of work that's why I think second solution is more
reasonable for you which is simply create newKconfigsymbol to disable boardenv_get_location()implementation.Thanks,
MichalYou mean to basically disable the board
env_get_location()that exists inboard/xilinx/zynqmp/zynqmp.cfor example?yes. Something like this.
config
BOARD_ENV_LOCATION
bool "Use board defined ENV location"
default y
...if defined (BOARD_ENV_SETUP/LOCATION)
enumenv_locationenv_get_location(enum env_operation op, int prio)
{
...
}
endifM
Quoted 8 lines
Quoted 1 line
This will be accepted by you in upstream?
I think it is reasonable compromise to pretty much disable bootmode media
selection for storing variables.Thanks,
Michal
Ok, I can submit a v3 then.
Cheers,
Vasilis
Michal Simek
maintainerQuoted 140 lines · Vasileios Amoiridis
Quoted 70 lines · Michal Simek
Quoted 67 lines · Vasileios Amoiridis
Quoted 65 lines · Michal Simek
Quoted 53 lines · Vasileios Amoiridis
Quoted 42 lines · Michal Simek
Hi Vasileios,
út 4. 6. 2024 v 15:21 odesílatel Vasileios Amoiridis <[email protected]> napsal:
Quoted 34 lines
From: Vasileios Amoiridis <[email protected]>
Changes in v2:
- Remove duplication of custom hardcoded
env_locations[]
code.
- Add implementation with general
arch_env_get_location(op,
prio)v1:
https://lore.kernel.org/u-boot/[email protected]/Vasileios Amoiridis (1):
xilinx: Add option to load environment from outside of
boot
mediaboard/xilinx/versal-net/board.c | 47 ++++++++++++++----- ----- ---- board/xilinx/versal/board.c | 47 ++++++++++++++----- ----- ---- board/xilinx/zynq/board.c | 49 +++++++++++++++---- ----- ----- board/xilinx/zynqmp/zynqmp.c | 55 +++++++++++++++++-- ----- ----- ---- 4 files changed, 101 insertions(+), 97 deletions(-)Quoted 3 lines
--
2.34.1Quoted 9 lines
I have to remove this patch from my queue because it is actually
breaking current behavior.
CI is reporting an issue with it and I did a closer look and what
is
happening is that if one location has no valid data it goes and looks at another location from the list.Quoted 3 lines
But that is the desired behavior, if the environment is not in one
location to check to the others.That's how u-boot is written but if device doesn't exist or not accessible by
u-boot it is clear that it shouldn't be used and then behavior is correct.Quoted 6 lines
Quoted 2 lines
Hmmm, how can a device be not-accessible by u-boot but u-boot still tries to use it? How could that happen?
That Xilinx virtual defconfig are setup in a way that all drivers are enabled
viaKconfigbut they are not present on all boards.Ok, now I understand how that happens.
Quoted 6 lines
If you look below in defconfig we are have that variables can be in NAND but
there is no NAND device on zc702 but still u-boot tries to reach nand and read
variables from it.So, the ideal scenario would be to U-Boot never try to access the device? Because from what I see, is that since the device is not there, U-Boot throws an error, and moves on.
Quoted 7 lines
Quoted 6 lines
Also, I think that this is a problem of the user, no? If for example
you have configureENV_IS_IN_NANDbut there is no NAND device, then with the patch you get a visible error that U-Boot tries to access NAND which is not there.Quoted 13 lines
For our platforms where you can burn boot.bin to any boot medium we had no
choice that's why code was written like that that variables are saved all the
time to boot medium.
Also that I don't want to maintain other defconfigs for slightly different
configurations.
On products customers should look at our all in one defconfig and disable things
which are not needed. And where variables are saved is definitely one of them.Well, that makes sense.
Quoted 17 lines
Quoted 17 lines
Quoted 6 lines
If device exists and simple varibles are not yet saved there going to
different
device is IMHO problematic.Maybe I am still a bit confused, but I think that if you have defined
ENV_IS_IN_QSPIandENV_IS_IN_NANDbut the environment is not there then
the behavior that we see is actually correct. U-Boot tries:a) Get env from QSPI but fails because env is not there,
b) Get env from NAND but fails because NAND is not there,
c) Get env from nowhere.Quoted 9 lines
Quoted 1 line
To me, this looks like the correct behavior. Isn't it?
This sequence is correct but what it is not correct is when you reach nowhere
and you run saveenv you can't really save variables even they can be saved to
QSPI. They can't be saved to NAND because it is not present on the board.
Quoted 1 line
This can be solved by using the
env_selectcommand (cmd/nvedit.c) no?
I looked at it and it is interesting option.
We don't have it enabled by default (and maybe should be enabled). CI test is not handling it too.
Love: can you please take a look at it?
Quoted 108 lines
Quoted 102 lines
The issue is that none write initial variable to QSPI that's why there will be
all the time bad CRC but location is correct.Quoted 36 lines
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
On Zynq it behaves like this.
MMC: mmc@e0100000: 0
prio 0
Loading Environment from SPIFlash... SF: Detected n25q128a13 with
page
size 256 Bytes, erase size 64 KiB, total 16 MiB *** Warning - bad CRC, using default environmentprio 1
Loading Environment from NAND... *** Error - No Valid Environment
Area found
*** Warning - bad env area, using default environmentprio 2
Loading Environment from SPIFlash... *** Warning - bad CRC, using
default environmentprio 3
Loading Environment from nowhere... OKQuoted 8 lines
Quoted 2 lines
This is the message that we get as well when this patch is not added.
It means you are booting out of QSPI but qspi is not accessible by u-
boot. Correct?Quoted 4 lines
Well, we are booting from QSPI but environment is in eMMC. In our config, we have defined
ENV_IS_IN_FATandENV_IS_NOWHEREbut we have
not definedENV_IS_IN_QSPI.ok.
Quoted 39 lines
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines
prio is my print to show where code is. Qemu boots out in QSPI
boot
mode and SPI is tried first and because
this isxilinx_zynq_virtdefconfigdrivers/envlocations for other
devices are present too. That's why it goes over the list and it always ends in nowhere which never fails.If this runs on real HW then the same behavior is visible and I
don't
think it is right.
I think this solution should be rethought.
In product current behavior from our code is not the best and current
U-Boot implementation is not allowing
flexibility too. We are enabling redundant variables which can be
only
on the same device but not that you have
one copy in QSPI and second in EMMC.
That's why I think location should be pretty much read from DT.
There is options/u-boot node where location of variables should
be
described and this should replaceenv_get_location().Quoted 8 lines
Quoted 3 lines
You mean that there should be some type of new U-Boot node that describes where the environment should be located and go and search in this device?
Not sure if node or just dt property which points where that variables are stored.
Quoted 13 lines
This doesn't sound too difficult to do. Still, even if this was done,
what would the priority be for looking for the environment? For now,
the code is written in a way to check for the environment only in the
bootmedia. My patch added a functionality that if the environment is
not in the bootmedia to check somewhere else. This should be the order
also if we had this u-boot node? Check first in the bootmedia and then
check if there is a dt property?Quoted 5 lines
I don't think this is going to be that simple. Especially to support redundant
variables saved to two different devices.
Quoted 8 lines
To my understanding, I think it is enough to have a dt property that says "emmc" or "nand" etc.. that can be read when the
env_get_location()is executed and the correctenv_locationis selected. What am I missing that makes you think that it is not so trivial?I don't have that much experience with the U-Boot sources themselves so my question might be stupid, I know.
To do it generic it is not just about saying qspi. It is also necessary to say where exactly it is for both copies no to be hardcoded via Kconfig.
Something like this.
options {
u-boot {
compatible = "u-boot,config";
env = <&qspi base size>, <&qspi base_redunt size_redunt>;
};
};above description should work properly for raw based devices.
Then there are MTD based devices where description can be like this env = <&mtd_qspi_1>, <&mtd_qspi_2>;
or
env = "partition_name1", "partition_name2";
And also filesystem based
env = <&sdhci 1>, <&sdhci 2>; // controller + partition ID or GUID.
And I think you should be able to define for example this
env = <&sdhci 1>, <&qspi base size>, <&mtd_qspi_1>;
Which means 3 locations for variables which should have the same content.
For doing it you need to touch all files in env/ folder and change the code around CONFIG_SYS_REDUNDAND_ENVIRONMENT.
Thanks,
Michal