added 1000ms timeout
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 26 Aug 2008 11:30:34 +0000 (11:30 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 26 Aug 2008 11:30:34 +0000 (11:30 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@970 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/flash/str9x.c

index e781c144d08021936572f84701a75edea43ad33d..94a2a1cf15e32ca38cc78317386f22a4012520cd 100644 (file)
@@ -305,8 +305,9 @@ int str9x_erase(struct flash_bank_s *bank, int first, int last)
                {
                        return retval;
                }
-               
-               while (1) {
+
+               int i;          
+               for (i=0; i<1000; i++) {
                        if ((retval=target_read_u8(target, adr, &status))!=ERROR_OK)
                        {
                                return retval;
@@ -315,6 +316,11 @@ int str9x_erase(struct flash_bank_s *bank, int first, int last)
                                break;
                        alive_sleep(1);
                }
+               if (i==1000)
+               {
+                       LOG_ERROR("erase timed out");
+                       return ERROR_FAIL;
+               }
                
                /* clear status, also clear read array */
                if ((retval=target_write_u16(target, adr, 0x50))!=ERROR_OK)
@@ -571,13 +577,20 @@ int str9x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                
                /* get status command */
                target_write_u16(target, bank_adr, 0x70);
-               
-               while (1) {
+       
+               int i;
+               for (i=0; i<1000; i++)
+               {       
                        target_read_u8(target, bank_adr, &status);
                        if( status & 0x80 )
                                break;
                        alive_sleep(1);
                }
+               if (i==1000)
+               {
+                       LOG_ERROR("write timed out");
+                       return ERROR_FAIL;
+               }
                
                /* clear status reg and read array */
                target_write_u16(target, bank_adr, 0x50);
@@ -614,12 +627,19 @@ int str9x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
                /* query status command */
                target_write_u16(target, bank_adr, 0x70);
                
-               while (1) {
+               int i;
+               for (i=0; i<1000; i++)
+               {       
                        target_read_u8(target, bank_adr, &status);
                        if( status & 0x80 )
                                break;
                        alive_sleep(1);
                }
+               if (i==1000)
+               {
+                       LOG_ERROR("write timed out");
+                       return ERROR_FAIL;
+               }
                
                /* clear status reg and read array */
                target_write_u16(target, bank_adr, 0x50);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)