Open main menu

DAVE Developer's Wiki β

Flashing Images (Naon)

Revision as of 08:07, 9 May 2012 by DevWikiAdmin (talk | contribs) (introduction to spi flash)

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Info Box
Naon am387x-dm814x.png Applies to Naon
Tux.png Applies to U-Boot

Contents

IntroductionEdit

In this article we'll see in detail how to flash binaries images into Naon on-board flash memories.

Three kind of binaries are usually programmed on flash memory:

  1. U-Boot (1st and 2nd stage)
  2. Kernel
  3. root file system, which can be
    • ramdisk binary image
    • flash file system (e.g. JFFS2 or UBIFS) image/files

Flash devices are also called Memory Tecnology Device (MTD) in Linux kernel terms. Please also take a look at MTD article on this wiki for flash memories usage in Linux. In this article we'll take a look only at flash memories from U-Boot point of view.

We also assume that:

  • user have a valid U-Boot image flashed on the board with the required flash device support
  • user can load the image into ram via TFTP
    • there's also a serial load option (using kermit or ymodem protocol) but we'll take care of this (primary due its slowness). Anyway, you can refer to Recovery U-Boot Image (Naon) again, which uses the serial port to download the 2nd stage U-Boot binary.


  Before continue reading, we suggest to first have a look at Naon Memory organization, where details of memory addresses and size are detailed.  

Flashing images on SPI NOR FlashEdit

SPI NOR Flash is commonly used for:

  • U-Boot (1st and 2nd stage) storage
  • U-Boot environment storage
  • Linux Kernel Image storage

Anyway it can be used as generic storage too (application custom data or even file systems)

Using SPI NOR FlashEdit

U-Boot uses sf (SPI flash sub-system) commands and all its subcommands, to manage SPI NOR flashes.

As with all U-Boot commands, there's a brief help description:

NAON#help sf
sf - SPI flash sub-system

Usage:
sf probe [bus:]cs [hz] [mode]   - init flash device on given SPI bus
                                  and chip select
sf read addr offset len         - read `len' bytes starting at
                                  `offset' to memory at `addr'
sf write addr offset len        - write `len' bytes from memory
                                  at `addr' to flash at `offset'
sf erase offset len             - erase `len' bytes from `offset'

First of all we need to detect which kind of flash is attached to our board. This needs to be done after each boot and before using other sf command, otherwise an error arises:

NAON#sf read 81000000 0 20000
No SPI flash selected. Please run `sf probe'

By using sf probe we can fix the above error:

NAON#sf probe 0:0
8192 KiB AT45DB642D at 0:0 is now current device
NAON#sf read 81000000 0 20000
NAON#

The sf read command read from SPI flash (in the example 128KiB from offset 0) into a ram buffer (at address 0x81000000)

Generally speaking flashing a binary from U-Boot into SPI flash requires

  1. download the binary image (via TFTP)
  2. probe the SPI bus
  3. erase a flash range
  4. write the binary image from RAM to SPI Flash

Flashing U-Boot 1st StageEdit

Flashing U-Boot 2nd StageEdit

Flashing Linux KernelEdit

Flashing images on NAND FlashEdit