Template:Linux-SPIFlash

From FriendlyELEC WiKi
Jump to: navigation, search

启动Linux系统时,看到类似下面的启动信息则说明SPI Flash被成功检测到了:

m25p80 spi0.0: mx25l12805d (16384 Kbytes)
1 ofpart partitions found on MTD device spi0.0
Creating 1 MTD partitions on "spi0.0":
0x000000000000-0x000001000000 : "spi-flash"

SPI Flash在Linux系统下的使用方法如下:

$ cat /sys/class/mtd/mtd0/size          # 以byte为单位
$ cat /sys/class/block/mtdblock0/size   # 以sector(512 byte)为单位
$ apt-get install mtd-utils 
$ flash_eraseall -j /dev/mtd0           # 格式成jffs2的格式
$ mount -t jffs2 /dev/mtdblock0 /mnt    
$ mkfs.ext4 /dev/mtdblock0              # 也格式化为ext4
$ mount -t ext4 /dev/mtdblock0 /mnt