SparkFun Forums 

Where electronics enthusiasts find answers.

Open source ARM Debugger
By Peggle
#25633
I am having difficulty flashing a LPC-H2148 with the demo led app and I hope someone here will be able to see what I am doing wrong.
I am using a ARM-USB-OCD with eclipse. I suspect the board has had a previous bad flash but have no evidence of this.

I think the relevant errors are:
arm-elf-gbd.exe
failed writing file main.bin to flash bank 0 at offset 0x00000000
openocd-ftd2xx.exe
Error: arm7_9_common.c:561 arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 0

Below is the order that I have done things and the output, all in probably far too much detail:

Output from building in Eclipse:
make -k all
".assembling"
arm-elf-as -ahls -mapcs-32 -o crt.o crt.s > crt.lst
".compiling"
arm-elf-gcc -I./ -c -fno-common -O0 -g main.c
"..linking"
arm-elf-ld -v -Map main.map -T2138_demo.cmd -o main.out crt.o main.o
GNU ld version 2.16.1
"...copying"
arm-elf-objcopy -O binary main.out main.bin
arm-elf-objdump -x --syms main.out > main.dmp
"...building hex"
arm-elf-objcopy -O ihex main.out main.hex

Connect ARM-USB-OCD to usb cable
Connect LPC-H2148 to usb cable (DBG_E and L_E jumbers are on)
Connect the JTAG cable
Run OpenOCD from Eclipse
Info: openocd.c:82 main(): Open On-Chip Debugger (2006-10-12 18:00 CEST)
Debug LPC2148_flash from Eclipse

Output from arm-elf-gbd.exe:
(gdb) target state: halted
target halted in Thumb state due to debug request, current mode: Undefined
cpsr: 0x600000fb pc: 0xfffffff0
flash 'lpc2000' found at 0x00000000
failed writing file main.bin to flash bank 0 at offset 0x00000000
flash program error
failed writing file main.bin to flash bank 0 at offset 0x00000000
flash program error
requesting target halt and executing a soft reset

Output from openocd-ftd2xx.exe:
Info: openocd.c:82 main(): Open On-Chip Debugger (2006-10-12 18:00 CEST)
Warning: arm7_9_common.c:842 arm7_9_halt(): target was already halted
Info: server.c:67 add_connection(): accepted 'gdb' connection from 0
Error: arm7_9_common.c:561 arm7_9_execute_sys_speed(): timeout waiting for SYSCOMP & DBGACK, last DBG_STATUS: 0
Warning: arm7_9_common.c:1963 arm7_9_write_memory(): memory write caused data abort (address: 0x40000020, size: 0x4, count: 0x3)
Error: armv4_5.c:186 armv4_5_mode_to_number(): invalid mode value encountered
Error: arm7_9_common.c:972 arm7_9_debug_entry(): cpsr contains invalid mode value - communication failure
Warning: arm7_9_common.c:623 arm7_9_poll(): DBGACK set while target was in unknown state. Reset or initialize target before resuming
By armdeveloper
#25641
It appears to me that you are trying to do things from within Eclipse.

Before you add that to the mix, I recommend getting things working from the command line.

So, for example, use $openocd -f flash.cfg You might add a -d<x> to the line to get more verbose output.

The other thing is to program your device with another tool, say an ISP application and then fire up telnet or gdb and see if you can run it from the command line.

Nevertheless, I recommend starting simple and getting things working from the command line first.
By Peggle
#25656
Thanks for you help, I have resolved the issue above, it was the jtag_speed lpc2xxx_armusbocd.cfg (in my case it needed to be changed from 2 to 3). I take it that this needs to be adjusted to each pc hardware configuration.

In case someone else has this issue the process I used to debug this was to run openocd with:
openocd-ftd2xx.exe -f lpc2xxx_armusbocd.cfg

Then telnet into the openocd:
telnet localhost 4444

Once you are connected to the openocd via telnet the jatag can be controlled with the commands which can be found here:
http://openfacts.berlios.de/index-en.ph ... D_commands
By Dominic
#25657
The jtag_speed usually acts as a divisor, but it's actual meaning depends on the JTAG interface used. All FT2232 based devices (ARM-USB-OCD, JTAGkey, Signalyzer, OOCD-Link, homebrew devices) work at 6MHz / (1 + jtag_speed). The LPCs use the ARM7TDMI-S core, which requires the JTAG speed to be limited to 1/6th of the core frequency. LPC2148 targets usually have a 12MHz crystal, and 6MHz / (1 + 2) = 2MHz is too close to the 1/6th limit, causing communication to fail.

