eblot / pyspiflash

SPI data flash device drivers (pure Python)
MIT License
39 stars 30 forks source link

A question about SerialFlashUnknownJedec exception when using W25Q256 #29

Open klemdev opened 1 year ago

klemdev commented 1 year ago

Hi.

I am a bit stuck and would really appreciate any hint related to my issue:

  1. I have a script for FLASH programming through FTDI (FT2232H) and it works without any problem with W25Q32
  2. But when I try it with W25Q256, I get:
    File "/home/admin/.local/lib/python3.9/site-packages/spiflash/serialflash.py", line 228, in get_from_controller
    flash = SerialFlashManager._get_flash(spi, jedec)
    File "/home/admin/.local/lib/python3.9/site-packages/spiflash/serialflash.py", line 271, in _get_flash
    raise SerialFlashUnknownJedec(jedec)
    spiflash.serialflash.SerialFlashUnknownJedec: Unknown flash device: b'ef4019'

My code looks something like (FTDI_URL=ftdi://0x0403:0x6010:FT6CCSY8/1):

spi_master = SpiController()
spi_master.configure(FTDI_URL, cs_count=1, debug=False)
spi_slave = spi_master.get_port(cs=0, freq=6E6, mode=0)

spi_master.set_gpio_direction(0b11010000, 0b11010000)
sleep(0.001)

# Send init value.
spi_master.write_gpio(64)
sleep(0.5)

# Soft reset.
# Enable reset.
spi_cmd = array('B', (0x66,))
spi_slave.exchange(spi_cmd)
# Reset device.
spi_cmd = array('B', (0x99,))
spi_slave.exchange(spi_cmd)

try:
    flash = SerialFlashManager.get_from_controller(spi_master, 0, 6E6)
...
...

Does that mean this device is not supported or I am doing something wrong?

Thank you in advance for any suggestion.

eblot commented 1 year ago

Flash devices are often different, even in a specific series. They are added once tested, as it may not be only about a different storage size.

Patches are welcomed :)

klemdev commented 1 year ago

Sorry for late reply @eblot

Thank you very much for clarifying this. It works using Efinix GUI which runs Python scripts under the hood for flashing. Should probably look what they are doing there. Will let you know if I manage to find a fix.