1.0 前言
一種可以在linux下讀寫flash的方案
測試發(fā)行版操作系統(tǒng): Debian10 Ubuntu 22.04 免驅(qū)動(dòng)
讀速度: 2秒可以吧4Mbyte flash讀出
寫速度: 74秒寫入1Mbyte的內(nèi)容到flash
寫特性: flashrom會(huì)讀出舊flash內(nèi)容, 與待寫入的數(shù)據(jù)對比, 然后只寫入有差異的塊, 所以如果新固件修改較小的話, 寫入時(shí)間將會(huì)很短.
2.0 引腳定義
ft232h模塊圖示及引腳定義:
flash引腳定義
從左上角的圓圈標(biāo)記點(diǎn)開始逆時(shí)針標(biāo)記為pin 1-8

3.0 接線方式
- AD0 接 pin 6
- AD1 接 pin 5
- AD2 接 pin 2
- AD4 接 pin 1
- pin 3 (寫保護(hù)) 接 3.3V
- pin 4 (GND) 接 GND
- pin 7 (HOLD) 接 3.3V
- pin 8 (VCC) 接 3.3v
4.0 讀寫flash
如果未安裝flashrom的話, 執(zhí)行安裝命令
sudo apt install flashrom
或者自行編譯以支持更多型號(hào)的flash
4.1 測試是否可以識(shí)別到ft232h及flash
sudo flashrom -p ft2232_spi:type=232H
如下輸出時(shí)表示已經(jīng)識(shí)別到flash的型號(hào):W25Q32.V
flashrom v1.2 on Linux 6.2.0-35-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org
Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on ft2232_spi.
No operations were specified.
4.2 讀出flash
sudo flashrom -p ft2232_spi:type=232H -r rom.bin
flashrom v1.2 on Linux 6.2.0-35-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org
Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on ft2232_spi.
Reading flash... done.
4.3 寫入flash
sudo flashrom -p ft2232_spi:type=232H -w rom.bin
flashrom v1.2 on Linux 6.2.0-35-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org
Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Winbond flash chip "W25Q32.V" (4096 kB, SPI) on ft2232_spi.
Reading old flash chip contents... done.
Erasing and writing flash chip... Erase/write done.
Verifying flash... VERIFIED.
參考資料:
https://learn.adafruit.com/programming-spi-flash-prom-with-an-ft232h-breakout/overview