jamesbowman / spidriver

SPI driver public repo
https://spidriver.com/
BSD 3-Clause "New" or "Revised" License
181 stars 57 forks source link

Python code does not properly calculate size / does not properly handle some devices #19

Open dshadoff opened 5 years ago

dshadoff commented 5 years ago

While trying to identify/read a 8KB FeRAM device MB85RS64V, the JEDEC ID is properly identified (0x04 0x7F 0x03), but the python code then goes into an infinite loop grabbing JEDEC ID again and again instead of determining memory size (which is 64 kbit / 8KB).

Product was purchased here: https://www.adafruit.com/product/1897 Datasheet here: http://www.adafruit.com/datasheets/MB85RS64V-DS501-00015-4v0-E.pdf

Likewise, a 128KB FeRAM MR45V100A was properly identified as (0xae 0x83 0x09), but was improperly identified as 512 bytes (actual size = 1Mbit / 128KB).

jamesbowman commented 5 years ago

Fixed the infinite loop bug, and pushed to PyPI: https://pypi.org/project/spidriver/

You can specify the size on the command-line using the -s argument, so for the MB85RS64V use -s 65536, and for MR45V100A -s 131072. This is meant for parts where the size isn't computable from the third ID byte, like these.

However reading further down the MB85RS64V datasheet, I see that it uses 16-bit addresses, and the flash tool assumes 24-bit addresses. image

However the MR45V100A does use 24-bit addressing, so it might work - please let me know. image

dshadoff commented 5 years ago

Thanks, the infinite loop bug appears to be fixed.

The third-byte size computation... may not be as straightforward as you had thought. I tested a AT25SF041 (very common 4Mb / 512KB Flash), which has JEDEC ID (0x1f 0x84 0x01)... this clearly also doesn't follow your expected rules.

As a result, it would be helpful if the spidriver.pdf file could be updated with this point about memory size, including the '-s ' operand for the python script.

biboc commented 2 years ago

Agree with @dshadoff , size calculation does not work as expected for my m25p20 memory https://media-www.micron.com/-/media/client/global/documents/products/data-sheet/nor-flash/serial-nor/m25p/m25p20.pdf?rev=3166183bc4514b9999c9c2fc7956ecca