Skip to content

Commit

Permalink
Added detect NAND SPI flash if first byte garbage in ID. Add support …
Browse files Browse the repository at this point in the history
…KIOXIA TC58CVG2S0HRAIJ.
  • Loading branch information
McMCCRU committed Jul 4, 2021
1 parent ef51717 commit ad7c19d
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 50 deletions.
Binary file modified Linux/SNANDer
Binary file not shown.
Binary file modified MacOSX/SNANDer
Binary file not shown.
Binary file modified Windows/SNANDer.exe
Binary file not shown.
77 changes: 39 additions & 38 deletions flash_support_list.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

SPI NAND Flash Support List:
001. GIGADEVICE GD5F1GQ4UA
Expand Down Expand Up @@ -39,43 +39,44 @@ SPI NAND Flash Support List:
035. TOSHIBA TC58CVG0S3H
036. TOSHIBA TC58CVG1S3H
037. TOSHIBA TC58CVG2S0H
038. MICRON MT29F1G01
039. MICRON MT29F2G01
040. MICRON MT29F4G01
041. HEYANG HYF1GQ4UAACAE
042. HEYANG HYF2GQ4UAACAE
043. HEYANG HYF2GQ4UHCCAE
044. HEYANG HYF1GQ4UDACAE
045. HEYANG HYF2GQ4UDACAE
046. PN PN26G01A-X
047. PN PN26G02A-X
048. ATO ATO25D1GA
049. ATO ATO25D2GA
050. ATO ATO25D2GB
051. FM FM25S01
052. FM FM25S01A
053. FM FM25G01B
054. FM FM25G02B
055. FM FM25G02C
056. FM FM25G02
057. XTX XT26G02B
058. XTX XT26G01A
059. XTX XT26G02A
060. MIRA PSU1GS20BN
061. BIWIN BWJX08U
062. BIWIN BWET08U
063. FORESEE FS35ND01GD1F1
064. FORESEE FS35ND01GS1F1
065. FORESEE FS35ND02GS2F1
066. FORESEE FS35ND02GD1F1
067. DS DS35Q2GA
068. DS DS35Q1GA
069. FISON CS11G0T0A0AA
070. FISON CS11G1T0A0AA
071. FISON CS11G0G0A0AA
072. TYM TYM25D2GA01
073. TYM TYM25D2GA02
074. TYM TYM25D1GA03
038. KIOXIA TC58CVG2S0HRAIJ
039. MICRON MT29F1G01
040. MICRON MT29F2G01
041. MICRON MT29F4G01
042. HEYANG HYF1GQ4UAACAE
043. HEYANG HYF2GQ4UAACAE
044. HEYANG HYF2GQ4UHCCAE
045. HEYANG HYF1GQ4UDACAE
046. HEYANG HYF2GQ4UDACAE
047. PN PN26G01A-X
048. PN PN26G02A-X
049. ATO ATO25D1GA
050. ATO ATO25D2GA
051. ATO ATO25D2GB
052. FM FM25S01
053. FM FM25S01A
054. FM FM25G01B
055. FM FM25G02B
056. FM FM25G02C
057. FM FM25G02
058. XTX XT26G02B
059. XTX XT26G01A
060. XTX XT26G02A
061. MIRA PSU1GS20BN
062. BIWIN BWJX08U
063. BIWIN BWET08U
064. FORESEE FS35ND01GD1F1
065. FORESEE FS35ND01GS1F1
066. FORESEE FS35ND02GS2F1
067. FORESEE FS35ND02GD1F1
068. DS DS35Q2GA
069. DS DS35Q1GA
070. FISON CS11G0T0A0AA
071. FISON CS11G1T0A0AA
072. FISON CS11G0G0A0AA
073. TYM TYM25D2GA01
074. TYM TYM25D2GA02
075. TYM TYM25D1GA03

SPI NOR Flash Support List:
001. AT25DF321
Expand Down
14 changes: 7 additions & 7 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

Usage:
-h display this message
Expand All @@ -23,7 +23,7 @@ Examples:

igor@mcmcc-GL553VE:~/Soft/SNANDer-bin/Linux$ ./SNANDer -i

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
Expand All @@ -35,7 +35,7 @@ Detected SPI NAND Flash: MXIC MX35LF2G, Flash Size: 256 MB

or

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

Found programmer device: Winchiphead (WCH) - CH341A
Device revision is 3.0.4
Expand All @@ -49,7 +49,7 @@ Detected SPI NAND Flash: WINBOND W25N01G, Flash Size: 128 MB

igor@mcmcc-GL553VE:~/Soft/SNANDer-bin/Linux$ ./SNANDer -d -e

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
Expand All @@ -70,7 +70,7 @@ igor@mcmcc-GL553VE:~/Soft/SNANDer-bin/Linux$

igor@mcmcc-GL553VE:~/Soft/SNANDer-bin/Linux$ ./SNANDer -d -v -w ecc_2Gb_2K_64_flashimage_rfb1_ac2600.bin

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
Expand All @@ -94,7 +94,7 @@ Status: OK

