Installing Linux Images to Flash Print

 

This note explains how to install a bootable Linux image to the QSPI Flash on the LPC4357 Dev Kit. Having installed a Linux image to the Flash, you would be able to boot Linux on the target automatically on any power up or reset cycle. This is the mode of operation that is typically used for deployed production units.

The example below refers to networking.uImage. This is the same networking.uImage that is included in the Emcraft software distribution. You can always use it to revert to the known-to-work default software, should you decide to do that for some reason. For instance, you may want to do that in order to validate an I/O interface supported by the networking project. However, as you proceed to develop your Linux configurations against your specific requirements, you will need a way to install an updated Linux image to the target for deployment. The process described below will work for any uImage you build using the Emcraft software distribution.

Before you proceed to install an uImage to the Flash, it probably makes sense to verify that what you have is indeed a bootable Linux image. You can do that by loading the image to the target from the network using the run netboot command (refer to Loading Linux Images via Ethernet and TFTP). It is important to understand that the same uImage that you load via TFTP can be loaded from the Flash as well. It doesn't make sense to install an uImage to the Flash unless you have validated the image by loading it via Ethernet and TFTP.

The U-Boot command sequence required to install a uImage to the QSPI Flash is defined for you by the U-Boot environment variable called update. Here is how update is defined in U-Boot by default:

EA-LPC4357> print update
update=tftp ${image}; cp.b ${loadaddr} ${flashaddr} ${filesize}
EA-LPC4357>

You will notice that the first command in update is a tftpboot command to download an image from the network via Ethernet and TFTP. Please refer to Loading Linux Images via Ethernet and TFTP for detailed information on how to set up your target and the development host for loading images from TFTP.

The second command is cp.b, which performs a per-byte copy of the just downloaded Linux image from the external RAM to the QSPI Flash device. The QSPI Flash is accessed by U-Boot using the SPIFI interface, which maps the Flash device into the memory space of the LPC4357 at the address defined by flashaddr:

EA-LPC4357> print flashaddr
flashaddr=14001000
EA-LPC4357>

Here is a snapshot showing how update is used to install networking.uImage to the Flash:

EA-LPC4357> sete image vlad/networking.uImage
EA-LPC4357> savee
Saving Environment to spifi...
EA-LPC4357> run update
Auto-negotiation...completed.
LPC18XX_MAC: link UP (100/Full)
Using LPC18XX_MAC device
TFTP from server 172.17.0.1; our IP address is 172.17.6.136
Filename 'vlad/networking.uImage'.
Load address: 0x28000000
Loading: #################################################################
####################################################
done
Bytes transferred = 1708896 (1a1360 hex)
EA-LPC4357>

Having installed an image to the Flash, just hit the Reset button on the target board to boot the newly installed image from Flash:

U-Boot 2010.03-00073-1.14.0 (May 14 2015 - 12:51:52)
CPU  : LPC43xx series (Cortex-M4/M0)
Freqs: SYSTICK=144MHz,CCLK=144MHz
Board: Embedded Artists LPC4357 Dev Kit Rev A1
DRAM:  32 MB
In:    serial
Out:   serial
Err:   serial
Net:   LPC18XX_MAC
Hit any key to stop autoboot:  0
## Booting kernel from Legacy Image at 14001000 ...
Image Name:   Linux-2.6.33-arm1
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    1708832 Bytes =  1.6 MB
Load Address: 28008000
Entry Point:  28008001
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...

Linux version 2.6.33-arm1 (vlad@ocean.emcraft.com)(gcc version 4.7.2 (GCC)) #41 Mon May 18 12:19:40 +0400 2015
...
init started: BusyBox v1.17.0 (2015-05-18 10:43:53 +0400)
~ # ls
bin    dev    etc    httpd  init   mnt    proc   root   sys usr    var
~ #

Please note that the QSPI Flash on the LPC4357 is only 2 MBytes in size, which limits the size of an installable uImage to less than 2 MBytes. The following shows a failed attempt to install a large uImage to the QSPI Flash. Please notice the "Cannot copy across SPIFI boundaries, aborting" printed by U-Boot:

EA-LPC4357> set image vlad/qtdemo.uImage
EA-LPC4357> run update
Auto-negotiation...completed.
LPC18XX_MAC: link UP (100/Full)
Using LPC18XX_MAC device
TFTP from server 172.17.0.1; our IP address is 172.17.6.136
Filename 'vlad/qtdemo.uImage'.
Load address: 0x28000000
Loading: #################################################################
...
done
Bytes transferred = 9602048 (928400 hex)
Cannot copy across SPIFI boundaries, aborting.
EA-LPC4357>

On deployed units, you will probably want to optimize the boot time by setting the U-Boot bootdelay variable to 0. Please refer to Running U-Boot for detailed information on how to do that.