Unfortunately NXP uses a built-in programmer in the LPCXpresso board called LPCLink that is not supported by OpenOCD and there is not (AFAIK) an option to replace its firmware.
Then I decided to cut the board to separate the “LPCXpresso LPC1115 REV A” from the LPCLink programmer.
So I used a simple and low cost STLink-v2 programmer board that is supported by OpenOCD. In order to use OpenOCD to reprogram the LPC1115 board we need to connect four wires from STLink-v2 to LPC1115 board:
STLink-v2 | LPC1115 Board ------------------------------ GND GND 3V3 3V3 IO AD4 CLK P0.10
Also we need to instruct OpenOCD to use SWD protocol. You can do it creating the following config openocd.cfg file:
# LPC1115 LPCXpresso Target # Using stlink as SWD programmer source [find interface/stlink-v2.cfg] # SWD as transport transport select hla_swd # Use LPC1115 target set WORKAREASIZE 0x4000 source [find target/lpc11xx.cfg]
Now execute OpenOCD using the created config file:
$ sudo openocd -f openocd.cfg Open On-Chip Debugger 0.9.0-dev-00251-g1fa4c72 (2015-01-28-20:08) Licensed under GNU GPL v2 For bug reports, read http://openocd.sourceforge.net/doc/doxygen/bugs.html Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD adapter speed: 10 kHz adapter_nsrst_delay: 200 Info : Unable to match requested speed 10 kHz, using 5 kHz Info : Unable to match requested speed 10 kHz, using 5 kHz Info : clock speed 5 kHz Info : STLINK v2 JTAG v17 API v2 SWIM v4 VID 0x0483 PID 0x3748 Info : using stlink api v2 Info : Target voltage: 3.137636 Info : lpc11xx.cpu: hardware has 4 breakpoints, 2 watchpoints
Connect to OpenOCD server:
$ telnet 127.0.0.1 4444
Reset the CPU and flash the lpc1115_blink.bin file:
> reset halt target state: halted target halted due to debug-request, current mode: Thread xPSR: 0xc1000000 pc: 0x1fff0040 msp: 0x10000ffc > flash probe 0 flash 'lpc2000' found at 0x00000000 > flash write_image erase blink_lpc1115.bin 0x00000000 auto erase enabled target state: halted target halted due to breakpoint, current mode: Thread xPSR: 0x01000000 pc: 0x10000108 msp: 0x100001b8 Verification will fail since checksum in image (0x00000000) to be written to flash is different from calculated vector checksum (0xefffebe9). To remove this warning modify build tools on developer PC to inject correct LPC vector checksum. wrote 4096 bytes from file blink_lpc1115.bin in 0.592621s (6.750 KiB/s) > reset run
The checksum warning message could be removed if you add the checksum to binary, read this post: http://sigalrm.blogspot.com.br/2011/10/cortex-m3-exception-vector-checksum.html.
The blink LED sample I got from Frank Duignan’s page: http://eleceng.dit.ie/frank/arm/BareMetalLPC1114/index.html
Edit Makefile and configure LIBSPEC to point out to the right path:
To generate the final binary I used objcopy:
$ arm-none-eabi-objcopy -O binary main.elf blink_lpc1115.bin