This is an automated email from Gerrit. Spencer Oliver (s...@spen-soft.co.uk) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/1635
-- gerrit commit ec2a8cd9505afd51f03b151714b6697a4490bbe3 Author: Spencer Oliver <s...@spen-soft.co.uk> Date: Thu Sep 19 12:07:06 2013 +0100 flash: add padded_value cmd This adds support for setting the default value used when padding image sections. Previously 0xff was used but some targets have an erased value of 0x00. Change-Id: If3df6fea3abf95b09daa3ff7be362acf991070ce Signed-off-by: Spencer Oliver <s...@spen-soft.co.uk> diff --git a/doc/openocd.texi b/doc/openocd.texi index a747f9a..a2d18e0 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -4851,6 +4851,12 @@ specifies "to the end of the flash bank". The @var{num} parameter is a value shown by @command{flash banks}. @end deffn +@deffn Command {flash padded_value} num value +Sets the default value used for padding any image sections, This should +normally match the flash bank erased value. If not specified by this +comamnd or the flash driver then it defaults to 0xff. +@end deffn + @anchor{program} @deffn Command {program} filename [verify] [reset] [offset] This is a helper script that simplifies using OpenOCD as a standalone diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index 21ea05d..e61b303 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -710,7 +710,7 @@ int flash_write_unlock(struct target *target, struct image *image, /* see if we need to pad the section */ while (padding[section]--) - (buffer + buffer_size)[size_read++] = 0xff; + (buffer + buffer_size)[size_read++] = c->default_padded_value; buffer_size += size_read; section_offset += size_read; diff --git a/src/flash/nor/core.h b/src/flash/nor/core.h index 07b095f..726dd95 100644 --- a/src/flash/nor/core.h +++ b/src/flash/nor/core.h @@ -87,6 +87,10 @@ struct flash_bank { int chip_width; /**< Width of the chip in bytes (1,2,4 bytes) */ int bus_width; /**< Maximum bus width, in bytes (1,2,4 bytes) */ + /** Default padded value used, normally this matches the flash + * erased value. Defaults to 0xFF. */ + uint8_t default_padded_value; + /** * The number of sectors on this chip. This value will * be set intially to 0, and the flash driver must set this to diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 57c3be5..bbb85ab 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -604,6 +604,24 @@ void flash_set_dirty(void) } } +COMMAND_HANDLER(handle_flash_padded_value_command) +{ + if (CMD_ARGC != 2) + return ERROR_COMMAND_SYNTAX_ERROR; + + struct flash_bank *p; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &p); + if (ERROR_OK != retval) + return retval; + + COMMAND_PARSE_NUMBER(u8, CMD_ARGV[1], p->default_padded_value); + + command_print(CMD_CTX, "Default padded value set to 0x%" PRIx8 " for flash bank %u", \ + p->default_padded_value, p->bank_number); + + return retval; +} + static const struct command_registration flash_exec_command_handlers[] = { { .name = "probe", @@ -699,6 +717,13 @@ static const struct command_registration flash_exec_command_handlers[] = { .help = "Turn protection on or off for a range of sectors " "in a given flash bank.", }, + { + .name = "padded_value", + .handler = handle_flash_padded_value_command, + .mode = COMMAND_EXEC, + .usage = "bank_id value", + .help = "Set default flash padded value", + }, COMMAND_REGISTRATION_DONE }; @@ -711,7 +736,6 @@ static int flash_init_drivers(struct command_context *cmd_ctx) return register_commands(cmd_ctx, parent, flash_exec_command_handlers); } - COMMAND_HANDLER(handle_flash_bank_command) { if (CMD_ARGC < 7) { @@ -764,6 +788,7 @@ COMMAND_HANDLER(handle_flash_bank_command) COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], c->size); COMMAND_PARSE_NUMBER(int, CMD_ARGV[3], c->chip_width); COMMAND_PARSE_NUMBER(int, CMD_ARGV[4], c->bus_width); + c->default_padded_value = 0xff; c->num_sectors = 0; c->sectors = NULL; c->next = NULL; diff --git a/src/flash/nor/virtual.c b/src/flash/nor/virtual.c index 45738ed..fab521d 100644 --- a/src/flash/nor/virtual.c +++ b/src/flash/nor/virtual.c @@ -46,6 +46,7 @@ static void virtual_update_bank_info(struct flash_bank *bank) bank->size = master_bank->size; bank->chip_width = master_bank->chip_width; bank->bus_width = master_bank->bus_width; + bank->default_padded_value = master_bank->default_padded_value; bank->num_sectors = master_bank->num_sectors; bank->sectors = master_bank->sectors; } -- ------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel