U-boot and Flash (NOR, NAND & SPI)

U-boot and Flash (NOR, NAND & SPI)

U-boot now has support for 3 different flash technologies:
  • NOR flash (traditional parallel 8-bit or 16-bit wide data bus, with a dedicated address bus).
  • NAND flash (newer technology 8-bit or 16-bit data bus, which is multiplexed with the address bus).
  • SPI serial flash (newer technology, simple 4-wire serial bus).

These different flash technologies require different device drivers tocommunicate with them, due to the different ways they are wired to theCPU. As a result, there are different U-boot commands used to access them.It is important to use the correct command for each type of flash device.

Which Flash command sets to use?

The following table shows the appropriate command sets for each type of flash.

Action NOR NAND SPI
Copy Flash to RAM cp.[bwl] nand read eeprom read
Write to Flash from RAM cp.[bwl] nand write eeprom write
Dump Flash md.[bwl] nand dump eeprom read ; md.[bwl]
Erase Flash erase nand erase n/a
Write Protection protect on
protect off
nand lock
nand unlock
n/a
Additional Info flinfo
imls
nand info
nand bad
n/a

For more information on each of these U-boot commands, then pleaseuse the help command, for example:

MB680> help cp
MB680> help nand
MB680> help eeprom

Writing data to Flash

The following are examples of how to burn U-boot into flash,so it may be booted from flash. In all cases, we assume that the binary tobe burned is in a NFS server, and that both the NFS server, and U-boot'snetworking are correctly set up. In addition, we assume that we want toburn the U-boot image into the first block in flash (i.e. offset zero).

NOTE: The following commands may need to be changed for your specificboard, configuration, environment, etc. - they are just examples!

For NOR Flash

In the case of NOR flash, the flash should be explicitly erased(and if necessary unprotected), prior to writing to it.

MB680> nfs $load_addr /export/u-boot.bin
MB680> protect off 1:0-4
MB680> erase 1:0-4
MB680> cp.b $load_addr A0000000 $filesize
MB680> protect on 1:0-4

It should be noted that by default, U-boot has 2 environment variables(unprot, and update) which should be automaticallydefined which help with burning U-boot into NOR flash. These may be usedinstead of the above code, as follows:

MB680> nfs $load_addr /export/u-boot.bin
MB680> run unprot
MB680> run update

For NAND Flash

In the case of NAND flash, the flash should be explicitly erased,prior to writing to it.

In the case of NAND, then most access operations need to be multiplesof certain page/block sizes. For simplicity, the following code assumesthat u-boot.bin fits in 256 KiB (0x40000). However, you may use smallestfigures that are appropriately aligned.

MB680> nfs $load_addr /export/u-boot.bin
MB680> nand erase 0 40000
MB680> nand write $load_addr 0 40000

For SPI Serial Flash

In the case of SPI serial flash, U-boot will automatically erase theflash, prior to writing to it. Hence, users may just use the eepromwrite command without explicitly having to erase the SPI serialflash device at all.

MB680> nfs $load_addr /export/u-boot.bin
MB680> eeprom write $load_addr 0 $filesize
發佈了11 篇原創文章 · 獲贊 10 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章