Update SPI Flash from U-boot

u-boot configuration

The required components to successfully boot the board are: the boot-loader (u-boot), the kernel (Linux), the file system (rootfs) and the Atheros calibration raw file (ART). This page describes how to write these components on the internal SPI Flash memory by using u-boot and the TFTP protocol.

Note: in order to follow this procedure your board must have u-boot already installed.

  • The first step is to gain access to the u-boot prompt.
  • The second step is to setup the server IP address and the local IP address:
 
 
setenv serverip 192.168.215.214;
setenv ipaddr 192.168.215.99;
 
 

Now the system is ready to retrieve the different components from the TFTP server. During the data transfer, we will save files in the RAM at the address 0x80060000 as a temporary location. Then, we will erase the SPI Flash memory section where we want to place our components. Finally, we will copy each component from the RAM to the SPI Flash memory.

During the procedure we will use the u-boot environment variables $fileaddr and $filesize. These variable are automatically generated/updated by the 'tftp' command. The environment variable $fileaddr is the last address used to store a file (in our case is always 0x80060000). The environment variable $filesize is the length of the last transferred file.

File names are the same that you can find in our download section, and they are the same that the compilation process will generate (if you are compiling your own binaries), but you are free to rename these files. All these files must be placed under the tftp root directory on the server.

It is not mandatory to write every component each time, you can write only the one that you need. Follow the commands to write each component in the correct place.

u-boot procedure to flash

  • u-boot
 
 
tftp 0x80060000 openwrt-ar71xx-generic-linino-u-boot.bin;
 
 

The output of the command could be

 
 
linino> tftp 0x80060000 openwrt-ar71xx-generic-linino-u-boot.bin
Using eth0 device
TFTP from server 192.168.215.214; our IP address is 192.168.215.99
Filename 'doghunter/openwrt-ar71xx-generic-linino-u-boot.bin'.
Load address: 0x80060000
Loading: ####################################
done
Bytes transferred = 181852 (2c65c hex)
 
 

In case of FAIL, try to understand if the ethernet connection is present and if the file is in the right position on the tftp server.

 
 
linino> tftp 0x80060000 openwrt-ar71xx-generic-linino-u-boot.bin
Using eth0 device
TFTP from server 192.168.215.214; our IP address is 192.168.215.99
Filename 'doghunter/openwrt-ar71xx-generic-linino-u-boot.bin'.
Load address: 0x80060000
Loading: *
TFTP error: 'File not found' (1)
Starting again
eth1 link down
FAIL
 
 

If the file was properly downloaded you can proceed erasing the flash and copying the new u-boot.

DON'T erase the boot partition if the new u-boot is not properly loaded in RAM, otherwise you'll brick the board!!

 
 
erase 0x9f000000 +0x40000;
cp.b $fileaddr 0x9f000000 $filesize;
 
 

If the u-boot environment partition also needs to be erased, in order to apply the new default environment, it is possible to delete it with the command:

 
 
erase 0x9f040000 +0x10000;
reset;
 
 

After the board reboots a message like *** Warning - bad CRC, the default environment will appear on the console. To avoid the warning message give the following command on the u-boot console

 
 
saveenv
 
 
  • kernel
 
 
tftp 0x80060000 openwrt-ar71xx-generic-linino-16M-kernel.bin;
erase 0x9fEa0000 +0x140000;
cp.b $fileaddr 0x9fea0000 $filesize;
 
 
  • rootfs
 
 
tftp 0x80060000 openwrt-ar71xx-generic-linino-16M-rootfs-squashfs.bin
erase 0x9f050000 +0xE50000;
cp.b $fileaddr 0x9f050000 $filesize;
 
 
  • ART ( Atheros calibration raw file )
 
 
tftp 0x80060000 art-linino.bin
erase 0x9fff0000 +0x10000;
cp.b $fileaddr 0x9fff0000 $filesize
 
 
  • and to boot the new image
 
 
bootm 0x9fea0000