LPC2900: Avoid false positive reprobing if first probing fails
authorRolf Meeser <rolfm_9dq@yahoo.de>
Sat, 27 Nov 2010 22:09:59 +0000 (23:09 +0100)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Wed, 1 Dec 2010 07:47:51 +0000 (08:47 +0100)
src/flash/nor/lpc2900.c

index e17823ec2dee513eb63c29de21022960d7b84fa9..99d6d1dc1b6bff614355aaf5a56351e3c0fedc59 100644 (file)
  */
 struct lpc2900_flash_bank
 {
+       /**
+        * This flag is set when the device has been successfully probed.
+        */
+       bool is_probed;
+
        /**
         * Holds the value read from CHIPID register.
         * The driver will not load if the chipid doesn't match the expected
@@ -255,7 +260,7 @@ static uint32_t lpc2900_is_ready( struct flash_bank *bank )
 {
        struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv;
 
-       if( lpc2900_info->chipid != EXPECTED_CHIPID )
+       if( !lpc2900_info->is_probed )
        {
                return ERROR_FLASH_BANK_NOT_PROBED;
        }
@@ -512,8 +517,6 @@ static uint32_t lpc2900_calc_tr( uint32_t clock_var, uint32_t time_var )
        /*           ((time[µs]/1e6) * f[Hz]) + 511
         * FPTR.TR = -------------------------------
         *                         512
-        *
-        * The result is the
         */
 
        uint32_t tr_val = (uint32_t)((((time_var / 1e6) * clock_var) + 511.0) / 512.0);
@@ -1050,6 +1053,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command)
 
        /* Chip ID will be obtained by probing the device later */
        lpc2900_info->chipid = 0;
+       lpc2900_info->is_probed = false;
 
        return ERROR_OK;
 }
@@ -1554,10 +1558,8 @@ static int lpc2900_probe(struct flash_bank *bank)
                return ERROR_TARGET_NOT_HALTED;
        }
 
-       /* We want to do this only once. Check if we already have a valid CHIPID,
-        * because then we will have already successfully probed the device.
-        */
-       if (lpc2900_info->chipid == EXPECTED_CHIPID)
+       /* We want to do this only once. */
+       if (lpc2900_info->is_probed)
        {
                return ERROR_OK;
        }
@@ -1723,6 +1725,8 @@ static int lpc2900_probe(struct flash_bank *bank)
                offset += bank->sectors[i].size;
        }
 
+       lpc2900_info->is_probed = true;
+
        /* Read sector security status */
        if ( lpc2900_read_security_status(bank) != ERROR_OK )
        {

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)