您的位置:首页 > 其它

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

2015-06-06 11:29 826 查看

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.

ActionNORNANDSPI
Copy Flash to RAMcp.[bwl]nand readeeprom read
Write to Flash from RAMcp.[bwl]nand writeeeprom write
Dump Flashmd.[bwl]nand dumpeeprom read ; md.[bwl]
Erase Flasherasenand erasen/a
Write Protectionprotect on

protect off
nand lock

nand unlock
n/a
Additional Infoflinfo

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: