Black God

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 0×0000 0×1000 0×40000

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 0×2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0×2000000;
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=0×02000000
autoload=no
ethact=egiga0
update=tftp 0×800000 uImage; tftp 0xa00000 rootfs.gz;bootm 0×800000
filesize=36464c
fileaddr=A00000
bootcmd=uart1 0×68;cp.l 0xf8200000 0×800000 0×80000;cp.l 0xf8400000 0xa00000 0×240000;bootm 0×800000
ipaddr=172.17.21.248
serverip=172.17.21.7
netmask=255.255.254.0
bootargs=console=ttyS0,115200 root=/dev/ram initrd=0xa00000,0×900000 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

 

3 comments for “U-Boot tools for Debian ARM Linux in QNAP Server

  1. Johnny
    November 8, 2012 at 7:59 pm

    Will this work with every QNAP NAS? I’ve got a QNAP TS-469L at home and want to try it.

  2. Ganesh Ganesh
    April 17, 2012 at 3:35 pm

    Dear Sir,

    This information in very useful to me. I am new to embedded division, little bit know about uboot. these are all, But I do know, How give Flash sector size

    # MTD device name Device offset Env. size Flash sector size
    /dev/mtd4 0×0000 0×1000 0×40000

    How to understand Flash sector size. any command to view flash sector partitions, size. I tried with devekit 8000.

    these commands set uboot environment

    setenv bootargs ‘console=ttyO2,115200n8 root=/dev/mmcblk0p2 rw rootwait video=omapfb:mode:7inch_LCD’
    setenv bootcmd ‘mmcinit;fatload mmc 0 80300000 uImage;bootm 80300000′

    my case fat partition have kernel
    another partition have root file system.

    what is mmc 0 80300000?
    what is uImage;bootm 80300000′?

    memory card load 0 to 80300000? How to know is number 80300000?
    load kernel uimage how to know is number 80300000′ ?

    please guide me sir.

    -Ganesh.

    • April 18, 2012 at 10:06 pm

      I have updated the article with more information on how to get MTD partition information and where you can get fw_env.config file for your machine.

Leave a Reply

Your email address will not be published. Required fields are marked *