igor@igor-GL553VE:~/Soft/SNANDer-bin/Linux$ ./SNANDer -E 93c46 -r test.bin

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
Expand All @@ -111,7 +111,7 @@ Status: OK

igor@igor-GL553VE:~/Soft/SNANDer-bin/Linux$ ./SNANDer -E 93c46 -w test.bin -v

SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7.1 by McMCC <mcmcc_at_mail.ru>

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern int org;
#define EHELP ""
#endif

#define _VER "1.7"
#define _VER "1.7.1"

void title(void)
{
Expand Down
8 changes: 4 additions & 4 deletions src/snander.rc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include "res.h"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1, 7, 0, 0
PRODUCTVERSION 1, 7, 0, 0
FILEVERSION 1, 7, 1, 0
PRODUCTVERSION 1, 7, 1, 0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0
Expand All @@ -15,11 +15,11 @@ BEGIN
VALUE "FileDescription", "SNANDer - Serial Nor/nAND/Eeprom programmeR\0"
VALUE "OriginalFilename", "SNANDer.exe\0"
VALUE "CompanyName", "-= (c) 2018-2021 Igor Mokrushin aka McMCC =-\0"
VALUE "FileVersion", "1.7.0.0\0"
VALUE "FileVersion", "1.7.1.0\0"
VALUE "InternalName", "SNANDer\0"
VALUE "LegalCopyright", "Copyright (c) 2018-2021 by McMCC <[email protected]>\0"
VALUE "ProductName","SNANDer\0"
VALUE "ProductVersion","1.7.0.0\0"
VALUE "ProductVersion","1.7.1.0\0"
END
END
BLOCK "VarFileInfo"
Expand Down
91 changes: 91 additions & 0 deletions src/spi_nand_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
#define _SPI_NAND_DEVICE_ID_TC58CVG0S3H 0xC2
#define _SPI_NAND_DEVICE_ID_TC58CVG1S3H 0xCB
#define _SPI_NAND_DEVICE_ID_TC58CVG2S0H 0xCD
#define _SPI_NAND_DEVICE_ID_TC58CVG2S0HRAIJ 0xED
#define _SPI_NAND_DEVICE_ID_MT29F1G01 0x14
#define _SPI_NAND_DEVICE_ID_MT29F2G01 0x24
#define _SPI_NAND_DEVICE_ID_MT29F4G01 0x36
Expand Down Expand Up @@ -1031,6 +1032,21 @@ static const struct SPI_NAND_FLASH_INFO_T spi_nand_flash_tables[] = {
feature: SPI_NAND_FLASH_FEATURE_NONE,
},

{
mfr_id: _SPI_NAND_MANUFACTURER_ID_TOSHIBA,
dev_id: _SPI_NAND_DEVICE_ID_TC58CVG2S0HRAIJ,
ptr_name: "KIOXIA TC58CVG2S0HRAIJ",
device_size: _SPI_NAND_CHIP_SIZE_4GBIT,
page_size: _SPI_NAND_PAGE_SIZE_4KBYTE,
oob_size: _SPI_NAND_OOB_SIZE_128BYTE,
erase_size: _SPI_NAND_BLOCK_SIZE_256KBYTE,
dummy_mode: SPI_NAND_FLASH_READ_DUMMY_BYTE_APPEND,
read_mode: SPI_NAND_FLASH_READ_SPEED_MODE_DUAL,
write_mode: SPI_NAND_FLASH_WRITE_SPEED_MODE_SINGLE,
oob_free_layout: &ooblayout_toshiba_256,
feature: SPI_NAND_FLASH_FEATURE_NONE,
},

{
mfr_id: _SPI_NAND_MANUFACTURER_ID_MICRON,
dev_id: _SPI_NAND_DEVICE_ID_MT29F1G01,
Expand Down Expand Up @@ -2061,6 +2077,47 @@ static SPI_NAND_FLASH_RTN_T spi_nand_protocol_read_id_2 ( struct SPI_NAND_FLASH_
return (rtn_status);
}

/*------------------------------------------------------------------------------------
* FUNCTION: static SPI_NAND_FLASH_RTN_T spi_nand_protocol_read_id_3( struct SPI_NAND_FLASH_INFO_T *ptr_rtn_flash_id )
* PURPOSE : To implement the SPI nand protocol for read id.
* AUTHOR :
* CALLED BY
* -
* CALLS
* -
* PARAMs :
* INPUT : None
* OUTPUT: None
* RETURN : SPI_RTN_NO_ERROR - Successful. Otherwise - Failed.
* NOTES : Workaround Toshiba/KIOXIA
* MODIFICTION HISTORY:
*
*------------------------------------------------------------------------------------
*/
static SPI_NAND_FLASH_RTN_T spi_nand_protocol_read_id_3 ( struct SPI_NAND_FLASH_INFO_T *ptr_rtn_flash_id )
{
SPI_NAND_FLASH_RTN_T rtn_status = SPI_NAND_FLASH_RTN_NO_ERROR;
u8 dummy = 0;

/* 1. Chip Select Low */
_SPI_NAND_READ_CHIP_SELECT_LOW();

/* 2. Write op_cmd 0x9F (Read ID) */
_SPI_NAND_WRITE_ONE_BYTE( _SPI_NAND_OP_READ_ID );

/* 3. Read data (Manufacture ID and Device ID) */
_SPI_NAND_READ_NBYTE( &dummy, _SPI_NAND_LEN_ONE_BYTE, SPI_CONTROLLER_SPEED_SINGLE);
_SPI_NAND_READ_NBYTE( &(ptr_rtn_flash_id->mfr_id), _SPI_NAND_LEN_ONE_BYTE, SPI_CONTROLLER_SPEED_SINGLE);
_SPI_NAND_READ_NBYTE( &(ptr_rtn_flash_id->dev_id), _SPI_NAND_LEN_ONE_BYTE, SPI_CONTROLLER_SPEED_SINGLE);

/* 4. Chip Select High */
_SPI_NAND_READ_CHIP_SELECT_HIGH();

_SPI_NAND_DEBUG_PRINTF(SPI_NAND_FLASH_DEBUG_LEVEL_1, "spi_nand_protocol_read_id_3 : dummy = 0x%x, mfr_id = 0x%x, dev_id = 0x%x\n", dummy, ptr_rtn_flash_id->mfr_id, ptr_rtn_flash_id->dev_id);

return (rtn_status);
}


/*------------------------------------------------------------------------------------
* FUNCTION: static SPI_NAND_FLASH_RTN_T spi_nand_protocol_page_read( u32 page_number )
Expand Down Expand Up @@ -3745,6 +3802,40 @@ static SPI_NAND_FLASH_RTN_T spi_nand_probe( struct SPI_NAND_FLASH_INFO_T *ptr_rt
}
}

if ( rtn_status != SPI_NAND_FLASH_RTN_NO_ERROR )
{
/* Another protocol for read id (For example, the Toshiba/KIOXIA SPI NADN chip */
_SPI_NAND_SEMAPHORE_LOCK();
spi_nand_protocol_read_id_3( ptr_rtn_device_t );
_SPI_NAND_SEMAPHORE_UNLOCK();

for ( i = 0; i < (sizeof(spi_nand_flash_tables) / sizeof(struct SPI_NAND_FLASH_INFO_T)); i++)
{
_SPI_NAND_DEBUG_PRINTF(SPI_NAND_FLASH_DEBUG_LEVEL_1,"spi_nand_probe: table[%d]: mfr_id = 0x%x, dev_id = 0x%x\n", i, spi_nand_flash_tables[i].mfr_id, spi_nand_flash_tables[i].dev_id );

if ( ( (ptr_rtn_device_t->mfr_id) == spi_nand_flash_tables[i].mfr_id) &&
( (ptr_rtn_device_t->dev_id) == spi_nand_flash_tables[i].dev_id) )
{
ecc_size = ((spi_nand_flash_tables[i].device_size / spi_nand_flash_tables[i].erase_size) * ((spi_nand_flash_tables[i].erase_size / spi_nand_flash_tables[i].page_size) * spi_nand_flash_tables[i].oob_size));
ptr_rtn_device_t->device_size = ECC_fcheck ? spi_nand_flash_tables[i].device_size : spi_nand_flash_tables[i].device_size + ecc_size;
erase_oob_size = (spi_nand_flash_tables[i].erase_size / spi_nand_flash_tables[i].page_size) * spi_nand_flash_tables[i].oob_size;
ptr_rtn_device_t->erase_size = ECC_fcheck ? spi_nand_flash_tables[i].erase_size : spi_nand_flash_tables[i].erase_size + erase_oob_size;
ptr_rtn_device_t->page_size = ECC_fcheck ? spi_nand_flash_tables[i].page_size : spi_nand_flash_tables[i].page_size + spi_nand_flash_tables[i].oob_size;
ptr_rtn_device_t->oob_size = ECC_fcheck ? spi_nand_flash_tables[i].oob_size : 0;
bmt_oob_size = spi_nand_flash_tables[i].oob_size;
ptr_rtn_device_t->dummy_mode = spi_nand_flash_tables[i].dummy_mode;
ptr_rtn_device_t->read_mode = spi_nand_flash_tables[i].read_mode;
ptr_rtn_device_t->write_mode = spi_nand_flash_tables[i].write_mode;
memcpy( &(ptr_rtn_device_t->ptr_name) , &(spi_nand_flash_tables[i].ptr_name), sizeof(ptr_rtn_device_t->ptr_name));
memcpy( &(ptr_rtn_device_t->oob_free_layout) , &(spi_nand_flash_tables[i].oob_free_layout), sizeof(ptr_rtn_device_t->oob_free_layout));
ptr_rtn_device_t->feature = spi_nand_flash_tables[i].feature;

rtn_status = SPI_NAND_FLASH_RTN_NO_ERROR;
break;
}
}
}

_SPI_NAND_PRINTF("spi_nand_probe: mfr_id = 0x%x, dev_id = 0x%x\n", ptr_rtn_device_t->mfr_id, ptr_rtn_device_t->dev_id);
if(rtn_status == SPI_NAND_FLASH_RTN_NO_ERROR)
{
Expand Down

0 comments on commit ad7c19d

Please sign in to comment.