Skip to main content.

7.6. Boot from Flash Memory

The previous section described how to load the Linux kernel image over ethernet using TFTP. This is especially well suited for your development and test environment, when the kernel image is still undergoing frequent changes, for instance because you are modifying kernel code or configuration.

Later in your development cycle you will work on application code or device drivers, which can be loaded dynamically as modules. If the Linux kernel remains the same then you can save the time needed for the TFTP download and put the kernel image into the flash memory of your canyonlands board.

The U-Boot command flinfo can be used to display information about the available on-board flash on your system:

=> fli

Bank # 1: CFI conformant FLASH (16 x 16)  Size: 64 MB in 512 Sectors
  AMD Standard command set, Manufacturer ID: 0x01, Device ID: 0x227E
  Erase timeout: 16384 ms, write timeout: 2 ms
  Buffer write timeout: 5 ms, buffer size: 32 bytes

  Sector Start Addresses:
  FC000000     FC020000     FC040000     FC060000     FC080000
  FC0A0000     FC0C0000     FC0E0000     FC100000     FC120000
  FC140000     FC160000     FC180000     FC1A0000     FC1C0000 E
  FC1E0000     FC200000     FC220000     FC240000     FC260000
  FC280000     FC2A0000     FC2C0000     FC2E0000     FC300000
  FC320000     FC340000     FC360000     FC380000     FC3A0000
  FC3C0000 E     FC3E0000 E     FC400000 E     FC420000 E     FC440000 E
  FC460000 E     FC480000 E     FC4A0000 E     FC4C0000 E     FC4E0000 E
  FC500000 E     FC520000 E     FC540000 E     FC560000 E     FC580000 E
  FC5A0000 E     FC5C0000 E     FC5E0000 E     FC600000 E     FC620000 E
  FC640000 E     FC660000 E     FC680000 E     FC6A0000 E     FC6C0000 E
  FC6E0000 E     FC700000 E     FC720000 E     FC740000 E     FC760000 E
  FC780000 E     FC7A0000 E     FC7C0000 E     FC7E0000 E     FC800000 E
  FC820000 E     FC840000 E     FC860000 E     FC880000 E     FC8A0000 E
  FC8C0000 E     FC8E0000 E     FC900000 E     FC920000 E     FC940000 E
  FC960000 E     FC980000 E     FC9A0000 E     FC9C0000 E     FC9E0000 E
  FCA00000 E     FCA20000 E     FCA40000 E     FCA60000 E     FCA80000 E
  FCAA0000 E     FCAC0000 E     FCAE0000 E     FCB00000 E     FCB20000 E
  FCB40000 E     FCB60000 E     FCB80000 E     FCBA0000 E     FCBC0000 E
  FCBE0000 E     FCC00000 E     FCC20000 E     FCC40000 E     FCC60000 E
  FCC80000 E     FCCA0000 E     FCCC0000 E     FCCE0000 E     FCD00000 E
  FCD20000 E     FCD40000 E     FCD60000 E     FCD80000 E     FCDA0000 E
  FCDC0000 E     FCDE0000 E     FCE00000 E     FCE20000 E     FCE40000 E
  FCE60000 E     FCE80000 E     FCEA0000 E     FCEC0000 E     FCEE0000 E
  FCF00000 E     FCF20000 E     FCF40000 E     FCF60000 E     FCF80000 E
  FCFA0000 E     FCFC0000 E     FCFE0000 E     FD000000 E     FD020000 E
  FD040000 E     FD060000 E     FD080000 E     FD0A0000 E     FD0C0000 E
  FD0E0000 E     FD100000 E     FD120000 E     FD140000 E     FD160000 E
  FD180000 E     FD1A0000 E     FD1C0000 E     FD1E0000 E     FD200000 E
  FD220000 E     FD240000 E     FD260000 E     FD280000 E     FD2A0000 E
  FD2C0000 E     FD2E0000 E     FD300000 E     FD320000 E     FD340000 E
  FD360000 E     FD380000 E     FD3A0000 E     FD3C0000 E     FD3E0000 E
  FD400000 E     FD420000 E     FD440000 E     FD460000 E     FD480000 E
  FD4A0000 E     FD4C0000 E     FD4E0000 E     FD500000 E     FD520000 E
  FD540000 E     FD560000 E     FD580000 E     FD5A0000 E     FD5C0000 E
  FD5E0000 E     FD600000     FD620000 E     FD640000 E     FD660000 E
  FD680000 E     FD6A0000 E     FD6C0000 E     FD6E0000 E     FD700000 E
  FD720000 E     FD740000 E     FD760000 E     FD780000 E     FD7A0000 E
  FD7C0000 E     FD7E0000 E     FD800000 E     FD820000 E     FD840000 E
  FD860000 E     FD880000 E     FD8A0000 E     FD8C0000 E     FD8E0000 E
  FD900000 E     FD920000 E     FD940000 E     FD960000 E     FD980000 E
  FD9A0000 E     FD9C0000 E     FD9E0000 E     FDA00000 E     FDA20000 E
  FDA40000 E     FDA60000 E     FDA80000 E     FDAA0000 E     FDAC0000 E
  FDAE0000 E     FDB00000 E     FDB20000 E     FDB40000 E     FDB60000 E
  FDB80000 E     FDBA0000 E     FDBC0000 E     FDBE0000 E     FDC00000 E
  FDC20000 E     FDC40000 E     FDC60000 E     FDC80000 E     FDCA0000 E
  FDCC0000 E     FDCE0000 E     FDD00000 E     FDD20000 E     FDD40000 E
  FDD60000 E     FDD80000 E     FDDA0000 E     FDDC0000 E     FDDE0000 E
  FDE00000 E     FDE20000 E     FDE40000 E     FDE60000 E     FDE80000 E
  FDEA0000 E     FDEC0000 E     FDEE0000 E     FDF00000 E     FDF20000 E
  FDF40000 E     FDF60000 E     FDF80000 E     FDFA0000 E     FDFC0000 E
  FDFE0000 E     FE000000 E     FE020000 E     FE040000 E     FE060000 E
  FE080000 E     FE0A0000 E     FE0C0000 E     FE0E0000 E     FE100000 E
  FE120000 E     FE140000 E     FE160000 E     FE180000 E     FE1A0000 E
  FE1C0000 E     FE1E0000 E     FE200000 E     FE220000 E     FE240000 E
  FE260000 E     FE280000 E     FE2A0000 E     FE2C0000 E     FE2E0000 E
  FE300000 E     FE320000 E     FE340000 E     FE360000 E     FE380000 E
  FE3A0000 E     FE3C0000 E     FE3E0000 E     FE400000 E     FE420000 E
  FE440000 E     FE460000 E     FE480000 E     FE4A0000 E     FE4C0000 E
  FE4E0000 E     FE500000 E     FE520000 E     FE540000 E     FE560000 E
  FE580000 E     FE5A0000 E     FE5C0000 E     FE5E0000 E     FE600000 E
  FE620000 E     FE640000 E     FE660000 E     FE680000 E     FE6A0000 E
  FE6C0000 E     FE6E0000 E     FE700000 E     FE720000 E     FE740000 E
  FE760000 E     FE780000 E     FE7A0000 E     FE7C0000 E     FE7E0000 E
  FE800000 E     FE820000 E     FE840000 E     FE860000 E     FE880000 E
  FE8A0000 E     FE8C0000 E     FE8E0000 E     FE900000 E     FE920000 E
  FE940000 E     FE960000 E     FE980000 E     FE9A0000 E     FE9C0000 E
  FE9E0000 E     FEA00000 E     FEA20000 E     FEA40000 E     FEA60000 E
  FEA80000 E     FEAA0000 E     FEAC0000 E     FEAE0000 E     FEB00000 E
  FEB20000 E     FEB40000 E     FEB60000 E     FEB80000 E     FEBA0000 E
  FEBC0000 E     FEBE0000 E     FEC00000 E     FEC20000 E     FEC40000 E
  FEC60000 E     FEC80000 E     FECA0000 E     FECC0000 E     FECE0000 E
  FED00000 E     FED20000 E     FED40000 E     FED60000 E     FED80000 E
  FEDA0000 E     FEDC0000 E     FEDE0000 E     FEE00000 E     FEE20000 E
  FEE40000 E     FEE60000 E     FEE80000 E     FEEA0000 E     FEEC0000 E
  FEEE0000 E     FEF00000 E     FEF20000 E     FEF40000 E     FEF60000 E
  FEF80000 E     FEFA0000 E     FEFC0000 E     FEFE0000 E     FF000000 E
  FF020000 E     FF040000 E     FF060000 E     FF080000 E     FF0A0000 E
  FF0C0000 E     FF0E0000 E     FF100000 E     FF120000 E     FF140000 E
  FF160000 E     FF180000 E     FF1A0000 E     FF1C0000 E     FF1E0000 E
  FF200000 E     FF220000 E     FF240000 E     FF260000 E     FF280000 E
  FF2A0000 E     FF2C0000 E     FF2E0000 E     FF300000 E     FF320000 E
  FF340000 E     FF360000 E     FF380000 E     FF3A0000 E     FF3C0000 E
  FF3E0000 E     FF400000 E     FF420000 E     FF440000 E     FF460000 E
  FF480000 E     FF4A0000 E     FF4C0000 E     FF4E0000 E     FF500000 E
  FF520000 E     FF540000 E     FF560000 E     FF580000 E     FF5A0000 E
  FF5C0000 E     FF5E0000 E     FF600000 E     FF620000 E     FF640000 E
  FF660000 E     FF680000 E     FF6A0000 E     FF6C0000 E     FF6E0000 E
  FF700000 E     FF720000 E     FF740000 E     FF760000 E     FF780000 E
  FF7A0000 E     FF7C0000 E     FF7E0000 E     FF800000 E     FF820000 E
  FF840000 E     FF860000 E     FF880000 E     FF8A0000 E     FF8C0000 E
  FF8E0000 E     FF900000 E     FF920000 E     FF940000 E     FF960000 E
  FF980000 E     FF9A0000 E     FF9C0000 E     FF9E0000 E     FFA00000 E
  FFA20000 E     FFA40000 E     FFA60000 E     FFA80000 E     FFAA0000 E
  FFAC0000 E     FFAE0000 E     FFB00000 E     FFB20000 E     FFB40000 E
  FFB60000 E     FFB80000 E     FFBA0000 E     FFBC0000 E     FFBE0000 E
  FFC00000 E     FFC20000 E     FFC40000 E     FFC60000 E     FFC80000 E
  FFCA0000 E     FFCC0000 E     FFCE0000 E     FFD00000 E     FFD20000 E
  FFD40000 E     FFD60000 E     FFD80000 E     FFDA0000 E     FFDC0000 E
  FFDE0000 E     FFE00000 E     FFE20000 E     FFE40000 E     FFE60000 E
  FFE80000 E     FFEA0000 E     FFEC0000 E     FFEE0000 E     FFF00000 E
  FFF20000 E     FFF40000 E     FFF60000   RO     FFF80000   RO     FFFA0000   RO
  FFFC0000   RO     FFFE0000   RO
