Flashing Images (Naon)

From DAVE Developer's Wiki
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)
Jump to: navigation, search
Info Box
Naon am387x-dm814x.png Applies to Naon
Tux.png Applies to U-Boot

Introduction[edit | edit source]

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.


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

Flashing images on SPI NOR Flash[edit | edit source]

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 Flash[edit | edit source]

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 Stage[edit | edit source]

Flashing U-Boot 2nd Stage[edit | edit source]

Flashing Linux Kernel[edit | edit source]

Flashing images on NAND Flash[edit | edit source]

WorkInProgress.gif