Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chip erase timeout #7

Open
gcat000 opened this issue Apr 20, 2016 · 3 comments
Open

chip erase timeout #7

gcat000 opened this issue Apr 20, 2016 · 3 comments

Comments

@gcat000
Copy link

gcat000 commented Apr 20, 2016

when i try to erase some 25q128, sometimes an error appears after a some minuts:
chip erase timeout.

@msiqueira553
Copy link

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

@dronov
Copy link
Contributor

dronov commented Nov 25, 2018

It could be fixed with #21

@setarcos setarcos closed this as completed Jan 9, 2019
@danielkucera
Copy link
Contributor

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?

@setarcos setarcos reopened this Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants