dumpflash
dumpflash copied to clipboard
ZeroDivisionError: integer division or modulo by zero
Hello,
I have hooked up the FTDI breakout board and oriented the TSOP-48 NAND flash chip correctly in the socket. But I get this error when running the script? I am using python 2.7.6, pyftdi-0.9.1, pyusb 1.0.0, and libusb-1.0-0.dev. Am I missing a dependency or a specific version?
test@ubuntu:~/DumpFlash-master$ sudo python DumpFlash.py -i
Traceback (most recent call last):
File "DumpFlash.py", line 83, in <module>
flash_util=FlashUtil(options.filename,options.page_size, options.oob_size, options.pages_per_block,options.slow)
File "/home/test/DumpFlash-master/FlashUtil.py", line 17, in __init__
self.io = NandIO(slow)
File "/home/test/DumpFlash-master/FlashDevice.py", line 155, in __init__
self.GetID()
File "/home/test/DumpFlash-master/FlashDevice.py", line 362, in GetID
self.PagePerBlock=self.PageCount/self.BlockCount
ZeroDivisionError: integer division or modulo by zero
This mean initialization failed. Can you confirm your hardware is working correctly?
Hmm, I double / triple checked the wiring and all is good there. The orientation of the chip is correct in the socket. I checked if I had inadvertently fried the chip but it was still functional when placed back on its board. I do believe the FTDI board is recognized by the pyftdi library and cannot see why it would not be able to as lsusb displays the FTDI device. It seems that the issue is that it cannot read anything from the chip for some reason. When readFlashData() is called on line 239 it returns a list of eight zeroes. Is there anything I needed to do beyond wiring up the socket / FTDI board, installing the dependencies for your program, and running the script?
I've tried another NAND chip from the same model device and it also resulted in the same error. I am doing this inside a VM -- but since the Linux VM can see the FTDI board I think that could not be the issue.
I was using unsupported NAND chips apparently. I ended up trying four overall, two newer 16GB chips (One Toshiba and one unmarked), one 8GB chip (Micron) that came out 4-5 years ago, and an absolute ancient 128MB chip (ST Micro) that would rarely recognize with my computer. It worked with the 128MB chip. Any idea why some chips do not work? I'm assuming some kind of new feature in the technology?
Can you give me the chip model and names? I can look it up to see what might be the reason.
Same issue with M2502128T048SX22
All command run as root
All packages has been install via pip inside virtualenv:
sudo -s
git clone https://github.com/ohjeongwook/DumpFlash.git
virtualenv -p python2 --prompt="(DumpFlash)" venv
. venv/bin/activate
pip install pyftdi
(DumpFlash)[root@metall-desktop ~/_git/nand/DumpFlash]# python DumpFlash.py -i
Traceback (most recent call last):
File "DumpFlash.py", line 4, in <module>
from FlashDevice import *
File "/home/metall/_git/nand/DumpFlash/FlashDevice.py", line 1, in <module>
from pyftdi.pyftdi.ftdi import *
ImportError: No module named pyftdi.ftdi
I try fix import:
mcedit /home/metall/_git/nand/DumpFlash/FlashDevice.py
#from pyftdi.pyftdi.ftdi import *
from pyftdi.ftdi import *
And import looks ok.
dmesg after FTDI connected:
[ 7317.644024] usb 1-3: new high-speed USB device number 19 using ehci-pci
[ 7317.776792] usb 1-3: New USB device found, idVendor=0403, idProduct=6010
[ 7317.776798] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 7317.776801] usb 1-3: Product: Dual RS232-HS
[ 7317.776803] usb 1-3: Manufacturer: FTDI
[ 7317.777580] ftdi_sio 1-3:1.0: FTDI USB Serial Device converter detected
[ 7317.777627] usb 1-3: Detected FT2232H
[ 7317.778615] usb 1-3: FTDI USB Serial Device converter now attached to ttyUSB0
[ 7317.778840] ftdi_sio 1-3:1.1: FTDI USB Serial Device converter detected
[ 7317.778876] usb 1-3: Detected FT2232H
[ 7317.779096] usb 1-3: FTDI USB Serial Device converter now attached to ttyUSB1
Then i run DumpFlash.py -i
command:
(DumpFlash)[root@desktop ~/_git/nand/DumpFlash]# ./DumpFlash.py -i
Traceback (most recent call last):
File "./DumpFlash.py", line 83, in <module>
flash_util=FlashUtil(options.filename,options.page_size, options.oob_size, options.pages_per_block,options.slow)
File "/home/metall/_git/nand/DumpFlash/FlashUtil.py", line 17, in __init__
self.io = NandIO(slow)
File "/home/metall/_git/nand/DumpFlash/FlashDevice.py", line 156, in __init__
self.GetID()
File "/home/metall/_git/nand/DumpFlash/FlashDevice.py", line 363, in GetID
self.PagePerBlock=self.PageCount/self.BlockCount
ZeroDivisionError: integer division or modulo by zero
And dmesg after DumpFlash.py -i
command:
[ 7339.373953] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[ 7339.374061] ftdi_sio 1-3:1.0: device disconnected
[ 7339.374623] ftdi_sio ttyUSB1: FTDI USB Serial Device converter now disconnected from ttyUSB1
[ 7339.374726] ftdi_sio 1-3:1.1: device disconnected
lsusb before and after DumpFlash.py -i
looks good:
(DumpFlash)[root@desktop ~/_git/nand/DumpFlash]# lsusb
Bus 001 Device 019: ID 0403:6010 Future Technology Devices International, Ltd FT2232C Dual USB-UART/FIFO IC
But again and again run DumpFlash.py -i
failed with message:
(DumpFlash)[root@desktop ~/_git/nand/DumpFlash]# ./DumpFlash.py -i
Traceback (most recent call last):
File "./DumpFlash.py", line 83, in <module>
flash_util=FlashUtil(options.filename,options.page_size, options.oob_size, options.pages_per_block,options.slow)
File "/home/metall/_git/nand/DumpFlash/FlashUtil.py", line 17, in __init__
self.io = NandIO(slow)
File "/home/metall/_git/nand/DumpFlash/FlashDevice.py", line 155, in __init__
self.waitReady()
File "/home/metall/_git/nand/DumpFlash/FlashDevice.py", line 165, in waitReady
if data[0]&2==0x2:
IndexError: array index out of range