Hilink Mt7621A HLK-7621 router u-boot environment dump problem

Hi i am currently working on Hilink-mt7621a dev board with latest snapshot image

SERIAL NOR FLASH : W25Q256JVFQ

I am trying to get uboot env variables with fw_printenv command doing this:

DMESG log:

[    1.241326] 0x000000000000-0x000000030000 : "u-boot"
[    1.252901] 0x000000030000-0x000000040000 : "u-boot-env"
[    1.264433] 0x000000040000-0x000000050000 : "factory"
[    1.275500] 0x000000050000-0x000002000000 : "firmware"

cat /proc/mtd

root@OpenWrt:~# 
dev:    size   erasesize  name
mtd0: 00030000 00010000 "u-boot"
mtd1: 00010000 00010000 "u-boot-env"
mtd2: 00010000 00010000 "factory"
mtd3: 01fb0000 00010000 "firmware"
mtd4: 002b9fc5 00010000 "kernel"
mtd5: 01cf603b 00010000 "rootfs"
mtd6: 019b0000 00010000 "rootfs_data"

opkg install uboot-envtools

and wrote shown below to /etc/fw_env.config

# MTD device name       Device offset   Env. size       
 /dev/mtd1               0x30000          0x10000    

and then i run this command "fw_printenv"
it returned wrong uboot env variables
like show below.

root@OpenWrt:~# fw_printenv 
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200

but it must return like this :

bootcmd=tftpbootdelay=5baudrate=57600ethaddr="03:17:73:AB:CD:EF"ethact=Eth0 (10/100-M)serial#=123456789astdin=serialstdout=serialstderr=serialipaddr=192.168.16.123serverip=192.168.16.112bootfile=7621_son.b
ibinstdin=serialstdout=serialstderr=serialipaddr=192.168.16.123serverip=192.168.16.112

So How can i get correct env variables? thanks for any help..

First, using the serial port, check that your installed u-boot actually saves and recalls to flash. A lot of routers have a hacked u-boot that always runs defaults.

I think the variables are stored as simple text, so hexdumps of the partition can be useful to see what is stored.

1 Like

Thanks.

I have created serial# variable and save with a value to uboot env it saved to flash successfully
printenv command returned serial# variable it is all okey

#dumping env part
root@OpenWrt:~# cat /dev/mtd1 > /tmp/u-boot-env.bin

#reading env
root@OpenWrt:~# cat /tmp/u-boot-env.bin 

���bootcmd=tftpbootdelay=5baudrate=57600ethaddr="03:17:73:AB:CD:EF"ethact=Eth0 (10/100-M)serial#=123456789astdin=serialstdout=serialstderr=serialipaddr=192.168.16.123���serverip=192.168.16.112bootfile=7621_son.b
ibinstdin=serialstdout=serialstderr=serialipaddr=192.168.16.123���serverip=192.168.16.112�����������������������������������������������
�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

I can read like shown above but i am seeking for more efficient way.
How can i get ethaddr value and set ?

why you not check this from source code, if you have.

Could you help some at this point?
i suspect fw_env.config
is this fw_env.config correct for reading env?

/etc/fw_env.config

# MTD device name       Device offset   Env. size       
 /dev/mtd1               0x30000          0x10000   

I donot have the device. Most of the info, you could get it in source code.

IIRC Default env size is 0x1000. At least in Ralink/Mediatek version of u-boot.

1 Like

thank you i solved with env size 0x1000

root@OpenWrt:~# cat /etc/fw_env.config 
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd1               0x0000          0x1000  
#/dev/mtd2              0x0000          0x4000          0x4000
root@OpenWrt:~# 

root@OpenWrt:~# fw_printenv 
bootcmd=tftp
bootdelay=5
baudrate=57600
ethaddr="XX:XX:XX:YY:YY:YY"
ethact=Eth0 (10/100-M)
serial#=123456789a
stdin=serial
stdout=serial
stderr=serial
ipaddr=192.168.16.123
serverip=192.168.16.112
bootfile=7621.bin
root@OpenWrt:~# 

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.