Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroDivisionError: integer division or modulo by zero #6

Open
rourion opened this issue Mar 25, 2016 · 5 comments
Open

ZeroDivisionError: integer division or modulo by zero #6

rourion opened this issue Mar 25, 2016 · 5 comments

Comments

@rourion
Copy link

rourion commented Mar 25, 2016

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
@ohjeongwook
Copy link
Owner

This mean initialization failed. Can you confirm your hardware is working correctly?

@rourion
Copy link
Author

rourion commented Mar 28, 2016

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.

@rourion
Copy link
Author

rourion commented Apr 19, 2016

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?

@ohjeongwook
Copy link
Owner

Can you give me the chip model and names? I can look it up to see what might be the reason.

@metajiji
Copy link

metajiji commented Jul 30, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants