I’m trying to create a configuration file for flashing an LPC1769 using the Olimex USB tiny-h adaptor, but so far I’m only able to make it work some of the time and absolutely only the first time after plugging the adaptor into USB, the second time I try to flash without re-plugging it will fail.
My configuration looks like this:
jtag_khz 1
# This is the JTAG connector I use
source [find interface/olimex-arm-usb-tiny-h.cfg]
# This is close enough to the board I use
source [find target/lpc1768.cfg]
adapter_khz 500
init
sleep 200
soft_reset_halt
wait_halt
mww 0x400FC040 0x01
sleep 200
flash write_image erase main.bin
verify_image main.bin
reset run
When it works it looks liket this:
> openocd -f openocd-flash.cfg
Open On-Chip Debugger 0.5.0 (2011-08-26-10:36)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
1 kHz
Info : only one transport option; autoselect 'jtag'
adapter_nsrst_delay: 200
jtag_ntrst_delay: 200
10 kHz
500 kHz
Info : max TCK change to: 30000 kHz
Info : clock speed 500 kHz
Info : JTAG tap: lpc1768.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : lpc1768.cpu: hardware has 6 breakpoints, 4 watchpoints
requesting target halt and executing a soft reset
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x01000000 pc: 0x1fff0080 msp: 0x10001ffc
auto erase enabled
wrote 98304 bytes from file main.bin in 10.767429s (8.916 KiB/s)
verified 69748 bytes in 0.559875s (121.658 KiB/s)
Info : JTAG tap: lpc1768.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Warn : Only resetting the Cortex-M3 core, use a reset-init event handler to reset any peripherals
When it fails it looks like this:
openocd -f openocd-flash.cfg
Open On-Chip Debugger 0.5.0 (2011-08-26-10:36)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.berlios.de/doc/doxygen/bugs.html
1 kHz
Info : only one transport option; autoselect 'jtag'
adapter_nsrst_delay: 200
jtag_ntrst_delay: 200
10 kHz
500 kHz
Info : max TCK change to: 30000 kHz
Info : clock speed 500 kHz
Info : JTAG tap: lpc1768.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : lpc1768.cpu: hardware has 6 breakpoints, 4 watchpoints
requesting target halt and executing a soft reset
target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x01000000 pc: 0x000005f8 msp: 0x10008000
auto erase enabled
wrote 98304 bytes from file main.bin in 10.403347s (9.228 KiB/s)
Error: checksum mismatch - attempting binary compare
diff 0 address 0x00000000. Was 0xff instead of 0x00
diff 1 address 0x00000001. Was 0xff instead of 0x80
diff 2 address 0x00000002. Was 0xff instead of 0x00
diff 3 address 0x00000003. Was 0xff instead of 0x10
diff 4 address 0x00000004. Was 0xff instead of 0xf9
diff 5 address 0x00000005. Was 0xff instead of 0x05
diff 6 address 0x00000006. Was 0xff instead of 0x00
diff 7 address 0x00000007. Was 0xff instead of 0x00
diff 8 address 0x00000008. Was 0xff instead of 0x01
diff 9 address 0x00000009. Was 0xff instead of 0x06
diff 10 address 0x0000000a. Was 0xff instead of 0x00
diff 11 address 0x0000000b. Was 0xff instead of 0x00
diff 12 address 0x0000000c. Was 0xff instead of 0x03
diff 13 address 0x0000000d. Was 0xff instead of 0x06
diff 14 address 0x0000000e. Was 0xff instead of 0x00
diff 15 address 0x0000000f. Was 0xff instead of 0x00
diff 16 address 0x00000010. Was 0xff instead of 0x05
diff 17 address 0x00000011. Was 0xff instead of 0x06
diff 18 address 0x00000012. Was 0xff instead of 0x00
diff 19 address 0x00000013. Was 0xff instead of 0x00
diff 20 address 0x00000014. Was 0xff instead of 0x07
diff 21 address 0x00000015. Was 0xff instead of 0x06
diff 22 address 0x00000016. Was 0xff instead of 0x00
diff 23 address 0x00000017. Was 0xff instead of 0x00
diff 24 address 0x00000018. Was 0xff instead of 0x09
diff 25 address 0x00000019. Was 0xff instead of 0x06
diff 26 address 0x0000001a. Was 0xff instead of 0x00
...
As you can see nothing was programmed in the second round, but the flash was erased ok.
The clock and jtag connections to the controller is set up exactly like the LPCxpresso LPC1769 board (32768 kHz RTC xtal and 12 MHz main xtal) and I’m able to reproduce the problem with that board as well, so I’m pretty sure there is some problem with either my openocd configuration or my adaptor.
I’m using OpenOCD 0.5.0 from the Ubuntu repo.
Another strange datapoint: When I press my reset button on my own target board it only comes up correctly about one time out of ten and the same is true when doing a “reset run” via jtag.
The full schematic of my project is online here, the only strange thing I can think of is that I’ve left ~TRST unconnected:
https://github.com/openspaceaarhus/Phot … f?raw=true
If anyone has OpenOCD working with LPC17xx and/or olimex-arm-usb-tiny-h, then please post your configurations here.
Any ideas as to what is going on with the strange reset problem?