ch341prog
ch341prog copied to clipboard
chip erase timeout
when i try to erase some 25q128, sometimes an error appears after a some minuts: chip erase timeout.
when i try to erase some 25qxx, sometimes an error appears after a some minuts: chip erase timeout. I changed the timeout value in main.c (line 183) to 500 seconds, now I no longer get the error but the memory is not reset
It could be fixed with #21
It may also not. In my experience, some chips got locked by flash protection bits, see 10.1.3-10.1.6 in https://www.elinux.org/images/f/f5/Winbond-w25q32.pdf
I got it fixed by following code (it's commented now), I'll submit a proper patch when I experience it again (not sure if both commands are needed)
diff --git a/ch341a.c b/ch341a.c
index 8caeeab..66b41db 100644
--- a/ch341a.c
+++ b/ch341a.c
@@ -334,14 +334,25 @@ int32_t ch341WriteStatus(uint8_t status)
/* chip erase */
int32_t ch341EraseChip(void)
{
- uint8_t out[1];
- uint8_t in[1];
+ uint8_t out[2];
+ uint8_t in[2];
int32_t ret;
if (devHandle == NULL) return -1;
out[0] = 0x06; // Write enable
ret = ch341SpiStream(out, in, 1);
if (ret < 0) return ret;
+/*
+ out[0] = 0x01; // Set status register
+ out[1] = 0x00; // all to 0
+ ret = ch341SpiStream(out, in, 2);
+// while (ch341ReadStatus() > 0){
+// sleep(1);
+// }
+ out[0] = 0x98; // Global block unlock
+ ret = ch341SpiStream(out, in, 1);
+ if (ret < 0) return ret;
+*/
out[0] = 0xC7; // Chip erase
ret = ch341SpiStream(out, in, 1);
if (ret < 0) return ret;
@setarcos ,can you please reopen?