[linux] flashrom使用ft232h讀寫 燒錄 flash

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 接線方式

  • AD0pin 6
  • AD1pin 5
  • AD2pin 2
  • AD4pin 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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容