flash/nor/lpcspifi.c: fix bug that prevented clean reset after flash write 59/2359/2
authorAnders <anders@openpuma.org>
Mon, 27 Oct 2014 19:55:50 +0000 (12:55 -0700)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 24 Nov 2014 22:14:38 +0000 (22:14 +0000)
After SPI flash was written by the assembly language stub,
the last SPI command was not terminated by raising CS.
This left the SPI device in a hung state that prevented the
flash from being read by the M4 SPIFI controller, even after
the M4 was fully reset. To access the flash via SPIFI, it was
necessary to completely power cycle the board.

This fix adds the missing instructions to raise CS and
terminate the SPI command after the last byte. This allows
the M4 to be resumed or reset cleanly after flashing. The
SPIFI memory is now immediately accessable at address
0x1400 0000 after flashing is complete.

Change-Id: I4d5e03bded0fa00c430c2991f182dc18611d5f48
Signed-off-by: Anders <anders@openpuma.org>
Reviewed-on: http://openocd.zylin.com/2359
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
contrib/loaders/flash/lpcspifi_write.S
src/flash/nor/lpcspifi.c

index d47129769659744e4c8c81d7f705b15387bc9880..8435a20453ffff142899a9b9d004046e0a008095 100644 (file)
  * r11 - current page end address
  */
 
  * r11 - current page end address
  */
 
+/*
+ * This code is embedded within: src/flash/nor/lpcspifi.c as a "C" array.
+ *
+ * To rebuild:
+ *   arm-none-eabi-gcc -c lpcspifi_write.S
+ *   arm-none-eabi-objcopy -O binary lpcspifi_write.o lpcspifi_write.bin
+ *   xxd -c 8 -i lpcspifi_write.bin > lpcspifi_write.txt
+ *
+ * Then read and edit this result into the "C" source.
+ */
+
 #define SSP_BASE_HIGH                          0x4008
 #define SSP_BASE_LOW                           0x3000
 #define SSP_CR0_OFFSET                         0x00
 #define SSP_BASE_HIGH                          0x4008
 #define SSP_BASE_LOW                           0x3000
 #define SSP_CR0_OFFSET                         0x00
@@ -204,6 +215,7 @@ error:
        movs    r0, #0
        str     r0, [r2, #4]    /* set rp = 0 on error */
 exit:
        movs    r0, #0
        str     r0, [r2, #4]    /* set rp = 0 on error */
 exit:
+       bl              cs_up                   /* end the command before returning */
        mov     r0, r6
        bkpt    #0x00
 
        mov     r0, r6
        bkpt    #0x00
 
index 7355c30a9ceacc627e9a6d80e1d7d253311cc26a..3b383ebd996004acddff62d4cbd7c1a11a1e80e1 100644 (file)
@@ -688,7 +688,8 @@ static int lpcspifi_write(struct flash_bank *bank, const uint8_t *buffer,
                0x00, 0xf0, 0x02, 0xb8, 0x4f, 0xf0, 0x00, 0x08,
                0x4f, 0xf4, 0x80, 0x4a, 0xc4, 0xf2, 0x0f, 0x0a,
                0xca, 0xf8, 0xab, 0x80, 0x70, 0x47, 0x00, 0x20,
                0x00, 0xf0, 0x02, 0xb8, 0x4f, 0xf0, 0x00, 0x08,
                0x4f, 0xf4, 0x80, 0x4a, 0xc4, 0xf2, 0x0f, 0x0a,
                0xca, 0xf8, 0xab, 0x80, 0x70, 0x47, 0x00, 0x20,
-               0x50, 0x60, 0x30, 0x46, 0x00, 0xbe, 0xff, 0xff
+               0x50, 0x60, 0xff, 0xf7, 0xef, 0xff, 0x30, 0x46,
+               0x00, 0xbe, 0xff, 0xff
        };
 
        if (target_alloc_working_area(target, sizeof(lpcspifi_flash_write_code),
        };
 
        if (target_alloc_working_area(target, sizeof(lpcspifi_flash_write_code),

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)