u-boot-qoriq build for LS1046ARDB is not using the right environment

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

u-boot-qoriq build for LS1046ARDB is not using the right environment

1,497 Views
srechermann
Contributor III

I'm building u-boot from source like described here. https://community.nxp.com/t5/Layerscape-Knowledge-Base/LS1046ARDB-How-to-update-U-Boot-binary-on-SD-...
additionally I'm editing the ~/dev/u-boot/configs/ls1046ardb_sdcard_defconfig file I'm using for the build by changing the bootdelay to CONFIG_BOOTDELAY=8 and by adding these to lines as I would like to have a custom bootcmd:
CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="setenv kerneladdr 0x80000000;setenv fdtaddr 0x90000000;setenv ramdiskaddr 0xa0000000;mmc read ${fdtaddr} 0x4840 0x3d;mmc read ${kerneladdr} 0x487d 0x15651;mmc read ${ramdiskaddr} 0x19ece 0x6d41;setenv bootargs console=ttyS0,115200 root=/dev/ram0 rw rootdelay=5;booti ${kerneladdr} ${ramdiskaddr} ${fdtaddr}"

I verified that after the make ls1046ardb_tfa_defconfig command, the changes I made to the ls1046ardb_tfa_defconfig are in the .config file.

git clone https://source.codeaurora.org/external/qoriq/qoriq-components/u-boot.git
cd u-boot
git checkout 1c881f4da83cc05bee50f352fa183263d7e2622b # version 2022.04
# edit ls1046ardb_tfa_defconfig in source code
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make distclean
make ls1046ardb_tfa_defconfig
make

 

Afterwards I'm building the rcw from source:

git clone git@code.rsint.net:mirror/source.codeaurora.org/external/qoriq/qoriq-components/rcw.git
git checkout a4db86818de35d0168a48d3f17878ec68fb1cf6d
cd rcw
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make BOARDS=ls1046ardb

 And bundel everything together using the atf repository:

git clone https://github.com/nxp-qoriq/atf.git
cd atf
git checkout c6a19b1a351308cc73443283f6aa56b2eff791b8
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make V=1 all fip pbl  PLAT=ls1046ardb BOOT_MODE=sd RCW=~/dev/rcw/ls1046ardb/RR_FFSSPPPH_1133_5559/rcw_1800_sdboot.bin BL33=~/dev/u-boot/u-boot.bin

In the last step I'm adding writing the bootloaders to my SD card:

cd ~/dev/atf
sudo dd if=build/ls1046ardb/release/bl2_sd.pbl of=/dev/sdb seek=8 bs=512
sudo dd if=build/ls1046ardb/release/fip.bin of=/dev/sdb seek=2048 bs=512

When I boot my board I get a warning: "Warning - bad CRC, using default " and the CONFIG_BOOTCOMMAND I added is not in the environment, but the changes bootdelay in in the environment. After executing env default -a the bootcmd I added is present in the environment.

NOTICE:  UDIMM 18ADF2G72AZ-2G6E1

NOTICE:  16 GB DDR4, 64-bit, CL=15, ECC on, CS0+CS1
NOTICE:  BL2: v2.6(release):lf-5.15.32-2.0.0-0-gc6a19b1a3
NOTICE:  BL2: Built : 10:59:10, Mar 30 2023
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.6(release):lf-5.15.32-2.0.0-0-gc6a19b1a3
NOTICE:  BL31: Built : 10:59:12, Mar 30 2023
NOTICE:  Welcome to ls1046ardb BL31 Phase


U-Boot 2022.04-dirty (Mar 30 2023 - 10:35:14 +0200)

SoC:  LS1046AE Rev1.0 (0x87070010)
Clock Configuration:
       CPU0(A72):1800 MHz  CPU1(A72):1800 MHz  CPU2(A72):1800 MHz
       CPU3(A72):1800 MHz
       Bus:      600  MHz  DDR:      2100 MT/s  FMAN:     700  MHz
Reset Configuration Word (RCW):
       00000000: 0c150012 0e000000 00000000 00000000
       00000010: 11335559 40005012 60040000 c1000000
       00000020: 00000000 00000000 00000000 00238800
       00000030: 20124000 00003101 00000096 00000001
Model: LS1046A RDB Board
Board: LS1046ARDB, boot from SD
CPLD:  V2.3
PCBA:  V3.0
SERDES Reference Clocks:
SD1_CLK1 = 156.25MHZ, SD1_CLK2 = 100.00MHZ
DRAM:  15.9 GiB (DDR4, 64-bit, CL=15, ECC on)
       DDR Chip-Select Interleaving Mode: CS0+CS1
