Skip to content

Commit

Permalink
New progress status, counter elapsed time and more cosmetic fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
McMCCRU committed Mar 2, 2021
1 parent 089fce9 commit ef51717
Show file tree
Hide file tree
Showing 22 changed files with 271 additions and 101 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.
2 changes: 1 addition & 1 deletion 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.6.2 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>

SPI NAND Flash Support List:
001. GIGADEVICE GD5F1GQ4UA
Expand Down
84 changes: 44 additions & 40 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.6.2 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>

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

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

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

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
spi_nand_probe: mfr_id = 0xc2, dev_id = 0x22
Get Status Register 1: 0x38
Get Status Register 2: 0x10
Using Flash ECC.
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>

Found programmer device: Winchiphead (WCH) - CH341A
Device revision is 3.0.4
Expand All @@ -32,98 +44,90 @@ Get Status Register 1: 0x81
Get Status Register 2: 0x18
Using Flash ECC.
Detected SPI NAND Flash: WINBOND W25N01G, Flash Size: 128 MB
igor@mcmcc-GL553VE:~/Soft/SNANDer-bin/Linux$

2. Full erase flash with disable internal ECC check. Without OOB, page size 2112 bytes.

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

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

Found programmer device: Winchiphead (WCH) - CH341A
Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
spi_nand_probe: mfr_id = 0xef, dev_id = 0xaa
Get Status Register 1: 0x81
Get Status Register 2: 0x18
spi_nand_probe: mfr_id = 0xc2, dev_id = 0x22
Get Status Register 1: 0x00
Get Status Register 2: 0x11
Disable Flash ECC.
Detected SPI NAND Flash: WINBOND W25N01G, Flash Size: 128 MB
Detected SPI NAND Flash: MXIC MX35LF2G, Flash Size: 256 MB
ERASE:
Set full erase chip!
Erase addr = 0x0000000000000000, len = 0x0000000008400000
Erase addr = 0x0000000000000000, len = 0x0000000010800000
Erase 100% [276824064] of [276824064] bytes
Elapsed time: 3 seconds
Status: OK
igor@mcmcc-GL553VE:~/Soft/SNANDer-bin/Linux$

3. Write and verify flash with disable internal ECC check. Without OOB, page size 2112 bytes.

igor@mcmcc-GL553VE:~/Soft/SNANDer-bin/Linux$ ./SNANDer -d -v -w ecc_1Gb_2K_64_flashimage_rfb1_ac2600.bin
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.6.2 by McMCC <mcmcc_at_mail.ru>
SNANDer - Serial Nor/nAND/Eeprom programmeR v.1.7 by McMCC <mcmcc_at_mail.ru>

Found programmer device: Winchiphead (WCH) - CH341A
Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
spi_nand_probe: mfr_id = 0xef, dev_id = 0xaa
Get Status Register 1: 0x81
Get Status Register 2: 0x08
spi_nand_probe: mfr_id = 0xc2, dev_id = 0x22
Get Status Register 1: 0x00
Get Status Register 2: 0x11
Disable Flash ECC.
Detected SPI NAND Flash: WINBOND W25N01G, Flash Size: 128 MB
Detected SPI NAND Flash: MXIC MX35LF2G, Flash Size: 256 MB
WRITE:
Write addr = 0x0000000000000000, len = 0x0000000001080000
snand_erase_write: offs:0, count:1080000
..........................................................................................................
..........................................................................................................
..........................................................................................................
..........................................................................................................
........................................................................................................Done!
Write addr = 0x0000000000000000, len = 0x000000000E5A9D6F
Written 100% [240819567] of [240819567] bytes
Elapsed time: 4184 seconds
Status: OK
VERIFY:
Read addr = 0x0000000000000000, len = 0x0000000001080000
Read addr = 0x0000000000000000, len = 0x000000000E5A9D6F
Read 100% [240819567] of [240819567] bytes
Elapsed time: 2047 seconds
Status: OK

4. Read Microwire EEPROM Atmel 93C46 and save file.

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

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

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
spi_nand_probe: mfr_id = 0xff, dev_id = 0xff
SPI NAND Flash Not Detected!
spi device id: ff ff ff ff ff (ffffffff)
SPI NOR Flash Not Detected!
I2C EEPROM Not Detected!
Microwire EEPROM chip: 93c46, Size: 64 bytes, Org: 16 bits, fix addr len: Auto
READ:
Read addr = 0x0000000000000000, len = 0x0000000000000080
Read_EEPROM_3wire: Set address len 6 bits
............................................................
Read 100% [64] of [64] bytes
Read [128] bytes from [93c46] EEPROM address 0x00000000
Elapsed time: 0 seconds
Status: OK

5. Write and verify Microwire EEPROM Atmel 93C46 from file.

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

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

