Flash Reader allows to read and/or write any EEPROM or Flash memory via SPI or I2C. This library is particularly useful in case of reverse engineering or prototyping for embedded systems (RPI, etc..).
from flashreader.memory import spiflash, m95, mx25, w25q, _24lc, _25lc, _25aa
from flashreader.platform import ft232h, raspberrypi
with ft232h.Platform() as platform: #Open FT232H adapter
with spiflash.Memory(platform) as memory: #Open generic SPI flash
print(f"Writing hello world @0x0000...")
memory.write(0x0000, b'Hello World')
buf = bytearray(memory.read(0x00000000, 11))
print(f"Read @0x0000: {buf}")
- Raspberry pi 4
- FT232H (Adafruit)
- Various spi serial flash
- Macronix mx25R..., mx25L...
- Microchip 25aa..., 25lc...
- Winbond w25q...
- Microchip 24lc...
- ST m95...
apt-get install python3 python3-pip python3-spidev python3-monotonic
sudo raspi-config
- Go to "Interfacing Options" > "SPI" > "Enable"
- Reboot the RPI
- SPI: PIN19(MOSI), PIN21(MISO), PIN23(SCK), PIN11(CS)
- I2C: PIN3(SDA), PIN5(SCL)
- Plug FT232H
- Use Zadig (https://zadig.akeo.ie/), select the USB device in the list, select libusb-win32 and replace the driver (DO NOT USE WINUSB or any other driver).
- SPI: D0(SCK), D1(MOSI), D2(MISO), D3(CS)
- I2C: D0(SCL), D1(SDA)
Read spi flash (By using generic driver: spiflash)
python -m flashreader --platform raspberrypi --memory spiflash --read ./dump.bin --offset 0
Write spi flash (By using generic driver: spiflash)
python -m flashreader --platform raspberrypi --memory spiflash --write ./dump.bin --offset 0