LPC1788 J-Link Error: usb_bulk_write failed

openocd-0.7.0

GNU/Linux, 3 different versions, same error

opencod.cfg:

 telnet_port 4444
 gdb_port 3333
 source [find interface/jlink.cfg]
 source [find target/lpc1788.cfg]

After this command in gdb:

monitor flash write_image erase test.elf

I get:

Error: usb_bulk_read failed (requested=1594, result=0)
Error: jlink_tap_execute, wrong result -107 (expected 1594)
Error: usb_bulk_write failed (requested=3206, result=0)
Error: jlink_tap_execute, wrong result -107 (expected 1601)
Error: usb_bulk_write failed (requested=3206, result=0)
Error: jlink_tap_execute, wrong result -107 (expected 1601)

… and so on

The hardware is OK. This debugger works with STM32, and another debugger works with this MCU.

There are few similar question on the web, but without answers :frowning:

Almost solved by adding

adapter_khz 32

after

#delays on reset lines
adapter_nsrst_delay 200
jtag_ntrst_delay 200

and

adapter_khz 1000

after

$_TARGETNAME configure -event reset-init {
        # Do not remap 0x0000-0x0020 to anything but the flash (i.e. select
        # "User Flash Mode" where interrupt vectors are _not_ remapped,
        # and reside in flash instead).
        #
        # See Table 612. Memory Mapping Control register (MEMMAP - 0x400F C040) bit description
        # Bit Symbol Value Description Reset
        # value
        # 0 MAP Memory map control. 0
        # 0 Boot mode. A portion of the Boot ROM is mapped to address 0.
        # 1 User mode. The on-chip Flash memory is mapped to address 0.
        # 31:1 - Reserved. The value read from a reserved bit is not defined. NA
        #
        # http://ics.nxp.com/support/documents/microcontrollers/?scope=LPC1768&type=user

        mww 0x400FC040 0x01
}

in lpc17xx.cfg

Very slow, but works