=>

From this output you can see the total amount of flash memory, and how it is divided in blocks (Erase Units or Sectors). The RO markers show blocks of flash memory that are write protected (by software) - this is the area where U-Boot is stored. The remaining flash memory is available for other use.

For instance, we can store the Linux kernel image in flash starting at the start address of the next free flash sector. Before we can do this we must make sure that the flash memory in that region is empty - a Linux kernel image is typically around 600...700 kB, so to be on the safe side we dedicate the whole area from 0xFC000000 to 0xFC17FFFF for the kernel image. Keep in mind that with flash memory only whole erase units can be cleared.

After having deleted the target flash area, you can download the Linux image and write it to flash. Below is a transcript of the complete operation with a final iminfo command to check the newly placed Linux kernel image in the flash memory.


=>  
=> setenv kernel_addr FC000000
=>  
=> prot off FC000000 FC17FFFF
Un-Protected 12 sectors
=>  
=> era FC000000 FC17FFFF

............ done
Erased 12 sectors
=>  
=> tftp 100000 /tftpboot/canyonlands/uImage-duts
ENET Speed is 1000 Mbps - FULL duplex connection (EMAC0)
Using ppc_4xx_eth0 device
TFTP from server 192.168.1.1; our IP address is 192.168.100.6
Filename '/tftpboot/canyonlands/uImage-duts'.
Load address: 0x100000
Loading: *#################################################################
    ######################################################
