SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By birger

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:
Code: Select all
# 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:
Code: Select all
 /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
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.:
Code: Select all
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;
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]