Regards,

Dominic
By armdeveloper
#25663
Wow, I didn't know that, Dominic. I'll change my speed numbers right now.
By Peggle
#25719
I suspect the most likely cause is a configuration issue however the hardware is new and I am not familiar with it so it may just be the order that I am doing things.

To my knowledge the LPC-h2148 does not have a serial port available.
There is only the jtag and usb (the usb does not show up as a device on the pc).

I have tried the following and the result is below.
Code: Select all
C:\GCCFD\openocd\bin\openocd-ftd2xx.exe -f C:\GCCFD\projects\lpc2148\lpc2xxx_armusbocd.cfg -d 3 -l C:\GCCFD\openocd\output.txt dump_binary C:\GCCFD\openocd\output.dmp
Debug: jtag.c:1210 jtag_init():
Debug: ft2232.c:991 ft2232_init(): 'ft2232' interface using FTD2XX with 'olimex-jtag' layout
Debug: ft2232.c:1077 ft2232_init(): current latency timer: 2
Debug: ft2232.c:1330 olimex_jtag_init(): 80 08 1b
Debug: ft2232.c:1373 olimex_jtag_init(): 82 09 0f
Debug: ft2232.c:242 ft2232_speed(): 86 02 00
Debug: jtag.c:247 jtag_call_event_callbacks(): jtag event: 1
Debug: jtag.c:1096 jtag_reset_callback():
Debug: jtag.c:247 jtag_call_event_callbacks(): jtag event: 1
Debug: jtag.c:1096 jtag_reset_callback():
Debug: openocd.c:100 main(): jtag init complete
Debug: arm7_9_common.c:656 arm7_9_assert_reset(): target->state: unknown
Debug: jtag.c:247 jtag_call_event_callbacks(): jtag event: 0
Debug: jtag.c:1096 jtag_reset_callback():
Debug: jtag.c:247 jtag_call_event_callbacks(): jtag event: 1
Debug: jtag.c:1096 jtag_reset_callback():
Debug: jtag.c:247 jtag_call_event_callbacks(): jtag event: 0
Debug: jtag.c:1096 jtag_reset_callback():
Debug: ft2232.c:738 olimex_jtag_reset(): trst: 1, srst: 1, high_output: 0x02, high_direction: 0x0f
Debug: ft2232.c:738 olimex_jtag_reset(): trst: 0, srst: 1, high_output: 0x03, high_direction: 0x0f
Debug: arm7_9_common.c:722 arm7_9_deassert_reset(): target->state: reset
Debug: jtag.c:247 jtag_call_event_callbacks(): jtag event: 2
Debug: jtag.c:1096 jtag_reset_callback():
Debug: ft2232.c:738 olimex_jtag_reset(): trst: 0, srst: 0, high_output: 0x09, high_direction: 0x0f
Debug: openocd.c:104 main(): target init complete
Debug: openocd.c:108 main(): flash init complete
Debug: gdb_server.c:1347 gdb_init(): gdb service for target arm7tdmi at port 3333
Debug: embeddedice.c:157 embeddedice_read_reg_w_check(): 1
Debug: jtag.c:247 jtag_call_event_callbacks(): jtag event: 3
Debug: jtag.c:1096 jtag_reset_callback():
Debug: arm7_9_common.c:838 arm7_9_halt(): target->state: running
Debug: embeddedice.c:253 embeddedice_write_reg(): 9: 0xffffffff
Debug: embeddedice.c:253 embeddedice_write_reg(): 11: 0xffffffff
Debug: embeddedice.c:253 embeddedice_write_reg(): 12: 0x00000100
Debug: embeddedice.c:253 embeddedice_write_reg(): 13: 0x000000f7
Debug: embeddedice.c:157 embeddedice_read_reg_w_check(): 1
Debug: arm7_9_common.c:620 arm7_9_poll(): DBGACK set, dbg_state->value: 0x9
Debug: embeddedice.c:253 embeddedice_write_reg(): 0: 0x00000005
Debug: embeddedice.c:253 embeddedice_write_reg(): 12: 0x00000000
Debug: arm7_9_common.c:944 arm7_9_debug_entry(): target entered debug from ARM state
Error: armv4_5.c:186 armv4_5_mode_to_number(): invalid mode value encountered
Error: arm7_9_common.c:972 arm7_9_debug_entry(): cpsr contains invalid mode value - communication failure
Error: target.c:1054 handle_target(): couldn't poll target, exiting