SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By smead
#18499
Out of the blue I can no longer erase flash on an Oilmex lpc2103 board. It was working one moment and not the next.

> reset
> Target 0 halted
target halted in Thumb state due to debug request, current mode: Supervisor
cpsr: 0x400000d3 pc: 0x7fffe278
> flash erase 0 0 7
flash erase error
>

Here's what I get from the ocd daemon:
Error: arm7_9_common.c:1902 arm7_9_write_memory(): memory write caused data abort
Error: armv4_5.c:558 armv4_5_run_algorithm(): timeout waiting for algorithm to complete, trying to halt target
Warning: lpc2000.c:433 lpc2000_erase(): lpc2000 prepare sectors returned 1075161416
By smead
#18504
Don't ask me what happened or what fixed the problem. I regressed back through code that was working previously and nothing worked anymore. I ordered a couple replacement boards from Spark Fun but that didn't make it work either.

I unplugged everything for the umpteenth time, but this time I popped the cork from a bottle of red wine and after a couple of glasses came back for one more try. It all started to work again.

If that's what it takes I won't complain.
By albert_kurucz
#18833
My Olimex LPC2148 board is having similar issues:
Sometimes flash erase fails.
Sometimes flash write fails.

Also strange that flash protect_check / flash info always reports "protected" for every page, but flash erase (mostly) passes even though it shows protected.
By Dominic
#18834
The LPC doesn't really fit into OpenOCD's concept of "protect" sectors, as all sectors are protected by default, and you have to unlock them for every operation again. This is done implicitly in the code.

I've never seen a flash operation fail on an LPC2000 when the target was in a clean state (for example with run_and_halt after a 1 or 2 seconds in bootloader mode, or in a simple led-blinking program). You have to make sure that the frequency specified in the .cfg file matches the actual core frequency - if you specify the value of your crystal, make sure the PLL is turned off. You can achieve that by writing the LPC register from within OpenOCD.

Regards,

Dominic
By albert_kurucz
#18835
Thanks Dominic!

It was my fault

The clock on my LPC2148 is PLL-d up to 60MHz, but the config still shows the clock (12MHz):

flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 12000 calc_checksum

It is interesting, that the flash operations were still mostly working!
By albert_kurucz
#18837
smead:

> mdw 0xE01FC080 4
0xe01fc080: 00000003 00000023 00000723 00000055
> mww 0xE01FC080 0
> mdw 0xE01FC080 4
0xe01fc080: 00000000 00000023 00000723 00000055
> mww 0xE01FC08C 0xAA
> mww 0xE01FC08C 0x55
> mdw 0xE01FC080 4
0xe01fc080: 00000000 00000023 00000023 00000055