Found programmer device: WinChipHead (WCH) - CH341A
Device revision is 3.0.4
spi_nand_probe: mfr_id = 0xff, dev_id = 0xff
SPI NAND Flash Not Detected!
spi device id: ff ff ff ff ff (ffffffff)
SPI NOR Flash Not Detected!
I2C EEPROM Not Detected!
Microwire EEPROM chip: 93c46, Size: 64 bytes, Org: 16 bits, fix addr len: Auto
WRITE:
Write addr = 0x0000000000000000, len = 0x0000000000000080
Erase_EEPROM_3wire: Set address len 6 bits
Write_EEPROM_3wire: Set address len 6 bits
............................................................
Written 100% [64] of [64] bytes
Wrote [128] bytes to [93c46] EEPROM address 0x00000000
Elapsed time: 1 seconds
Status: OK
VERIFY:
Read addr = 0x0000000000000000, len = 0x0000000000000080
Read_EEPROM_3wire: Set address len 6 bits
............................................................
Read 100% [64] of [64] bytes
Read [128] bytes from [93c46] EEPROM address 0x00000000
Elapsed time: 1 seconds
Status: OK
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EEPROM_SUPPORT = y
BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-O2 -std=gnu99 -static -Wall -I./lusb_build/include $(BIGFILES)

OBJS= flashcmd_api.o spi_controller.o spi_nand_flash.o spi_nor_flash.o ch341a_spi.o main.o
OBJS= flashcmd_api.o spi_controller.o spi_nand_flash.o spi_nor_flash.o ch341a_spi.o timer.o main.o

ifeq ($(EEPROM_SUPPORT),y)
CFLAGS += -DEEPROM_SUPPORT
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.osx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CFLAGS=-O2 -std=gnu99 -Wall -Wno-gnu-designator -I./lusb_build_osx/include $(BIG
U=lusb_build_osx/libusb
O=lusb_build_osx/libusb/os

OBJS = flashcmd_api.o spi_controller.o spi_nand_flash.o spi_nor_flash.o ch341a_spi.o main.o
OBJS = flashcmd_api.o spi_controller.o spi_nand_flash.o spi_nor_flash.o ch341a_spi.o timer.o main.o
USB_OBJS += $(U)/libusb_1_0_la-core.o $(U)/libusb_1_0_la-descriptor.o $(U)/libusb_1_0_la-hotplug.o \
$(U)/libusb_1_0_la-io.o $(U)/libusb_1_0_la-strerror.o $(U)/libusb_1_0_la-sync.o \
$(O)/libusb_1_0_la-darwin_usb.o $(O)/libusb_1_0_la-poll_posix.o $(O)/libusb_1_0_la-threads_posix.o
Expand Down
9 changes: 6 additions & 3 deletions src/Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ EEPROM_SUPPORT = y
BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=-O2 -std=gnu99 -posix -static -Wall -I./lusb_build_win/include $(BIGFILES)

OBJS= flashcmd_api.o spi_controller.o spi_nand_flash.o spi_nor_flash.o ch341a_spi.o main.o
OBJS= flashcmd_api.o spi_controller.o spi_nand_flash.o spi_nor_flash.o ch341a_spi.o timer.o main.o

ifeq ($(EEPROM_SUPPORT),y)
CFLAGS += -DEEPROM_SUPPORT
Expand All @@ -26,8 +26,11 @@ all: SNANDer.exe
make install
touch $@

SNANDer.exe: .lusb_install_win $(OBJS)
$(CC) $(CFLAGS) -s -o $@ $(OBJS) $(LDFLAGS)
res.o:
x86_64-w64-mingw32-windres -i snander.rc -o res.o

SNANDer.exe: .lusb_install_win $(OBJS) res.o
$(CC) $(CFLAGS) -s -o $@ $(OBJS) res.o $(LDFLAGS)

.c.o:
$(CC) $(CFLAGS) -c $<
Expand Down
19 changes: 8 additions & 11 deletions src/bitbang_microwire.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ void Erase_EEPROM_3wire(int size_eeprom)
int i, num_bit;

num_bit = addr_nbits(__func__, size_eeprom);
size_eeprom = convert_size(size_eeprom);

enable_write_3wire(num_bit);
csel_0();
Expand Down Expand Up @@ -339,13 +338,12 @@ int Read_EEPROM_3wire(unsigned char *buffer, int size_eeprom)
delay_ms(1);
clock_1();
delay_ms(1);
printf("\bRead %d%% [%d] of [%d] bytes ", 100 * l / size_eeprom, l, size_eeprom);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
address++;
if (l % (org ? 16 : 8)) {
printf(".");
fflush(stdout);
}
}
printf("\n");
printf("Read 100%% [%d] of [%d] bytes \n", l, size_eeprom);
return 0;
}

Expand Down Expand Up @@ -408,13 +406,12 @@ int Write_EEPROM_3wire(unsigned char *buffer, int size_eeprom)
delay_ms(1);
clock_1();
delay_ms(1);
printf("\bWritten %d%% [%d] of [%d] bytes ", 100 * l / size_eeprom, l, size_eeprom);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
address++;
if (l % (org ? 16 : 8)) {
printf(".");
fflush(stdout);
}
}
printf("\n");
printf("Written 100%% [%d] of [%d] bytes \n", l, size_eeprom);
disable_write_3wire(num_bit);