Using SERDES1 Protocol: 4403 (0x1133)
Using SERDES2 Protocol: 21849 (0x5559)
PCIe1: pcie@3400000 Root Complex: no link
PCIe2: pcie@3500000 Root Complex: no link
PCIe3: pcie@3600000 Root Complex: no link
Core:  46 devices, 16 uclasses, devicetree: separate
NAND:  512 MiB
MMC:   FSL_SDHC: 0
Loading Environment from MMC... *** Warning - bad CRC, using default environment

EEPROM: NXID v1
In:    serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
Net:
MMC read: dev # 0, block # 18432, count 128 ...
Fman1: Uploading microcode version 106.4.18
eth0: fm1-mac3, eth1: fm1-mac4, eth2: fm1-mac5, eth3: fm1-mac6, eth4: fm1-mac9, eth5: fm1-mac10
Hit any key to stop autoboot:  0
=> printenv bootdelay
bootdelay=8
=> printenv bootcmd
bootcmd=run distro_bootcmd;run sd_bootcmd; env exists secureboot && esbc_halt;
=> env default -a
## Resetting to default environment
=> print bootdelay
bootdelay=8
=> printenv bootcmd
bootcmd=setenv kerneladdr 0x80000000;setenv fdtaddr 0x90000000;setenv ramdiskaddr 0xa0000000;mmc read ${fdtaddr} 0x4840 0x3d;mmc read ${kerneladdr} 0x487d 0x15651;mmc read ${ramdiskaddr} 0x19ece 0x6d41;setenv bootargs console=ttyS0,115200 root=/dev/ram0 rw rootdelay=5;booti ${kerneladdr} ${ramdiskaddr} ${fdtaddr}

 I added a file containing the two environments before and after the env default -a command.

Why is it behaving like that? From which config file/environment does the run distro_bootcmd;run sd_bootcmd; env exists secureboot && esbc_halt; come and what are these two environments in general? What's the correct way to change the bootcmd so that it appears in the initial environment? Why do I get this warning: Warning - bad CRC, using default? This also occures when I don't do any changes to the ls1046ardb_tfa_defconfig so I guess it's not related to the issue I'm facing

0 Kudos
Reply
7 Replies

1,475 Views
srechermann
Contributor III

Adding CONFIG_ENV_IS_NOWHERE=y removes the bad CRC warning:

Loading Environment from nowhere... OK

But the behavior regarding the environment(s) is still exactly the same. I thought that CONFIG_ENV_IS_NOWHERE=y forces the uboot to use it's environment compiled into the binary. But there are two environments in the binary. I can't find where the one that's used by default before running env default -a comes from. The bootcmd=run distro_bootcmd;run sd_bootcmd; env exists secureboot && esbc_halt; is nowhere defined in the uboot source code. I expected it in the #define CONFIG_EXTRA_ENV_SETTINGS in the ~/dev/u-boot/include/configs/ls1046a_common.h file but it's not there.

0 Kudos
Reply

1,467 Views
srechermann
Contributor III

In the soc.c file there is the function fsl_setenv_bootcmd that seems to override the bootcmd. So uncommenting the call of this function fixes it for me.

diff --git a/soc.c b/soc_patched.c
index 12feaf0..f94f244 100755
--- a/soc.c
+++ b/soc_patched.c
@@ -966,7 +966,7 @@ int board_late_init(void)
         */
        if (env_get_yesno("fsl_bootcmd_mcinitcmd_set") <= 0) {
                // Set bootcmd and mcinitcmd as per boot source
-               fsl_setenv_bootcmd();
+               // fsl_setenv_bootcmd();
                fsl_setenv_mcinitcmd();
                env_set("fsl_bootcmd_mcinitcmd_set", "y");
        }

But I still don't understand what env default -a is exactly doing? For example the following environment fields are gone after executing the command

eth1addr=00:04:9F:07:74:32
eth2addr=00:04:9F:07:74:2D
eth3addr=00:04:9F:07:74:2E
eth4addr=00:04:9F:07:74:30
eth5addr=00:04:9F:07:74:2F
ethaddr=00:04:9F:07:74:31

 

0 Kudos
Reply

1,411 Views
khushbur
NXP TechSupport
NXP TechSupport

Hi @srechermann 

 

env default -a commands reset environment variables to their default values. ethaddr variables are gone because it wasn't set by default.

 

Thanks

Khushbu

 

0 Kudos
Reply