done
Bytes transferred = 1744326 (1a9dc6 hex)
=>  
=> imi 100000

## Checking Image at 00100000 ...
   Legacy image found
   Image Name:   Linux-2.6.25-rc8-01016-g94bf13b-
   Created:      2008-04-10   9:50:08 UTC
   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
   Data Size:    1744262 Bytes =  1.7 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
=>  
=> setenv ram_ws 100000
=>  
=> cp.b ${ram_ws} ${kernel_addr} ${filesize}
Copy to Flash... done
=>  
=> iminfo ${kernel_addr}

## Checking Image at fc000000 ...
   Legacy image found
   Image Name:   Linux-2.6.25-rc8-01016-g94bf13b-
   Created:      2008-04-10   9:50:08 UTC
   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
   Data Size:    1744262 Bytes =  1.7 MB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
=>  
=> saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... done
Protected 1 sectors
Protected 1 sectors
=> 

Note how the filesize variable (which gets set by the TFTP transfer) is used to automatically adjust for the actual image size.

Since kernel requires the flattened device tree blob to be passed at boot time, you have to also write the blob to the flash memory. Below is a transcript of this operation.

 
=>  
=> setenv fdt_addr FC1E0000
=>  
=> prot off FC1E0000 FC1FFFFF
Un-Protected 1 sectors
=>  
=> era FC1E0000 FC1FFFFF