return 0;
Expand Down
10 changes: 8 additions & 2 deletions src/ch341a_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ int32_t ch341readEEPROM(uint8_t *buffer, uint32_t bytestoread, struct EEPROM *ee
readbuf = buffer;

while (1) {
printf("Read %d%% [%d] of [%d] bytes \r", 100 * byteoffset / bytestoread, byteoffset, bytestoread);
printf("Read %d%% [%d] of [%d] bytes ", 100 * byteoffset / bytestoread, byteoffset, bytestoread);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
ret = libusb_handle_events_timeout(NULL, &tv);

if (ret < 0 || getnextpkt == -1) { // indicates an error
Expand Down Expand Up @@ -182,6 +184,7 @@ int32_t ch341readEEPROM(uint8_t *buffer, uint32_t bytestoread, struct EEPROM *ee
}
}
}
printf("Read 100%% [%d] of [%d] bytes \n", byteoffset, bytestoread);

libusb_free_transfer(xferBulkIn);
libusb_free_transfer(xferBulkOut);
Expand Down Expand Up @@ -321,8 +324,11 @@ int32_t ch341writeEEPROM(uint8_t *buffer, uint32_t bytesum, struct EEPROM *eepro
return -1;
}
*/
printf("Written %d%% [%d] of [%d] bytes \r", 100 * (bytesum - bytes) / bytesum, bytesum - bytes, bytesum);
printf("\bWritten %d%% [%d] of [%d] bytes ", 100 * (bytesum - bytes) / bytesum, bytesum - bytes, bytesum);
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
fflush(stdout);
}
printf("Written 100%% [%d] of [%d] bytes \n", bytesum - bytes, bytesum);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions src/ch341a_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,9 @@ int ch341a_spi_init(void)
}
printf("Found programmer device: %s - %s\n", devs_ch341a_spi[0].vendor_name, devs_ch341a_spi[0].device_name);

/* libusb_detach_kernel_driver() and friends basically only work on Linux. We simply try to detach on Linux
* without a lot of passion here. If that works fine else we will fail on claiming the interface anyway. */
#if 1 /* IS_LINUX */
#ifdef __gnu_linux__
/* libusb_detach_kernel_driver() and friends basically only work on Linux. We simply try to detach on Linux
* without a lot of passion here. If that works fine else we will fail on claiming the interface anyway. */
ret = libusb_detach_kernel_driver(handle, 0);
if (ret == LIBUSB_ERROR_NOT_SUPPORTED) {
printf("Detaching kernel drivers is not supported. Further accesses may fail.\n");
Expand Down
46 changes: 28 additions & 18 deletions src/flashcmd_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#ifdef EEPROM_SUPPORT
#define __EEPROM___ "or EEPROM"
extern int eepromsize;
extern int mw_eepromsize;
#else
#define __EEPROM___ ""
#endif
Expand All @@ -26,26 +28,33 @@ long flash_cmd_init(struct flash_cmd *cmd)
{
long flen = -1;

if((flen = snand_init()) > 0) {
cmd->flash_erase = snand_erase;
cmd->flash_write = snand_write;
cmd->flash_read = snand_read;
} else if ((flen = snor_init()) > 0) {
cmd->flash_erase = snor_erase;
cmd->flash_write = snor_write;
cmd->flash_read = snor_read;
#ifdef EEPROM_SUPPORT
} else if ((flen = i2c_init()) > 0) {
cmd->flash_erase = i2c_eeprom_erase;
cmd->flash_write = i2c_eeprom_write;
cmd->flash_read = i2c_eeprom_read;
} else if ((flen = mw_init()) > 0) {
cmd->flash_erase = mw_eeprom_erase;
cmd->flash_write = mw_eeprom_write;
cmd->flash_read = mw_eeprom_read;
if ((eepromsize <= 0) && (mw_eepromsize <= 0)) {
#endif
} else
printf("\nNot Flash" __EEPROM___ " detected!!!!\n\n");
if ((flen = snand_init()) > 0) {
cmd->flash_erase = snand_erase;
cmd->flash_write = snand_write;
cmd->flash_read = snand_read;
} else if ((flen = snor_init()) > 0) {
cmd->flash_erase = snor_erase;
cmd->flash_write = snor_write;
cmd->flash_read = snor_read;
}
#ifdef EEPROM_SUPPORT
} else if ((eepromsize > 0) || (mw_eepromsize > 0)) {
if ((eepromsize > 0) && (flen = i2c_init()) > 0) {
cmd->flash_erase = i2c_eeprom_erase;
cmd->flash_write = i2c_eeprom_write;
cmd->flash_read = i2c_eeprom_read;
} else if ((mw_eepromsize > 0) && (flen = mw_init()) > 0) {
cmd->flash_erase = mw_eeprom_erase;
cmd->flash_write = mw_eeprom_write;
cmd->flash_read = mw_eeprom_read;
}
}
#endif
else
printf("\nFlash" __EEPROM___ " not found!!!!\n\n");

return flen;
}
Expand All @@ -62,3 +71,4 @@ void support_flash_list(void)
support_mw_eeprom_list();
#endif
}
/* End of [flashcmd.c] package */
Loading

0 comments on commit ef51717

Please sign in to comment.