Access U-boot env variables in LS1046ARDB Linux user space

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

Access U-boot env variables in LS1046ARDB Linux user space

Jump to solution
1,985 Views
sheikfaaruk
Contributor III

I am working with LS1046ARDB Evaluation Board to develop a network based application. I have started my project with Flex-builder(flexbuild_lsdk2108), Flex-installer(version: 1.13.2108) and Codewarrior IDE.

I have download the images from https://lsdk.github.io/components.html
boot_LS -> wget https://www.nxp.com/lgfiles/sdk/lsdk2108/boot_LS_arm64_lts_5.10.tgz
firmware image -> wget https://www.nxp.com/lgfiles/sdk/lsdk2108/firmware_ls1046ardb_sdboot.img
Rootfs -> wget https://www.nxp.com/lgfiles/sdk/lsdk2108/rootfs_lsdk2108_ubuntu_main_arm64.tgz

I have depolyed the image's in SD card through flex-installer:

$ flex-installer -i pf -d /dev/sdx (partition and format the target storage device)
$ sudo flex-installer -b boot_LS_arm64_lts_5.10.tgz -r rootfs_lsdk2108_ubuntu_main_arm64.tgz -f firmware_ls1046ardb_sdboot.img -d /dev/sdx

I have booted the board using SD card

u-boot log :

NOTICE: UDIMM 18ASF2G72AZ-2G6D1

NOTICE: 16 GB DDR4, 64-bit, CL=15, ECC on, CS0+CS1
NOTICE: BL2: v2.4(release):LSDK-21.08-0-g340b20bcb
NOTICE: BL2: Built : 12:17:37, Jul 1 2022
NOTICE: BL2: Booting BL31
NOTICE: BL31: v2.4(release):LSDK-21.08-0-g340b20bcb
NOTICE: BL31: Built : 12:17:44, Jul 1 2022
NOTICE: Welcome to ls1046ardb BL31 Phase


U-Boot 2021.04 (Jul 01 2022 - 12:17:22 +0530)

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: V2.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)
NAND: 512 MiB
MMC: FSL_SDHC: 0
Loading Environment from MMC... OK
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

I attached the printenv output stored in printenv.log file which in u-boot

root@localhost:/home/user# ll /dev/mtd*
crw------- 1 root root 90, 0 Sep 19 10:17 /dev/mtd0
crw------- 1 root root 90, 1 Sep 19 10:17 /dev/mtd0ro
crw------- 1 root root 90, 2 Sep 19 10:17 /dev/mtd1
crw------- 1 root root 90, 3 Sep 19 10:17 /dev/mtd1ro
crw------- 1 root root 90, 4 Sep 19 10:17 /dev/mtd2
crw------- 1 root root 90, 5 Sep 19 10:17 /dev/mtd2ro
brw-rw---- 1 root disk 31, 0 Sep 19 10:17 /dev/mtdblock0
brw-rw---- 1 root disk 31, 1 Sep 19 10:17 /dev/mtdblock1
brw-rw---- 1 root disk 31, 2 Sep 19 10:17 /dev/mtdblock2

root@localhost:/home/user# ll /dev/mmcblk*
brw-rw---- 1 root disk 179, 0 Sep 19 10:17 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 Sep 19 10:17 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Sep 19 10:17 /dev/mmcblk0p2
brw-rw---- 1 root disk 179, 3 Sep 19 10:17 /dev/mmcblk0p3
brw-rw---- 1 root disk 179, 4 Sep 19 10:17 /dev/mmcblk0p4

root@localhost:/home/user# cat /proc/mtd
dev: size erasesize name
mtd0: 20000000 00040000 "7e800000.flash"
mtd1: 04000000 00040000 "1550000.spi-0"
mtd2: 04000000 00040000 "1550000.spi-1"

My requirement is to update the u-boot variables through linux userspace, according to above bootlog i have flashed the image in SD card and booted the board through SD card option. U-boot environment is also store and read from SD(MMC).

I refered the following files to find SD card env offset, env size to update /etc/fw_env.config for fw_printenv and fw_setenv.

<flex-builder-root-dir>/components/firmware/uboot/configs/ls1046ardb_sdcard_defconfig
<flex-builder-root-dir>/docs/memory_layout.txt
<flex-builder-root-dir>/components/firmware/uboot/tools/env/fw_env.config
<flex-builder-root-dir>/components/firmware/uboot/tools/env/README

I have update the ENV_OFFSET & ENV_SIZE in fw_env.config in /etc according to above files.

root@localhost:~# fw_printenv -c /etc/fw_env.config
Environment WRONG, copy 0
Cannot read environment, using default
Cannot read default environment from file

After running fw_printenv, it shows cannot read environment. It sounds like i'm looking in wrong address space, can you guide me to find the correct offset and size?

 

Thanks In advance 

0 Kudos
Reply
1 Solution
1,958 Views
yipingwang
NXP TechSupport
NXP TechSupport
According to the following definition in configs/ls1046ardb_tfa_defconfig. CONFIG_ENV_SIZE=0x2000 CONFIG_ENV_OFFSET=0x500000 CONFIG_ENV_SECT_SIZE=0x40000 In Linux, please configure /etc/fw_env.config as the following. # device name Device offset Env. size Flash sector size /dev/mmcblk0 0x500000 0x2000

View solution in original post

0 Kudos
Reply
1 Reply
1,959 Views
yipingwang
NXP TechSupport
NXP TechSupport
According to the following definition in configs/ls1046ardb_tfa_defconfig. CONFIG_ENV_SIZE=0x2000 CONFIG_ENV_OFFSET=0x500000 CONFIG_ENV_SECT_SIZE=0x40000 In Linux, please configure /etc/fw_env.config as the following. # device name Device offset Env. size Flash sector size /dev/mmcblk0 0x500000 0x2000
0 Kudos
Reply