number of sector to erase and write_image erase

Hi,

I’m using openocd without problem with various LPC2xxx.

I’m trying to erase the whole internal flash of a lpc2212 (128kb)

I have defined my flash bank as following:

flash bank lpc2000 0x0 0x20000 0 0 0 lpc2000_v1 12000 calc_checksum

If I do ```
flash info 0

I see that the flash is divided into 16 blocks (0-15)

I'm trying to erase the whole flahs, so I do:

flash erase_sector 0 0 15


And I get the following error: 

failed erasing sectors 0 to 15 (-901)


If I do 

flash erase_sector 0 0 14


Is this the normal behaviour?

I'm trying to auto erase the flash during the flash of an image:

flash write_image erase main.elf 0x0 elf


and similary I get the error: 

failed erasing sectors 0 to 15 (-901)

Ok, it’s normal since the last block of flash (8kb) isn’t usable as it contains the boot loader code. I didn’t noticed it and my linker script were wrong (128kb of flash instead of 120kb)

To OpenOCD : maybe it would be a good idea to treat the last block differently and don’t intend to write it with the auto erase feature?