Electronics > Microcontrollers

Dumping flash memory ft2232h

(1/1)

t4rmo:
I tried to read the memory's flash content with my ft2232h.
I wrote a script to emulate the read's chronogram with pyftdi but i haven't able to communicate with the flash.(I don't receive flash's response)
Any idea of what happen?


--- Code: ---from pyftdi.spi import *
fd = open('dump','wb')

spi = SpiController()

spi.configure('ftdi://ftdi:2232:2:7/1')

slave = spi.get_port(cs=0,freq = 10E6)
address = b'\x00\x00\x00'

read_command = b'\x03'
release_deep_power = b'\xAB'

slave.write(release_deep_power)
slave.write(read_command + address)
while 1:
    data_out=slave.read(1)
    fd.write(data_out)

--- End code ---

In theory with a single read instruction you can dump the whole memory due to a internal counter

abyrvalg:
According to PyFTDI SPI documentation https://eblot.github.io/pyftdi/api/spi.html#pyftdi.spi.SpiPort.write both write() and read() assert nCS at start and deassert at the end of transfer by default, so you have a broken nCS sequence. Try this:

--- Code: ---FLASH_SIZE = 0x100000 #put your size here
slave.write(read_command + address, start=True, stop=False) #assert nCS and keep it asserted
for i in range(FLASH_SIZE-1):
    data_out=slave.read(1, start=False, stop=False) # don't touch nCS
    fd.write(data_out)
data_out=slave.read(1, start=False, stop=True) #read last byte and deassert nCS, terminating the operation
fd.write(data_out)

--- End code ---

t4rmo:
Thank you abyrvalg, you are right
Now I'm going to try the writing

Regards

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod