Olimex LPC-P2138 and Olimex ARM-USB-OCD under Linux

Hello!

I have bought LPC-P2138 and ARM-USB-OCD and have tried to get it to work under Linux using Insight during a long time. Reading this newsgroup and other newsgroups has helped me slightly, but the last obstacle is still there.

My arm-elf chain is basically compiled after www.openhardware.net. OpenOCD is subversion version 225, ie fairly late.

My test program is small flash based program. I hope and assume that it should be possible to debug applications in flash on the LPC2138.I have managed to download this small program (does not set up stack et al, but lights one of the LEDs) using serial port and the telnet interface to OpenOCD. The telnet commands are:

halt

flash write_image <filename.elf> 0 elf

resume 0

When I try to download the same application using Insight it fails with the error :

Warning: arm7_9_common.c:2074 arm7_9_write_memory(): memory write caused data abort (address: 0x00000000, size: 0x4, count: 0x1b)

The config is as follows:

#daemon configuration

telnet_port 4444

gdb_port 3333

#interface

interface ft2232

ft2232_device_desc “Olimex OpenOCD JTAG”

ft2232_layout “olimex-jtag”

ft2232_vid_pid 0x15ba 0x0003

jtag_speed 3

#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

#target

#target arm7tdmi

target arm7tdmi little run_and_init 0 arm7tdmi-s_r4

flash-options LPC2138

target_script 0 reset openocd_lpc2138_flash.script

run_and_halt_time 0 30

working_area 0 0x40000000 0x40000 nobackup

LPC2138 @ 12MHz / 0x7D000 from 500*1024 (not 512!)

up to version SVN188:

#flash bank lpc2000 0x0 0x7D000 0 0 lpc2000_v2 0 12000 calc_checksum

from Version SVN189:

#flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 12000 calc_checksum

flash bank lpc2000 0x0 0x7D000 0 0 0 lpc2000_v2 14745 calc_checksum

For more information about the configuration files, take a look at:

http://openfacts.berlios.de/index-en.ph … p+Debugger

The script is as follows:

#Based on information from

http://www.openhardware.net/Embedded_ARM/OpenOCD_JTAG/

halt

sleep 10

arm7_9 dcc_downloads enable

arm7_9 write_xpsr 0x000000d3 0 * Enable IRQ, FIQ and Supervisor mode

mww 0xE01FC040 0x00000001 #MEMMAP: User flash mode

sleep 10

arm7_9 force_hw_bkpts enable # program resides in Flash

#arm7_9 force_hw_bkpts disable # program resides in RAM

flash auto_erase on

Best regards,

/Stefan

Your config appears OK, and it must be if you can program the FLASH using the same config for OpenOCD via Telnet.

Your post did not specifically say, but I assume that you are having difficulty concerning these lines in your post? :

"

When I try to download the same application using Insight it fails with the error :warning: arm7_9_common.c:2074 arm7_9_write_memory(): memory write caused data abort (address: 0x00000000, size: 0x4, count: 0x1b)

"

I do not use Insight, but it appears that Insight tried to write to address 0x0, which is in FLASH. If that is the case, it can not do that! FLASH can only be programmed, but not written to by normal memory write methods. If a memory write to FLASH is attempted a data abort will result. You can certainly debug applications in FLASH memory using ARM’s hardware breakpoints, but you will have to program the FLASH first, not just write to it with the debugger.

Please excuse me if I wrongly jumped on the easy answer, but it was the only thing that looked like a question in your post.

–Dave

Hi Dave!

Thanks for the answer. You are correct, the error I got is my problem.

I realize what the error is now when you pointed it out. I hadn’t realized that Insight/GDB tried to write to the flash despite “declared” as flash.

Next question; I should thus get my script part of the OpenOCD to program the flash with the program to debug and then be able to run it, set breakpoints etc from Insight/GDB?

Best regards,

/Stefan

spe:
Hi Dave!

Thanks for the answer. You are correct, the error I got is my problem.

I realize what the error is now when you pointed it out. I hadn’t realized that Insight/GDB tried to write to the flash despite “declared” as flash.

Next question; I should thus get my script part of the OpenOCD to program the flash with the program to debug and then be able to run it, set breakpoints etc from Insight/GDB?

Best regards,

/Stefan

As I said earlier, I do not use Insight so I do not know the steps you need to follow, but I think that you are on the right path by enhancing your script to do the FLASH programming. I use the NoICE debugger, and I usually just program the FLASH outside the debugger before starting debugging even though NoICE can be used to program FLASH. The ELF file contains all the debug information necessary for source level debugging, but you do need to enable hardware breakpoints in the OpenOCD startup config file. The only drawback to hardware breakpoints is that ARM has only 2 hardware breakpoint registers, so you need to be careful with how you use breakpoints.

–Dave

I will try out the NoICE as far I can without paying to see if I at least get smarter. If I like it (or works :slight_smile: )I’ll buy it. Thanks for the tips.

Regards,

/Stefan