GDB not loading w/STM32F107, OpenOCD, Olimex ARM-USB-OCD

Perhaps someone can help me get this working…

I bought an Olimex ARM-USB-OCD for use with various ARM Cortex-M3 and -M0 processors.

I downloaded and compiled the OpenOCD from the svn repository.

It reports:

Open On-Chip Debugger 0.5.0-dev-00053-g5e78ddc (2010-03-04-18:05)

I have an STM3210C-EVAL/A board as well. I am able to load its flash using the JTAG, and telnet commands.

However, when I use GDB, the ‘load’ command doesn’t work. If I load the flash using the telnet method, I can debug via gdb just fine. I just can’t load the program. I have tried several kinds of reset commands, and also doing a mass erase of the flash bank before loading. Nothing seemed to help.

Here’s my openocd.cfg file:

interface ft2232
ft2232_device_desc "Olimex OpenOCD JTAG"
ft2232_layout olimex-jtag
ft2232_vid_pid 0x15ba 0x0003

# This is an STM32 eval board with a single STM32F103ZET6 chip on it.

# script for stm32

if { [info exists CHIPNAME] } {
   set  _CHIPNAME $CHIPNAME
} else {
   set  _CHIPNAME stm32
}

if { [info exists ENDIAN] } {
   set  _ENDIAN $ENDIAN
} else {
   set  _ENDIAN little
}

# Work-area is a space in RAM used for flash programming
# By default use 16kB
if { [info exists WORKAREASIZE] } {
   set  _WORKAREASIZE $WORKAREASIZE
} else {
   set  _WORKAREASIZE 0x10000
}

reset_config trst_and_srst

# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
jtag_khz 1000

jtag_nsrst_delay 100
jtag_ntrst_delay 100

#jtag scan chain
if { [info exists CPUTAPID ] } {
   set _CPUTAPID $CPUTAPID
} else {
  # See STM Document RM0008
  # Section 26.6.3
   set _CPUTAPID 0x3ba00477
}
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID

if { [info exists BSTAPID ] } {
   # FIXME this never gets used to override defaults...
   set _BSTAPID $BSTAPID
} else {
  # See STM Document RM0008
  # Section 29.6.2
  # Low density devices, Rev A
  set _BSTAPID1 0x06412041
  # Medium density devices, Rev A
  set _BSTAPID2 0x06410041
  # Medium density devices, Rev B and Rev Z
  set _BSTAPID3 0x16410041
  # High density devices, Rev A
  set _BSTAPID4 0x06414041
  # Connectivity line devices, Rev A and Rev Z
  set _BSTAPID5 0x06418041
}
jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID1 \
	-expected-id $_BSTAPID2 -expected-id $_BSTAPID3 \
	-expected-id $_BSTAPID4 -expected-id $_BSTAPID5

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME

$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0

set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME stm32x 0x8000000 0x40000 0 0 $_TARGETNAME

# reset halt

source [find chip/st/stm32/stm32.tcl]

And here’s my GDB startup script:

# Connect to the OpenOCD gdb server
target remote localhost:3333

# Reset the chip to get to a known state.
monitor reset halt

monitor stm32x mass_erase 0

monitor reset halt

load

break main
continue

When I run gdb, I see in its output:

Reading symbols from /home/ned/src/QPlwip/QP/examples/arm-cortex/qk/gnu/dpp-qk-stm3210c-eval/dbg/dpp-qk.elf...done.
warning: Can not parse XML memory map; XML support was disabled at compile time
0x00000000 in ?? ()
JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x3)
JTAG tap: stm32.bs tap/device found: 0x06418041 (mfg: 0x020, part: 0x6418, ver: 0x0)
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Loading section .isr_vector, size 0x154 lma 0x8000000
/home/ned/src/QPlwip/QP/examples/arm-cortex/qk/gnu/dpp-qk-stm3210c-eval/openocd.gdb:9: Error in sourced command file:
Load failed

And in the OpenOCD debug log (the full log is attached) I see:

Debug: 391 54975 cortex_m3.c:442 cortex_m3_debug_entry(): entered debug state in core mode: Thread at PC 0xfffffffe, target->state: halted
Debug: 392 54975 target.c:1007 target_call_event_callbacks(): target event 2 (gdb-halt)
Debug: 393 54975 target.c:1007 target_call_event_callbacks(): target event 3 (halted)
User : 394 54975 target.c:1273 target_arch_state(): target state: halted
User : 395 54975 armv7m.c:480 armv7m_arch_state(): target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Debug: 396 54975 target.c:1007 target_call_event_callbacks(): target event 8 (gdb-end)
Debug: 397 54975 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_stm32.cpu curstate
Debug: 398 54975 command.c:133 script_debug(): command - ocd_stm32.cpu ocd_stm32.cpu curstate
Debug: 399 54975 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_stm32.cpu invoke-event reset-end
Debug: 400 54975 command.c:133 script_debug(): command - ocd_stm32.cpu ocd_stm32.cpu invoke-event reset-end
Debug: 401 54979 gdb_server.c:2145 gdb_input_inner(): received packet: 'X8000000,0:<binary-data>'
Debug: 402 54979 gdb_server.c:2145 gdb_input_inner(): received packet: 'X8000000,154:<binary-data>'
Debug: 403 54979 gdb_server.c:1388 gdb_write_memory_binary_packet(): addr: 0x08000000, len: 0x00000154
Debug: 404 54979 target.c:1290 target_write_buffer(): writing buffer of 340 byte at 0x08000000
Debug: 405 54988 arm_adi_v5.c:291 jtagdp_transaction_endcheck(): jtag-dp: CTRL/STAT error, 0xf0000021
Error: 406 54988 arm_adi_v5.c:317 jtagdp_transaction_endcheck(): JTAG-DP STICKY ERROR
Debug: 407 54991 arm_adi_v5.c:329 jtagdp_transaction_endcheck(): jtag-dp: CTRL/STAT 0xf0000001
Error: 408 54993 arm_adi_v5.c:344 jtagdp_transaction_endcheck(): MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8000004
Debug: 409 55004 arm_adi_v5.c:291 jtagdp_transaction_endcheck(): jtag-dp: CTRL/STAT error, 0xf0000021
Error: 410 55004 arm_adi_v5.c:317 jtagdp_transaction_endcheck(): JTAG-DP STICKY ERROR
Debug: 411 55007 arm_adi_v5.c:329 jtagdp_transaction_endcheck(): jtag-dp: CTRL/STAT 0xf0000001
Error: 412 55009 arm_adi_v5.c:344 jtagdp_transaction_endcheck(): MEM_AP_CSW 0x23000052, MEM_AP_TAR 0x8000004
Warn : 413 55011 arm_adi_v5.c:602 mem_ap_write_buf_u32(): Block write error address 0x8000000, wcount 0x55
Error: 414 55011 gdb_server.c:1211 gdb_error(): unexpected error -107

The clue is in the following line:

Reading symbols from /home/ned/src/QPlwip/QP/examples/arm-cortex/qk/gnu/dpp-qk-stm3210c-eval/dbg/dpp-qk.elf…done.

warning: Can not parse XML memory map; XML support was disabled at compile time

xml support is required for the memory map that openocd send to gdb.

This map is then used by gdb to decide what is flash etc.

You will need to get a gdb that has xml support.

Cheers

Spen

Thanks!

Using the CodeSourcery G++ Lite worked fine.