McMCCRU / SNANDer

SNANDer - Serial Nor/nAND/Eeprom programmeR (based on CH341A)
GNU General Public License v2.0
245 stars 65 forks source link

WiP: add W25N01GW and GD5F1GQ4RB9IG #29

Open danielkucera opened 1 year ago

danielkucera commented 1 year ago

Hi @McMCCRU , I am adding two new chips here but with one I am getting following error, can you please advice what could be wrong?

SNANDer -e

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.5 by McMCC <mcmcc@mail.ru>

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
spi_nand_probe: mfr_id = 0xc8, dev_id = 0xc1, dev_id_2 = 0xc8
Get Status Register 1: 0x00
Get Status Register 2: 0x11
Using Flash ECC.
Detected SPI NAND Flash: GIGADEVICE GD5F1GQ4xBxIG, Flash Size: 128 MB
ERASE:
Set full erase chip!
Erase addr = 0x0000000000000000, len = 0x0000000008000000
spi_nand_erase_block : erase block fail, block = 0x3ff, status = 0x4
spi_nand_erase_internal : Erase Fail at addr = 0x7fe0000, len = 0x8000000, block_idx = 0x3ff
Erase 100% [134217728] of [134217728] bytes      
Status: BAD(-1)
danielkucera commented 1 year ago

And also this:

$ SNANDer -w  ok-mod-druhy.bin 

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.5 by McMCC <mcmcc@mail.ru>

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
spi_nand_probe: mfr_id = 0xc8, dev_id = 0xc1, dev_id_2 = 0xc8
Get Status Register 1: 0x00
Get Status Register 2: 0x11
Using Flash ECC.
Detected SPI NAND Flash: GIGADEVICE GD5F1GQ4xBxIG, Flash Size: 128 MB
WRITE:
Write addr = 0x0000000000000000, len = 0x0000000008000000
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc0, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc1, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc2, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc3, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc4, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc5, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc6, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc7, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc8, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffc9, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffca, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffcb, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffcc, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffcd, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffce, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffcf, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd0, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd1, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd2, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd3, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd4, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd5, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd6, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd7, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd8, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffd9, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffda, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffdb, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffdc, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffdd, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffde, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffdf, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe0, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe1, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe2, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe3, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe4, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe5, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe6, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe7, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe8, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffe9, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffea, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffeb, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffec, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffed, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffee, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffef, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff0, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff1, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff2, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff3, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff4, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff5, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff6, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff7, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff8, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfff9, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfffa, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfffb, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfffc, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfffd, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xfffe, status = 0xc
spi_nand_write_page : Program Fail at addr_offset = 0x0, page_number = 0xffff, status = 0xc
Written 100% [134217728] of [134217728] bytes      
Status: BAD(-1)

Is it possible that the flash is not exactly 128MB?

McMCCRU commented 1 year ago

Hi! Everything is done correctly, but the Status register (0xC0) return E_FAIL flag, this is an internal error, most likely related to the supply voltage or logic levels, your chip work on a 1.8V supply.

Droid-MAX commented 1 year ago

Haven't oob_free_layout fields been removed?

danielkucera commented 1 year ago

Hi! Everything is done correctly, but the Status register (0xC0) return E_FAIL flag, this is an internal error, most likely related to the supply voltage or logic levels, your chip work on a 1.8V supply.

But the chip works normally after flashing and all other pages were written okay. What could be the problem with writing to the last 64 pages?

McMCCRU commented 1 year ago

But the chip works normally after flashing and all other pages were written okay. What could be the problem with writing to the last 64 pages?

Please update on new version.

danielkucera commented 1 year ago

I've rebased to latest main, the problem is still there.

McMCCRU commented 1 year ago

Then I don’t understand why you have an internal error, I recently used a similar chip with a 3.3V supply, there were no problems. Is this a new chip or has it been used somewhere? Maybe it has some kind of set protection...

McMCCRU commented 1 year ago

It is also possible that this is not a marked BAD block.

danielkucera commented 1 year ago

I tried with at least 5 pieces of the same model. Always errors at the end.

McMCCRU commented 1 year ago

From your posts, I see return error flags programming and erase from register 0xC0. I don't understand these reasons.

danielkucera commented 1 year ago

If I specify the size like this:

diff --git a/src/spi_nand_flash.c b/src/spi_nand_flash.c
index 57c867d..9b29a3b 100644
--- a/src/spi_nand_flash.c
+++ b/src/spi_nand_flash.c
@@ -304,7 +304,7 @@ static const struct SPI_NAND_FLASH_INFO_T spi_nand_flash_tables[] = {
                mfr_id:                                 _SPI_NAND_MANUFACTURER_ID_GIGADEVICE,
                dev_id:                                 _SPI_NAND_DEVICE_ID_GD5F1GQ4RB9IG,
                ptr_name:                               "GIGADEVICE GD5F1GQ4xBxIG",
-               device_size:                            _SPI_NAND_CHIP_SIZE_1GBIT,
+               device_size:                            0x7fe0000,
                page_size:                              _SPI_NAND_PAGE_SIZE_2KBYTE,
                oob_size:                               _SPI_NAND_OOB_SIZE_128BYTE,
                erase_size:                             _SPI_NAND_BLOCK_SIZE_128KBYTE,

there are no more errors. Do you think the flash can really be 1 page (128kB) shorter? Possibly a hardware bug? Should I commit the shorter size?

danielkucera commented 1 year ago

this is the result when I read erased flash:

00000000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
07fe0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
08000000

But interestingly, no error at the end.

McMCCRU commented 1 year ago

Hi! You need to print debug, check the status of the registers responsible for the operations and installing Block Protection. I highlighted the right place in the code and also give tables to see where it all is. Screenshot_20230120_170639 Screenshot_20230120_170137 Screenshot_20230120_170342

McMCCRU commented 1 year ago

Before writing the last block, check the state of register 0xa0, make sure that there will be 0 or the bits responsible for setting the protection are not affected. Try turning off bit the quad mode, it turns on in the highlighted area in the screenshot with the source code.

danielkucera commented 1 year ago

spi_nand_protocol_get_status_reg_1 still reads 0 for all pages, disabling quad mode didn't help either.