Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-21 Thread David Brownell
On Monday 21 September 2009, Johnny Halfmoon wrote: > Okay. Like this then: Merged with some cleanups, including the one noted by Rolf. ___ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/o

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-21 Thread David Brownell
On Monday 21 September 2009, Johnny Halfmoon wrote: > > David Brownell wrote: > > On Sunday 20 September 2009, Johnny Halfmoon wrote: > >> + if ((retval = flash_check_sector_parameters(cmd_ctx, > >> first, last, p->num_sectors)) ! > > > > I had in mind more like > > > > uint32

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-21 Thread Rolf Meeser
Hi Johnny, it should be > +if ( first > last ) { not > +if ( first >= last ) { With first=last you can erase a single sector. Regards, Rolf --- Johnny Halfmoon schrieb am Mo, 21.9.2009: > Von: Johnny Halfmoon > Betreff: Re: [Openocd-development] [PATCH] Enhanc

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-21 Thread Johnny Halfmoon
David Brownell wrote: > On Sunday 20 September 2009, Johnny Halfmoon wrote: >> + if ((retval = flash_check_sector_parameters(cmd_ctx, first, >> last, p->num_sectors)) ! > > I had in mind more like > > uint32_t value; Okay. Like this then: = = = = = = = = = = = = doc/

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread David Brownell
On Sunday 20 September 2009, Johnny Halfmoon wrote: > +   if ((retval = flash_check_sector_parameters(cmd_ctx, first, > last, p->num_sectors)) ! I had in mind more like uint32_t value; retval = parse_u32(argv[X], &value); if (retval != ERROR_OK)

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread Johnny Halfmoon
Fair enough. Try this then (with some added parameter checking)... = = = doc/openocd.texi |6 -- src/flash/flash.c | 47 --- 2 files changed, 48 insertions(+), 5 deletions(-) Index: src/flash/flash.c ===

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread Audrius Urmanavičius
On Sun, Sep 20, 2009 at 10:23 PM, Michael Schwingen wrote: > David Brownell wrote: >> Good point; Øyvind's suggestion (keyword "last") seems >> to be the best overall solution then. >> > > That would be my favourite, unless it needs ridiculous amounts of code > to implement. Agree 100%. What abou

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread Michael Schwingen
David Brownell wrote: > Good point; Øyvind's suggestion (keyword "last") seems > to be the best overall solution then. > That would be my favourite, unless it needs ridiculous amounts of code to implement. cu Michael ___ Openocd-development mailing

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread Øyvind Harboe
Could you use a keyword like "last", rather than try to overload the meaning of integers? Using -1 is quicker, easier and more seductive -- Øyvind Harboe Embedded software and hardware consulting services http://www.zylin.com ___ Openocd-developme

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread Michael Schwingen
David Brownell wrote: >> >> +if (last < 0) >> +last = p->num_sectors - 1; >> + >> > > This relies on the lack of error checking for testing "first" > and "last" ... better to add error checking, and then use zero > as the magic number. > Hm - would'nt that

Re: [Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread David Brownell
On Sunday 20 September 2009, Johnny Halfmoon wrote: > 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

[Openocd-development] [PATCH] Enhancement: Allow -1 as last sector for protection and erase

2009-09-20 Thread Johnny Halfmoon
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 --- d