Hi,
On 6/27/22 05:01, David Antliff wrote:
Hi,
I'm having some difficulty configuring U-Boot, in particular setting it up so
that it can load from an SD card,
but access its Environment from QSPI Flash.
First of all, is this even possible? Can the U-Boot environment be stored in a
different location from where
U-Boot was loaded?
Currently, I have a U-Boot image running from QSPI Flash on a Xilinx MPSoC
ARM64 platform. I'm using Xilinx
PetaLinux however I think I understand how this configures U-Boot "under the
hood" so I'll try to refer to
uboot.cfg as much as I can.
Along with all the defaults, I have set:
#define CONFIG_ENV_OFFSET 0x2E00000
#define CONFIG_ENV_OVERWRITE 1
#define CONFIG_CMD_ERASEENV 1
On this particular platform, there is a physical switch to switch the Xilinx
first-stage bootloader (and ARM
Trusted Firmware) between QSPI Flash to SD card. This platform also requires a so-called
"BOOT.BIN", which
contains the u-boot binary and other things (like the Xilinx FSBL, ARM Trusted
Firmware, an FPGA image and
other things), to be written to QSPI Flash, which I have done. This is all
working correctly, and the serial console
looks like this:
Xilinx Zynq MP First Stage Boot Loader
Release 2021.2 Oct 13 2021 - 07:15:53
NOTICE: BL31: v2.4(release):xlnx_rebase_v2.4_2021.1_update1-23-g9188496b9
NOTICE: BL31: Built : 07:41:24, Oct 13 2021
U-Boot 2021.01 (Oct 12 2021 - 09:28:42 +0000)
CPU: ZynqMP
Silicon: v3
Model: ZynqMP ZCU208 RevA
Board: Xilinx ZynqMP
DRAM: 4 GiB
PMUFW: v1.1
EL Level: EL2
Chip ID: zu48dr
NAND: 0 MiB
MMC: mmc@ff170000: 0
Loading Environment from SPIFlash... SF: Detected mt25qu02g with page size 512
Bytes, erase size 128 KiB, total 512 MiB
...
As you can see, U-Boot loads from QSPI Flash and the Environment is also loaded
from QSPI Flash. All good.
What I want to do is modify the system so that the earlier bootloader "BL31"
loads U-Boot from the SD card. In my config I
already have CONFIG_ENV_IS_IN_FAT set to 1. When I copy BOOT.BIN to the first,
FAT partition on an SD card, and set my
platform's boot mode to "SD Card" via the physical switch, the unit loads
U-Boot from the SD card successfully, and the
serial console shows the above but with:
Loading Environment from FAT... *** Warning - bad CRC, using default environment
It works, although this warning is expected because there is no Environment
saved on the SD card yet.
It does show that the SD card is being checked for the Environment though, so
that's good.
Note that this is the same build that I used for the QSPI flash boot earlier,
so I'm currently under the impression that
U-Boot only looks for its Environment based on where it was loaded from, even
if other locations are enabled.
The issue is that I would like to configure U-Boot to be loaded from the SD
card, but to use QSPI for its Environment,
so that we can store persistent U-Boot configuration on the board itself.
Experimentally, it appears that U-Boot uses the
medium it was loaded from as the place to look for its Environment, although I
haven't been able to confirm this.
According to the U-Boot documentation I've read, disabling FAT as the default
should be achievable by unsetting the
following in u-boot.cfg:
CONFIG_ENV_IS_IN_FAT
CONFIG_SYS_MMC_ENV_DEV
CONFIG_ENV_FAT_DEVICE_AND_PART
CONFIG_ENV_IS_IN_FAT
CONFIG_ENV_FAT_FILE
CONFIG_SYS_MMC_ENV_PART
CONFIG_ENV_FAT_INTERFACE
Performing the same installation steps as above, to have this new U-Boot loaded
from the SD card, results in the
following output:
Xilinx Zynq MP First Stage Boot Loader
Release 2021.2 Oct 13 2021 - 07:15:53
NOTICE: BL31: v2.4(release):xlnx_rebase_v2.4_2021.1_update1-23-g9188496b9
NOTICE: BL31: Built : 07:41:24, Oct 13 2021
And that's it! No more output. There is an LED on the board that goes from red
to green, which I think indicates that
the FPGA image within BOOT.BIN has been loaded into the gate array
successfully, so I think the earlier boot loader
has found BOOT.BIN. I have no reason therefore to think that U-Boot has not
also been loaded, but if it has, it is
generating no output. I tried increasing the debug level of U-Boot to 7 (DEBUG)
in the hope of seeing something
from U-Boot, but that makes no difference. It's also not booting Linux, which
would normally happen next.
Can anyone shed any light on why making this change might result in this
behaviour? Is there some other
configuration option I need to set to ensure that U-Boot can run from the SD
card when CONFIG_ENV_IS_IN_FAT
and friends are not set? Or perhaps I can keep CONFIG_ENV_IS_IN_FAT etc. and
there's some other way to instruct
U-Boot to use the QSPI Flash for its environment, even though it was loaded
from SD card?
There are couple of things here. You are saying you want to U-Boot to be loaded
from SD card. But FSBL you are using don't support this mode. It only supports
that boot.bin has all binaries you want FSBL to load.
The second part where u-boot has it's own environment variables stores. By
default as you properly described it is reading variables from location which
corresponds with boot mode.
This is directed by
https://source.denx.de/u-boot/u-boot/-/blob/master/board/xilinx/zynqmp/zynqmp.c#L850
That's why if you want to change this setting you can simply return location you
like. If it is FAT just simply change it to return ENVL_FAT.
We have been discussing this in past that would be the best to have better way
how to configure it but none has found a time to implement it yet.
Thanks,
Michal
--
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