Login

Why register?

  • Download software and technical materials
  • Purchase products at our on-line shop
  • Receive design news to stay up-to-date with Emcraft's new solutions

 

 

Installing Linux Images to Flash Print


This note explains how to install a bootable Linux image to the NAND Flash on the Kinetis System-On-Module (SOM). 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.

It should be noted that all Kinetis SOMs come with a default Linux image preloaded to the Flash. This is the same networking.uImage that is included in the Emcraft software distribution (refer to K70/K61 System-On-Module Release Materials). Clearly, as you proceed to develop your Linux applications against your specific requirements, you will need a way to install an updated Linux image to the target for deployment. This note explains how to do that.

The example below refers to networking.uImage. This image is included as a prebuilt binary in the software distribution so you can always use it to revert to the factory 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. As mentioned above though, the process below will work for any uImage you build using the Emcraft software distribution.

Before you proceed to install an uImage to the NAND 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 NAND Flash is defined for you by the U-Boot environment variable called update. Here is how update is defined in U-Boot by default:

K70-SOM> print update
update=tftp ${image};nand erase ${flashaddr} 1f00000;nand write ${loadaddr} ${flashaddr} 1f00000
K70-SOM>

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 nand erase, which erases the Flash in order to prepare it for installing an image. NAND Flash devices must be erased before data can be copied to it. That specific nand erase command erases a Flash region of 31 MBytes (0x1F00000) starting at offset 1 MByte (flashaddr):

K70-SOM> print flashaddr
flashaddr=00100000
K70-SOM>

The final command in the update command sequence is nand write, which copies the image loaded by the tftpboot command to the just erased region of the NAND Flash.

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

K70-SOM> setenv image vlad/networking.uImage
K70-SOM> saveenv
Saving Environment to NAND...
Erasing Nand...
Erasing at 0x60000 -- 100% complete.
Writing to Nand... done
K70-SOM> run update
Using FEC0 device
TFTP from server 172.17.0.1; our IP address is 172.17.6.46
Filename 'vlad/networking.uImage'.
Load address: 0x8007fc0
Loading: #################################################################
#################################################################
#############################
done
Bytes transferred = 2325504 (237c00 hex)

NAND erase: device 0 offset 0x100000, size 0x1f00000
Erasing at 0x1fe0000 -- 100% complete.
OK

NAND write: device 0 offset 0x100000, size 0x1f00000
32505856 bytes written: OK
K70-SOM>

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

U-Boot 2010.03-cortexm-1.14.2 (Sep 02 2015 - 13:53:39)

CPU : Freescale Kinetis series (Cortex-M4)
Freqs: SYSTICK=150MHz,CCLK=150MHz,PCLK=75MHz,MACCLK=50MHz
Board: K70-SOM Rev 1.A, www.emcraft.com
DRAM: 64 MB
NAND: 128 MiB
...
Loading from NAND, offset 0x100000
Image Name: Linux-2.6.33-cortexm-1.14.2
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2334656 Bytes = 2.2 MB
Load Address: 08008000
Entry Point: 08008001
...
Starting kernel ...

Linux version 2.6.33-cortexm-1.14.2 (psl @ocean.emcraft.com) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-189) ) #3 Wed Sep 2 13:59:32 MSK 2015 CPU: ARMv7-M Processor [410fc241] revision 1 (ARMv7M)
...
init started: BusyBox v1.17.0 (2015-09-02 13:57:19 MSK)
~ # ls
bin dev etc httpd init mnt proc root sys usr var
~ #

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.