flash/nor/tcl.c: add filld command to write double-word with 64-bit value 43/5443/2
authorTarek BOCHKATI <tarek.bouchkati@gmail.com>
Fri, 7 Feb 2020 17:36:29 +0000 (18:36 +0100)
committerTomas Vanek <vanekt@fbl.cz>
Sun, 23 Feb 2020 21:33:58 +0000 (21:33 +0000)
Change-Id: I2eeda7af7d855ed1284083d025994f8fa9531969
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: http://openocd.zylin.com/5443
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
doc/openocd.texi
src/flash/nor/tcl.c

index cdec3b0..de7dceb 100644 (file)
@@ -5074,10 +5074,11 @@ If @option{unlock} is specified, then the flash is unprotected
 before erase starts.
 @end deffn
 
-@deffn Command {flash fillw} address word length
+@deffn Command {flash filld} address double-word length
+@deffnx Command {flash fillw} address word length
 @deffnx Command {flash fillh} address halfword length
 @deffnx Command {flash fillb} address byte length
-Fills flash memory with the specified @var{word} (32 bits),
+Fills flash memory with the specified @var{double-word} (64 bits), @var{word} (32 bits),
 @var{halfword} (16 bits), or @var{byte} (8-bit) pattern,
 starting at @var{address} and continuing
 for @var{length} units (word/halfword/byte).
index bd313a0..3287dd9 100644 (file)
@@ -476,7 +476,7 @@ COMMAND_HANDLER(handle_flash_write_image_command)
 COMMAND_HANDLER(handle_flash_fill_command)
 {
        target_addr_t address;
-       uint32_t pattern;
+       uint64_t pattern;
        uint32_t count;
        struct target *target = get_current_target(CMD_CTX);
        unsigned i;
@@ -487,7 +487,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        COMMAND_PARSE_ADDRESS(CMD_ARGV[0], address);
-       COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], pattern);
+       COMMAND_PARSE_NUMBER(u64, CMD_ARGV[1], pattern);
        COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], count);
 
        struct flash_bank *bank;
@@ -496,6 +496,9 @@ COMMAND_HANDLER(handle_flash_fill_command)
                return retval;
 
        switch (CMD_NAME[4]) {
+               case 'd':
+                       wordsize = 8;
+                       break;
                case 'w':
                        wordsize = 4;
                        break;
@@ -541,6 +544,10 @@ COMMAND_HANDLER(handle_flash_fill_command)
        uint8_t *ptr = buffer + padding_at_start;
 
        switch (wordsize) {
+               case 8:
+                       for (i = 0; i < count; i++, ptr += wordsize)
+                               target_buffer_set_u64(target, ptr, pattern);
+                       break;
                case 4:
                        for (i = 0; i < count; i++, ptr += wordsize)
                                target_buffer_set_u32(target, ptr, pattern);
@@ -577,9 +584,12 @@ COMMAND_HANDLER(handle_flash_fill_command)
                goto done;
 
        for (i = 0, ptr = buffer; i < count; i++) {
-               uint32_t readback = 0;
+               uint64_t readback = 0;
 
                switch (wordsize) {
+                       case 8:
+                               readback = target_buffer_get_u64(target, ptr);
+                               break;
                        case 4:
                                readback = target_buffer_get_u32(target, ptr);
                                break;
@@ -593,7 +603,7 @@ COMMAND_HANDLER(handle_flash_fill_command)
                if (readback != pattern) {
                        LOG_ERROR(
                                "Verification error address " TARGET_ADDR_FMT
-                               ", read back 0x%02" PRIx32 ", expected 0x%02" PRIx32,
+                               ", read back 0x%02" PRIx64 ", expected 0x%02" PRIx64,
                                address + i * wordsize, readback, pattern);
                        retval = ERROR_FAIL;
                        goto done;
@@ -1003,6 +1013,14 @@ static const struct command_registration flash_exec_command_handlers[] = {
 
        },
        {
+               .name = "filld",
+               .handler = handle_flash_fill_command,
+               .mode = COMMAND_EXEC,
+               .usage = "address value n",
+               .help = "Fill n double-words with 64-bit value, starting at "
+                       "word address.  (No autoerase.)",
+       },
+       {
                .name = "fillw",
                .handler = handle_flash_fill_command,
                .mode = COMMAND_EXEC,