This patch slightly enhances the behaviour of the standard erase and protect
functions. After applying this patch, defining -1 as the last sector tells
OpenOCD to protect or erase the entire flash bank. The relevant part in the
OpenOCD has been updated.
Signed-off-by: Johnny Halfmoon <jhalfmoon at milksnot.com>
---
doc/openocd.texi | 6 ++++--
src/flash/flash.c | 6 ++++++
2 files changed, 10 insertions(+), 2 deletions(-)
Index: trunk/src/flash/flash.c
===================================================================
--- trunk/src/flash/flash.c (revision 2736)
+++ trunk/src/flash/flash.c (working copy)
@@ -577,6 +577,9 @@
return ERROR_COMMAND_SYNTAX_ERROR;
}
+ if (last < 0)
+ last = p->num_sectors - 1;
+
if ((retval = flash_driver_erase(p, first, last)) == ERROR_OK)
{
if ((retval = duration_stop_measure(&duration,
&duration_text)) != ERROR_OK)
@@ -621,6 +624,9 @@
return ERROR_COMMAND_SYNTAX_ERROR;
}
+ if (last < 0)
+ last = p->num_sectors - 1;
+
retval = flash_driver_protect(p, set, first, last);
if (retval == ERROR_OK)
{
Index: trunk/doc/openocd.texi
===================================================================
--- trunk/doc/openocd.texi (revision 2736)
+++ trunk/doc/openocd.texi (working copy)
@@ -3071,7 +3071,8 @@
@anchor{flash erase_sector}
@deffn Command {flash erase_sector} num first last
Erase sectors in bank @var{num}, starting at sector @var{first} up to and
including
-...@var{last}. Sector numbering starts at 0.
+...@var{last}. Sector numbering starts at 0. Defining a @var{last} sector of
-1 is
+equivalent to defining (max_sectors-1), i.e. erasing the entire bank.
The @var{num} parameter is a value shown by @command{flash banks}.
@end deffn
@@ -3144,7 +3145,8 @@
@anchor{flash protect}
@deffn Command {flash protect} num first last (on|off)
Enable (@var{on}) or disable (@var{off}) protection of flash sectors
-...@var{first} to @var{last} of flash bank @var{num}.
+...@var{first} to @var{last} of flash bank @var{num}. Defining a @var{last}
sector of -1 is
+equivalent to defining (max_sectors-1), i.e. protecting the entire bank.
The @var{num} parameter is a value shown by @command{flash banks}.
@end deffn
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development