Cannot Flash over 4K with OpenOCD

I am having trouble writing to flash over 4K using OpenOCD (Eclipse and Insight) on LPC-H2148. I can write small demos to flash and step or hit break points in Eclipse, but have trouble with LPCUSB which is 7K in size.

Relevant forum topics:

viewtopic.php?t=6046

viewtopic.php?t=4838

I tried some commands at the insight console…

monitor flash probe 0
monitor flash erase 0 0 1
monitor flash write 0 d:\whatever.bin 0x0

…which fills the first 4K with wholesome goodness, but 0x1000 - 0x1fff contains only 0xFFFF.

I tried splitting the .bin file into 4K chunks and explicitly writing across the 4K boundary…

split -b 4k -a 1 whatever.bin w

monitor flash probe 0
monitor flash write 0 d:\wa 0x1000

…but that resulted in the same flash write failed error.

I tried “unprotecting” memory with…

monitor flash protect 0 0 1 off
monitor flash write 0 d:\whatever.bin 0x0

…but that also ended in tears.

What would thwart flash writes? Is there an esoteric mww I am missing?

-Jason

More information…

Programming device - ARM-JTAG http://www.sparkfun.com/commerce/produc … cts_id=275

whatever.bin - 7325 bytes

wa - 4096 bytes (first split file)

wb - 3229 bytes (second split file)

monitor flash erase 0 0 1
monitor flash write 0 d:\wa 0x0000
monitor flash write 0 d:\wb 0x1000

OpenOCD log reports the following during the write to 0x1000…

Warning: lpc2000.c:606 lpc2000_write(): lpc2000 return 9

If ‘9’ is the ISP return code, then the LPC manual says this means SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION. I erased the sector before writing.

OpenOCD Version:

Info:    openocd.c:86 main(): Open On-Chip Debugger (2007-04-16 19:30 CEST)
Open On-Chip Debugger
(c) 2005 by Dominic Rath
(snapshot r141 from SVN tree + giveio, no official release, compiled my mifi)

:cry:

Hello Jason,

I suspect your .cfg file is at fault - check the “flash bank …” line from your config, and make sure you specify “lpc2000_v2” as the variant.

See http://openfacts.berlios.de/index-en.ph … figuration for a description of the config file format.

The “newer” LPC2k devices (starting with LPC213x and LPC214x) use a different sector layout. “flash info 0” shows you what the OpenOCD believes the sector layout looks like.

Regards,

Dominic

Thanks, Dominic.

lpc2000_v2 fixed the problem (I had lpc2000_v1). I swear I checked that line 8-10 times :oops:

I blame dySleXiA :roll:

Thanks again for the help.

-Jason