1,406 Views
srechermann
Contributor III

Hi @khushbur ,
thanks for the response. So there is a default environment compiled into the binary and the default environment variables have values set somewhere and default values defined somewhere? I'm still confused. The values defined in the .config files seem to configure the "default environment", so this one:

Loading Environment from MMC... *** Warning - bad CRC, using default environment

And the default environment default values that are loaded when running "env default -a" I think so as: 1. the bootdelay im configuring in the .config appears in the default environment. 2. The bootcmd I also defined in the .config get's overriden by the function "fsl_setenv_bootcmd()" I mentionend but it's appearing after running "env default -a".  So it is the default value. So 1. suggests that .config configures the default environment and 2. suggests that .config configures the default values of the default environment. But where is the exact difference between the default environment and it's default values? Are all the values that dissappear or differ after running "env default -a" hardcoded in the u-boot source code like the bootcmd?

0 Kudos
Reply

1,377 Views
khushbur
NXP TechSupport
NXP TechSupport

Hi @srechermann 

 

Default environment value can be defined in uboot/include/configs/ls1046a_common.h and  uboot/include/configs/ls1046ardb.h

 

 

Are all the values that dissappear or differ after running "env default -a" hardcoded in the u-boot source code like the bootcmd?

 

Yes all the variable will reset to their default value.

 

Loading Environment from MMC... *** Warning - bad CRC, using default environment

This should resolved by running below commands on uboot consol.

saveenv

rest

 

Thanks

Khushbu

 

0 Kudos
Reply

1,323 Views
srechermann
Contributor III

Hi @khushbur ,

I guess saveenv + rest is saving the default environment, that was loaded before, to the MMC right? But if I don't want to change the uboot env in the uboot prompt or type anything in the uboot prompt(what I don't want) it may be the cleaner solution to set CONFIG_ENV_IS_NOWHERE=y or am I wrong here? There problem with this solution is that the autoboot is disabled when the NOWHERE/default env is used. I would like uboot to autoboot. I guess patching the u-boot source code to enable autoboot from the default/NOWHERE environment might be another ugly workaround that would work to archieve this.

I think the cleanest solution would be to use a working environment from MMC. So wouldn't it be possible to compile the u-boot somehow so that the configs defined in .config are in the included in the u-boot.bin file and getting recognized as a valid MMC env without bad CRC? It would also be fine to have a seperate env file, that I can write to SD card block 0x02800 as described in the flash layout ( https://community.nxp.com/t5/Layerscape-Knowledge-Base/Flash-layout-for-new-boot-flow-with-TF-A/ta-... ) if there is an option to get such a file when compiling the u-boot? I tried the following:

 

 

cd u-boot
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make ls1046ardb_tfa_defconfig
make u-boot-initial-env
# copy u-boot to sd block 0x2800
sudo dd if=u-boot-initial-env of=/dev/sdb bs=512 seek=10240

 

 

But this does not work. I still get the bad CRC warning and the default env is used.

EDIT:

I found out that I have to compile the u-boot-initial-env like this before deploying it to the SD card:

 

 

mkenvimage -s 8192 -o env_blob u-boot-initial-env
sudo dd if=env_blob of=/dev/sdb bs=512 seek=10240​

 

 

This works but I still have the problem that I end up in the u-boot prompt after the bootdelay has expired and I have to type in "boot" and press enter to run the bootcmd. In my .config the autoboot is set CONFIG_AUTOBOOT=y. Do I need to set some other config?

EDIT:

Adding "boot" to the bootcmd solved it. I don't really know why as in my opinion the booti cmd at the and of my bootcmd should start the kernel boot. However it works know as I want using the following bootcmd:

CONFIG_BOOTCOMMAND="setenv kerneladdr 0x80000000;setenv fdtaddr 0x90000000;setenv ramdiskaddr 0xa0000000;mmc read ${fdtaddr} 0x4840 0x3d;mmc read ${kerneladdr} 0x487d 0x15651;mmc read ${ramdiskaddr} 0x19ece 0x6d41;setenv bootargs console=ttyS0,115200 root=/dev/ram0 rw rootdelay=5;booti ${kerneladdr} ${ramdiskaddr} ${fdtaddr};boot"

0 Kudos
Reply

1,298 Views
khushbur
NXP TechSupport
NXP TechSupport

Hi @srechermann 

 

Can you please share a boot logs and output of prientenv commands.

if you set CONFIG_ENV_IS_NOWHERE=y it will not save env variables to MMC

 

Thanks

Khushbu

0 Kudos
Reply