Friday, 31 May 2019

u-boot-tools-for-debian-arm-linux-in-qnap-server

Here is a small note on how to install U-Boot tools to manage boot loader from linux environment. This will provide a tool for printing environment for the bootloader U-Boot (fw_printenv) and modifying the same (fw_setenv).
1. Install the necessary U-Boot support packages
# apt-get install u-boot uboot-envtools
You can find your MTD partition information in /proc/mtd file as shown below.
# cat /proc/mtd
dev: size erasesize name
mtd0: 00080000 00040000 “U-Boot”
mtd1: 00200000 00040000 “Kernel”
mtd2: 00900000 00040000 “RootFS1”
mtd3: 00300000 00040000 “RootFS2”
mtd4: 00040000 00040000 “U-Boot Config”
mtd5: 00140000 00040000 “NAS Config”
2. Create a configuration file /etc/fw_env.config for U-boot environment in the machine. In my case it is QNAP TS-110 Home Server. Here is the configuration file.
# Configuration file for fw_(printenv/saveenv) utility for
# QNAP TS-119, TS-219 and TS-219P.
# MTD device name Device offset Env. size Flash sector size
/dev/mtd4 0x0000 0x1000 0x40000
You have good chances of getting fw_env.config file for your machine in /usr/share/doc/uboot-envtools/examples (installed by uboot-envtools).
In case you don’t have the above file, you will end up with the following error message while issuing the fw_printenv command.
# fw_printenv
Cannot parse config file: No such file or directory
As an another error case, if you have wrong configuration file it will throw the following error message.
# 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
Here is the output of fw_printenv command in my server.
# fw_printenv  
baudrate=115200
loads_echo=0
rootpath=/mnt/ARM_FS/
console=console=ttyS0,115200 mtdparts=cfi_flash:0xf40000(root),0xc0000(uboot)ro
CASset=min
MALLOC_len=1
ethprime=egiga0
bootargs_root=root=/dev/nfs rw
bootargs_end=:::DB88FXX81:eth0:none
image_name=uImage
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0x2000000;
ethaddr=00:08:XX:XX:XX:XX
mvPhoneConfig=mv_phone_config=dev0:fxs,dev1:fxo
mvNetConfig=mv_net_config=(00:11:88:0f:62:81,0:1:2:3),mtu=1500
usb0Mode=host
yuk_ethaddr=00:00:00:EE:51:81
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
ethact=egiga0
update=tftp 0x800000 uImage; tftp 0xa00000 rootfs.gz;bootm 0x800000
filesize=36464c
fileaddr=A00000
bootcmd=uart1 0x68;cp.l 0xf8200000 0x800000 0x80000;cp.l 0xf8400000 0xa00000 0x240000;bootm 0x800000
ipaddr=172.17.21.248
serverip=172.17.21.7
netmask=255.255.254.0
bootargs=console=ttyS0,115200 root=/dev/ram initrd=0xa00000,0x900000 ramdisk=32768
stdin=serial
stdout=serial
stderr=serial
mainlineLinux=no
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
netbsd_en=no
vxworks_en=no
bootdelay=3
disaMvPnp=no
enaAutoRecovery=yes
bootp_vendor_class=F_TS-110
3. To modify the U-boot parameter, you can use fw_setenv command. Here is an example of how to change boot delay.
# fw_setenv bootdelay 5

No comments: