|
本帖最后由 独行客 于 2016-7-17 14:40 编辑
4. 启动软件测试
$ flashrom -p linux_spi:dev=/dev/spidev0.0
- bpi@bananapi:~$ flashrom -p linux_spi:dev=/dev/spidev0.0
复制代码
说明硬件连接已经OK,软件已经识别到我的SPI FLASH
[Found Eon flash chip "unknown Eon SPI chip" (0 kB, SPI) on linux_spi.]
而我实际放到座子上的是T80-75HCP 2M_BYTE [可直接代换 EN25T80]
然后,我换了一片SPI flash 重新测试,烙铁拆下后比较脏,看不清具体型号。
- bpi@bananapi:~$ flashrom -p linux_spi:dev=/dev/spidev0.0
- flashrom v0.9.9-rc1-r1942 on Linux 3.4.39-BPI-M3-Kernel (armv7l)
- flashrom is free software, get the source code at https://flashrom.org
- Calibrating delay loop... OK.
- Found Macronix flash chip "MX25L6405" (8192 kB, SPI) on linux_spi.
- Found Macronix flash chip "MX25L6405D" (8192 kB, SPI) on linux_spi.
- Found Macronix flash chip "MX25L6406E/MX25L6408E" (8192 kB, SPI) on linux_spi.
- Found Macronix flash chip "MX25L6436E/MX25L6445E/MX25L6465E/MX25L6473E" (8192 kB, SPI) on linux_spi.
- Multiple flash chip definitions match the detected chip(s): "MX25L6405", "MX25L6405D", "MX25L6406E/MX25L6408E", "MX25L6436E/MX25L6445E/MX25L6465E/MX25L6473E"
- Please specify which chip definition to use with the -c <chipname> option.
复制代码
从上面的提示[Multiple flash chip definitions match the detected chip(s)]可以看出这个芯片有多重名字,具体操作的时候需要指定具体型号
哈哈,终于识别到我的芯片型号了
5. 使用flashrom软件
获取使用帮助
- bpi@bananapi:~$ flashrom -h
- flashrom v0.9.9-rc1-r1942 on Linux 3.4.39-BPI-M3-Kernel (armv7l)
- flashrom is free software, get the source code at https://flashrom.org
- Please note that the command line interface for flashrom has changed between
- 0.9.5 and 0.9.6 and will change again before flashrom 1.0.
- Usage: flashrom [-h|-R|-L|-p <programmername>[:<parameters>] [-c <chipname>]
- [-E|(-r|-w|-v) <file>] [-l <layoutfile> [-i <imagename>]...] [-n] [-f]]
- [-V[V[V]]] [-o <logfile>]
- -h | --help print this help text
- -R | --version print version (release)
- -r | --read <file> read flash and save to <file>
- -w | --write <file> write <file> to flash
- -v | --verify <file> verify flash against <file>
- -E | --erase erase flash memory
- -V | --verbose more verbose output
- -c | --chip <chipname> probe only for specified flash chip
- -f | --force force specific operations (see man page)
- -n | --noverify don't auto-verify
- -l | --layout <layoutfile> read ROM layout from <layoutfile>
- -i | --image <name> only flash image <name> from flash layout
- -o | --output <logfile> log output to <logfile>
- -L | --list-supported print supported devices
- -p | --programmer <name>[:<param>] specify the programmer device. One of
- internal, dummy, gfxnvidia, drkaiser, satasii, atavia, it8212, serprog,
- buspirate_spi, dediprog, pony_spi, nicintel, nicintel_spi, nicintel_eeprom,
- ogp_spi, linux_spi, pickit2_spi, ch341a_spi.
- You can specify one of -h, -R, -L, -E, -r, -w, -v or no operation.
- If no operation is specified, flashrom will only probe for flash chips.
复制代码
尝试后,试验成功!
5.1 擦除芯片操作
bpi@bananapi:~$ flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -E
- bpi@bananapi:~$ flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -E
- flashrom v0.9.9-rc1-r1942 on Linux 3.4.39-BPI-M3-Kernel (armv7l)
- flashrom is free software, get the source code at https://flashrom.org
- Calibrating delay loop... OK.
- Found Macronix flash chip "MX25L6405D" (8192 kB, SPI) on linux_spi.
- Erasing and writing flash chip... Erase/write done.
- bpi@bananapi:~$
复制代码
擦除命令解释:
- flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -E
复制代码
前面的不解释,后面的 –c MX25L6405D 表示指定芯片型号
-E 表示擦除整芯片
擦除时,感觉就像死机一样,约2分钟后擦除完成【Erase/write done】
5.2 读flash操作
- ~$ flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -r readMX25L6405D.bin
- flashrom v0.9.9-rc1-r1942 on Linux 3.4.39-BPI-M3-Kernel (armv7l)
- flashrom is free software, get the source code at https://flashrom.org
- Calibrating delay loop... OK.
- Found Macronix flash chip "MX25L6405D" (8192 kB, SPI) on linux_spi.
- Reading flash... done.
复制代码
命令解释:
- flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -r readMX25L6405D.bin
复制代码
后面的 -r readMX25L6405D.bin 表示读取flash到当前目录的 readMX25L6405D.bin文件
显示读出来的二进制数据用hexdump命令,系统自带
- bpi@bananapi:~$ hexdump readMX25L6405D.bin
- 0000000 ffff ffff ffff ffff ffff ffff ffff ffff
- *
- 0800000
- bpi@bananapi:~$
复制代码
由于是擦除后才读出的,所以整个文件都是1
利用XP上的【WinSCP】软件可以把文件拷贝到XP系统,
5.3 写flash操作
- 刚刚想把读出来的数据写到flash,结果提示写入的内容和flash的内容相同,跳过写操作
- 然后写入比flash小的文件,提示文件太小烧写失败
- 然后想到把刚刚读出的8M的文件在XP下的WinHex软件修改下,再烧进去测试下flash的写操作
- bpi@bananapi:~$ flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -w writeMX25L6405D.bin
- flashrom v0.9.9-rc1-r1942 on Linux 3.4.39-BPI-M3-Kernel (armv7l)
- flashrom is free software, get the source code at https://flashrom.org
- Calibrating delay loop... OK.
- Found Macronix flash chip "MX25L6405D" (8192 kB, SPI) on linux_spi.
- Reading old flash chip contents... done.
- Erasing and writing flash chip... Erase/write done.
- Verifying flash... FAILED at 0x00000000! Expected=0x68, Found=0xff, failed byte count from 0x00000000-0x007fffff: 0xa0ab
- Your flash chip is in an unknown state.
- Please report this on IRC at chat.freenode.net (channel #flashrom) or
- mail flashrom@flashrom.org, thanks!
- bpi@bananapi:~$
复制代码
命令解释:
- flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -w writeMX25L6405D.bin
复制代码
-w writeMX25L6405D.bin 把writeMX25L6405D.bin烧到flash
但是writeMX25L6405D.bin文件大小必须等于flash的大小,内容不能和flash相同,否则烧写失败
- flashrom -p linux_spi:dev=/dev/spidev0.0 -c MX25L6405D -r rrMX25L6405D.bin
复制代码
可以用vi 或 nano命令来查看里面的文本内容
也可以拷贝到电脑上打开对比下
6. 强制使用之前没有支持到的flash芯片
强制擦除指定芯片型号
擦除失败
- flashrom -p linux_spi:dev=/dev/spidev0.0 -f -c EN25B80 -E
复制代码
强制读取
- flashrom -p linux_spi:dev=/dev/spidev0.0 -f -c EN25B80 -r readEN25T80.bin
复制代码
读出来的全部是1
写也失败
也就是目前flashrom 不支持我的EN25T80,需要自己在源码里添加,后面再说
7. 源码编译flashrom 成功!
参考链接https://www.flashrom.org/Downloads#Releases
实际操作是:
先安装subversion 等组件
- bpi@bananapi:~$ sudo apt install subversion
- sudo apt-get install pciutils-dev
- sudo apt-get install build-essential
- sudo apt-get install zlib1g-dev
- sudo apt-get install libftdi-dev
- sudo apt-get install libusb-dev
复制代码
libusb-dev 安装了,编译flashrom还是提示缺usb的头文本,干脆直接源码编译安装
源码编译安装libusb
https://sourceforge.net/projects/libusb/?source=typ_redirect
下载后
- tar -vxf libusb-1.0.20.tar.bz2
- cd libusb-1.0.20/
- ./configure
- make
- sudo make install
复制代码
下载flashrom源码
然后才是下面的步骤正式编译flashrom:
- svn co svn://flashrom.org/flashrom/trunk flashrom
- $ cd flashrom
- $ make
- # The next step is optional!
- $ sudo make install
- 上面的install 安装可以省略,直接在编译成功路径下运行
- ./flashrom -p linux_spi:dev=/dev/spidev0.0
复制代码
8. 总结
烧写8M的flash蛮快的
但是我的1M的 EN25T80不支持,有点遗憾,源码编译后应该能添加进去,但是暂时不折腾
所有资料在云盘可以下载,免密码:
http://pan.baidu.com/s/1kVm5P7h
|
|