AT91SAM4L: Fix bug when writing to flash at a non-zero offset, add debug 65/1965/2
authorAngus Gratton <gus@projectgus.com>
Wed, 12 Feb 2014 11:32:47 +0000 (22:32 +1100)
committerPaul Fertser <fercerpav@gmail.com>
Sat, 29 Mar 2014 07:15:36 +0000 (07:15 +0000)
output for flash page writes

The offset wasn't being considered in the "full page" write codepath, so any
writes at an offset were actually written out starting from page 0.

Change-Id: I5e70a1f35f144b3edd1ce6d9df9af9b5da6cf194
Signed-off-by: Angus Gratton <gus@projectgus.com>
Reviewed-on: http://openocd.zylin.com/1965
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
src/flash/nor/at91sam4l.c

index 9f1319b663754c9af4102bc81fbea57f74a9ec50..0139f61c87b84dc5797301c20abe8f415341af0f 100644 (file)
@@ -499,6 +499,8 @@ static int sam4l_write_page(struct sam4l_info *chip, struct target *target,
 {
        int res;
 
+       LOG_DEBUG("sam4l_write_page address=%08" PRIx32, address);
+
        /* Clear the page buffer before we write to it */
        res = sam4l_flash_command(target, SAM4L_FCMD_CPB, -1);
        if (res != ERROR_OK) {
@@ -535,6 +537,8 @@ static int sam4l_write_page_partial(struct sam4l_info *chip,
        if (!pg)
                return ERROR_FAIL;
 
+       LOG_DEBUG("sam4l_write_page_partial address=%08" PRIx32 " nb=%08" PRIx32, address, nb);
+
        assert(page_offset + nb < chip->page_size);
        assert((address % chip->page_size) == 0);
 
@@ -563,6 +567,8 @@ static int sam4l_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t nb = 0;
        struct sam4l_info *chip = (struct sam4l_info *)bank->driver_priv;
 
+       LOG_DEBUG("sam4l_write offset=%08" PRIx32 " count=%08" PRIx32, offset, count);
+
        if (bank->target->state != TARGET_HALTED) {
                LOG_ERROR("Target not halted");
 
@@ -605,14 +611,14 @@ static int sam4l_write(struct flash_bank *bank, const uint8_t *buffer,
                for (int i = 0; i < np; i++) {
                        if (count >= chip->page_size) {
                                res = sam4l_write_page(chip, bank->target,
-                                               bank->base + (i * chip->page_size),
+                                               bank->base + offset,
                                                buffer + (i * chip->page_size));
                                /* Advance one page */
                                offset += chip->page_size;
                                count -= chip->page_size;
                        } else {
                                res = sam4l_write_page_partial(chip, bank,
-                                               bank->base + (i * chip->page_size),
+                                               bank->base + offset,
                                                buffer + (i * chip->page_size), 0, count);
                                /* We're done after this. */
                                offset += count;

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)