Hi,
I have had a hard time figuring out why programming an LPC1114 with an ST-Link V2 did not work using openocd 0.9. I used the following .cfg:
# NXP lpc1114fn23 Cortex-M0 32k flash, 4k ram
set CHIPNAME lpc1114
set CPUTAPID 0x0BB11477
set CPUROMSIZE 0x8000
set CPURAMSIZE 0x1000
adapter_khz 100
# Include the main configuration file.
source [find interface/stlink-v2.cfg]
source [find target/lpc11xx.cfg];
However, the stlink configuration file resets the adapter speed to a default of 10khz, which gets mapped to 5khz in stlink_usb.c. Output of openocd:
/usr/local/bin/openocd -f lpc1114.cfg
Open On-Chip Debugger 0.9.0 (2015-09-03-18:58)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 100 kHz
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
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 v24 API v2 SWIM v4 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.152262
While any commands without bulk data transfers will work, programming even small programs fails, because the bulk transfer size is set to 512 bytes for the adapter, which cannot be transferred at 5khz within the STLINK_WRITE_TIMEOUT of 100ms defined in stlink_usb.c. The error message then merely states that the programming failed.
My suggestion: Increase timeout to 2000ms, add more error logging in libusb1_common.c. e.g.:
int jtag_libusb_bulk_write(jtag_libusb_device_handle *dev, int ep, char *bytes,
int size, int timeout)
{
int transferred = 0;
int err = libusb_bulk_transfer(dev, ep, (unsigned char *)bytes, size,
&transferred, timeout);
if (err) {
LOG_ERROR("jtag_libusb_bulk_write error: %d, transferred: %d", err, transferred);
}
return transferred;
}
Birger