ohjeongwook / dumpflash

Low-level NAND Flash dump and parsing utility
288 stars 102 forks source link

Can read from flash chip but cant write to flash chip #10

Closed PathEtechManagement closed 4 years ago

PathEtechManagement commented 7 years ago

I have been able to read from my flash chip "NAND 128MiB 3,3V 8-bit" but when i try to write back to the nand it starts but wont complete

$ ./DumpFlash.py -w -R Test.dmp Writing 0% page: 0/65535 block: 0/1024 speed: 740542 bytes/s Writing 0% page: 1/65535 block: 0/1024 speed: 635190 bytes/s Writing 0% page: 2/65535 block: 0/1024 speed: 592652 bytes/s Writing 0% page: 3/65535 block: 0/1024 speed: 576613 bytes/s Writing 0% page: 4/65535 block: 0/1024 speed: 566247 bytes/s Writing 0% page: 5/65535 block: 0/1024 speed: 559423 bytes/s Writing 0% page: 6/65535 block: 0/1024 speed: 554747 bytes/s Writing 0% page: 7/65535 block: 0/1024 speed: 551275 bytes/s Writing 0% page: 8/65535 block: 0/1024 speed: 548253 bytes/s Writing 0% page: 9/65535 block: 0/1024 speed: 546401 bytes/s Writing 0% page: 10/65535 block: 0/1024 speed: 544010 bytes/s Writing 0% page: 11/65535 block: 0/1024 speed: 543094 bytes/s Writing 0% page: 12/65535 block: 0/1024 speed: 502387 bytes/s Traceback (most recent call last): File "./DumpFlash.py", line 167, in flash_util.io.writePages(filename, options.offset, start_page, end_page, add_oob, add_jffs2_eraser_marker=add_jffs2_eraser_marker, raw_mode=options.raw_mode) File "/home/Matthew/projects/DumpFlash/FlashDevice.py", line 671, in writePages self.writePage(page,page_data) File "/home/Matthew/projects/DumpFlashFlashDevice.py", line 536, in writePage self.waitReady() File "/home/Matthew/projects/DumpFlash/FlashDevice.py", line 164, in waitReady if data[0]&2==0x2: IndexError: array index out of range

I was also able to erase the nand but now I can not reflash the image I read out from the chip.

drdoinstuff commented 7 years ago

Hi E-Path, I haven't used this project before but after looking at the error, I see that it is trying to write 0x83 and read it back in a loop until it succeeds, it doesn't seem to check if it fails the first time either.

There is a chance it will loop infinitely now, I feel like this might indicate that there is another problem preventing access to the chip.

Here is my patch; DumpFlash/FlashDevice.py

 def WaitReady(self):
        while 1:
            self.Ftdi.write_data(Array('B', [Ftdi.GET_BITS_HIGH]))
            data = self.Ftdi.read_data_bytes(1)
            if (len(data)>0 and data[0]&2==0x2):
                return
            else:
                if self.Debug>0:
                    print 'Not Ready', data
PathEtechManagement commented 7 years ago

Hi drdoinstuff Thanks for the reply. I applied the patch and I am now able to write data to the flash chip.

ohjeongwook commented 4 years ago

Applied recent commits.