LPC2378 doesnt boot my binary / gets stuck in boot code

Hi,

i’m debugging an LPC2378 using OpenOCD, connected by an Amontec JTAGkey-tiny.

Running own binaries works fine as long as I dont hard-reset the board:

  flash erase 0 0 26
  flash write 0 myprog.bin 0
  soft_reset_halt
  resume

When i enter ‘reset’ or power off/on the board, it dosn’t start my binary any more. It gets stuck in the boot code. It is even impossible to get the JTAG connection any more; commands like ‘halt’ or ‘soft_reset_halt’ have no effect, they result in a timeout. The only way (afaik) to recover the board from this state is:

  0. plug out everything
  1. plug in the JTAGkey
  2. power on the board
  3. plug in the USB cable to the JTAGkey
  4. start openocd
  5. now it gets connected and i can do
     telnet> halt
     telnet> flash erase 0 0 26
     telnet> flash write 0 firmware.bin 0
     telnet> reset

Any ideas why the LPC refuses to boot my binary? Is it possible to debug the LPC’s boot-up code which cannot be overwritten?

Regarding the checksum at address 0x14: it seems to be right at least for the firmware. When I write the firmware back to the flash with ‘calc_checksum’ enabled, it works fine after an reset.

When i disable ‘calc_checksum’ in openocd.cfg, edit the firmware binary to contain a wrong checksum and write it to the flash, it fails to boot, just like my own binary fails. So the checksum might be a reason; but at least for the firmware, openocd calculates it correctly.

Are any other reasons known why the LPC might refuse to boot a binary?

cheers,

  • dc

my openocd.cfg:

#daemon configuration
telnet_port 4444
gdb_port 3333

#interface
interface ft2232
ft2232_device_desc "Amontec JTAGkey A"
ft2232_layout jtagkey
ft2232_vid_pid 0x0403 0xcff8
jtag_speed 2
#use combined on interfaces or targets that can't set TRST/SRST separately
reset_config trst_and_srst srst_pulls_trst

#jtag scan chain
#format L IRC IRCM IDCODE (Length, IR Capture, IR Capture Mask, IDCODE)
jtag_device 4 0x1 0xf 0xe

#target configuration
#daemon_startup reset
daemon_startup attach

#target <type> <startup mode>
#target arm7tdmi <reset mode> <chainpos> <endianness> <variant>
target arm7tdmi little reset_run 0 arm7tdmi-s_r4
working_area 0 0x40000000 0x40000 nobackup

#flash configuration
flash bank lpc2000 0x0 0x7d000 0 0 lpc2000_v2 0 12000 calc_checksum

Hey,

I haven’t tested the OpenOCD with LPC23xx (or LPC24xx) yet, but I guess there are some differences, both in reset/boot handling and in flash writing. I’ll go through the datasheets later today to see what changes might be necessary.

The LPC21xx and LPC22xx made debugging out of reset impossible for security reasons - I’m not sure if this is the case for the newer LPCs.

Regards,

Dominic

Now it works. There were 2 problems:

  1. the GPIO pins which drive the LEDs on the devel board (a Keil mcb2300) are used for the ETM module too. To see something on the LEDs, i had to disable the ETM by setting the PINSEL10 register to zero, or remove the ETM jumper. As the LEDs were the only output i used, sometimes the binary did actually run but one couldn’t see.

  2. Flash writing doesnt work correctly. After erasing and writing, there are only some bits set to zero. A workaround is writing the same binary twice; this seems to work reliably. This is also the case for the lpc2103 on the Keil mcb2100 board.

By misconfiguring the PLL it is very easy to bring the lpc2378 in a state where it is impossible to connect to the jtag any more. For that case i still didnt find another workaround than re-powering the device as mentioned above.

cheers,

  • dc

Thanks for creating and maintaining OpenOCD!