. done
Erased 1 sectors
=>  
=> tftp 100000 /tftpboot/canyonlands/canyonlands.dtb
Waiting for PHY auto negotiation to complete... done
ENET Speed is 1000 Mbps - FULL duplex connection (EMAC0)
Using ppc_4xx_eth0 device
TFTP from server 192.168.1.1; our IP address is 192.168.100.6
Filename '/tftpboot/canyonlands/canyonlands.dtb'.
Load address: 0x100000
Loading: *T #
done
Bytes transferred = 10000 (2710 hex)
=>  
=> md 100000
00100000: d00dfeed 00002710 000000b8 00001b08    ......'.........
00100010: 00000028 00000011 00000010 00000000    ...(............
00100020: 000002f5 00001a50 00000000 00000000    .......P........
00100030: 00000000 00000000 00000000 00000000    ................
00100040: 00000000 00000000 00000000 00000000    ................
00100050: 00000000 00000000 00000000 00000000    ................
00100060: 00000000 00000000 00000000 00000000    ................
00100070: 00000000 00000000 00000000 00000000    ................
00100080: 00000000 00000000 00000000 00000000    ................
00100090: 00000000 00000000 00000000 00000000    ................
001000a0: 00000000 00000000 00000000 00000000    ................
001000b0: 00000000 00000000 00000001 00000000    ................
001000c0: 00000003 00000004 00000000 00000002    ................
001000d0: 00000003 00000004 0000000f 00000001    ................
001000e0: 00000003 00000011 0000001b 616d6363    ............amcc
001000f0: 2c63616e 796f6e6c 616e6473 00000000    ,canyonlands....
=>  
=> setenv ram_ws 100000
=>  
=> cp.b ${ram_ws} ${fdt_addr} ${filesize}
Copy to Flash... done
=>  
=> md ${fdt_addr}
fc1e0000: d00dfeed 00002710 000000b8 00001b08    ......'.........
fc1e0010: 00000028 00000011 00000010 00000000    ...(............
fc1e0020: 000002f5 00001a50 00000000 00000000    .......P........
fc1e0030: 00000000 00000000 00000000 00000000    ................
fc1e0040: 00000000 00000000 00000000 00000000    ................
fc1e0050: 00000000 00000000 00000000 00000000    ................
fc1e0060: 00000000 00000000 00000000 00000000    ................
fc1e0070: 00000000 00000000 00000000 00000000    ................
fc1e0080: 00000000 00000000 00000000 00000000    ................
fc1e0090: 00000000 00000000 00000000 00000000    ................
fc1e00a0: 00000000 00000000 00000000 00000000    ................
fc1e00b0: 00000000 00000000 00000001 00000000    ................
fc1e00c0: 00000003 00000004 00000000 00000002    ................
fc1e00d0: 00000003 00000004 0000000f 00000001    ................
fc1e00e0: 00000003 00000011 0000001b 616d6363    ............amcc
fc1e00f0: 2c63616e 796f6e6c 616e6473 00000000    ,canyonlands....
=>  
=> setenv filesize
=>  
=> saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Un-Protected 1 sectors
Erasing Flash...
. done
Erased 1 sectors
Writing to Flash... done
Protected 1 sectors
Protected 1 sectors
=> 

Now we can boot directly from flash. All we need to do is passing the in-flash address of the image (FC000000) and the in-flash address of the flattened device tree (FC1E0000) with the bootm command; we also make the definition of the bootargs variable permanent now:

=> setenv bootcmd bootm FC000000 - FC1E0000 
=> setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off

Use printenv to verify that everything is OK before you save the environment settings:

=> printenv
bootdelay=5
baudrate=115200
stdin=serial
stdout=serial
stderr=serial
bootcmd=bootm FC000000 - FC1E0000 
bootargs=root=/dev/nfs rw nfsroot=192.168.1.1:/opt/eldk-4.2/ppc_4xx
ip=192.168.100.6:192.168.1.1:192.168.1.1:255.255.0.0:canyonlands::off
....

=> saveenv

To test booting from flash you can now reset the board (either by power-cycling it, or using the U-Boot command reset), or you can manually call the boot command which will run the commands in the bootcmd variable:

=> run flash_self
## Booting kernel from Legacy Image at fc000000 ...
   Image Name:    Linux-2.6.32.7-00007-g08eba26
   Created:    2010-02-04  17:54:22 UTC
   Image Type:    PowerPC Linux Kernel Image (gzip compressed)
   Data Size:    1958545 Bytes =  1.9 MB
   Load Address: 00000000
   Entry Point:    00000000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at fc200000 ...
   Image Name:    Simple Embedded Linux Framework
   Created:    2008-04-01  19:52:43 UTC
   Image Type:    PowerPC Linux RAMDisk Image (gzip compressed)
   Data Size:    1727937 Bytes =  1.6 MB
   Load Address: 00000000
   Entry Point:    00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at fc1e0000
   Booting using the fdt blob at 0xfc1e0000
   Uncompressing Kernel Image ... OK
   Loading Ramdisk to 1fca6000, end 1fe4bdc1 ... OK
   Loading Device Tree to 00ffa000, end 00fff7cd ... OK
Using PowerPC 44x Platform machine description
Linux version 2.6.32.7-00007-g08eba26 (stefan@stefan-desktop) (gcc version 4.2.2) #1 Thu Feb 4 18:54:16 CET 2010
Found initrd at 0xdfca6000:0xdfe4bdc1
Zone PFN ranges:
  DMA      0x00000000 -> 0x00020000
  Normal   0x00020000 -> 0x00020000
  HighMem  0x00020000 -> 0x00020000
Movable zone start PFN for each node
early_node_map[1] active PFN ranges
    0: 0x00000000 -> 0x00020000
MMU: Allocated 1088 bytes of context maps for 255 contexts
Built 1 zonelists in Zone order, mobility grouping on.   Total pages: 130048
7.5. Networked Operation with Root Filesystem over NFS 1. Abstract 7.7. Standalone Operation with Ramdisk Image
Prev Home Next