OpenOCD won't accept a gdb connection initiated from Eclipse

Good day,

I’m trying to debug an application that I wrote for the ST STM32F103ZET6 (Cortex-M3, 512k flash).

I’ve used OpenOCD/Eclipse/GCC successfully in the past to develop for the STR912 (ARM9).

I have the following setup:

OS: Linux (Ubuntu Karmic)

GCC: 4.2.1 arm-none-eabi (CodeSourcery 2009q3 : 6.8.50.20090630-cvs)

Eclipse: 20100218-1602

OpenOCD: 0.4 (

Dongle: Amontec USB-tiny

I have run into the following OpenOCD error when trying to open a debug session to my target board from within Eclipse:

“rejected ‘gdb’ connection, no more connections allowed”

I’ve tried to issue the gdb commands directly from within a command line gdb session, and OpenOCD accepts all the commands without a problem.

The gdbCommands file that I’ve specified in Eclipse contains the following commands:

target remote localhost:3333

monitor halt

monitor sleep 500

monitor gdb_breakpoint_override hard

monitor wait_halt

monitor sleep 500

symbol-file main.out

set $pc = 0x0

break main

continue

My OpenOCD config file contains the following lines:

source [find interface/jtagkey-tiny.cfg]

source [find target/stm32.cfg]

The output from OpenOCD (-d 3) when I try to open a debug session from withing Eclipse are listed below.

Info : 343 297284 server.c:81 add_connection(): accepting ‘gdb’ connection from 0

Debug: 344 297284 breakpoints.c:161 breakpoint_clear_target(): Delete all breakpoints for target: stm32.cpu

Debug: 345 297284 breakpoints.c:299 watchpoint_clear_target(): Delete all watchpoints for target: stm32.cpu

Debug: 346 297284 target.c:968 target_call_event_callbacks(): target event 25 (gdb-attach)

Debug: 347 297284 gdb_server.c:856 gdb_new_connection(): New GDB Connection: 1, Target stm32.cpu, state: halted

Debug: 348 297284 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qSupported’

Debug: 349 297285 gdb_server.c:2147 gdb_input_inner(): received packet: ‘QStartNoAckMode’

Warn : 350 297285 gdb_server.c:649 gdb_get_packet_inner(): acknowledgment received, but no packet pending

Debug: 351 297285 gdb_server.c:2147 gdb_input_inner(): received packet: ‘?’

Debug: 352 297285 gdb_server.c:2147 gdb_input_inner(): received packet: ‘Hc-1’

Debug: 353 297285 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qC’

Debug: 354 297285 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qOffsets’

Debug: 355 297285 gdb_server.c:2147 gdb_input_inner(): received packet: ‘Hg0’

Debug: 356 297285 gdb_server.c:2147 gdb_input_inner(): received packet: ‘g’

Debug: 357 297286 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qXfer:memory-map:read::0,fff’

Debug: 358 297287 gdb_server.c:2147 gdb_input_inner(): received packet: ‘m8001872,4’

Debug: 359 297287 gdb_server.c:1251 gdb_read_memory_packet(): addr: 0x08001872, len: 0x00000004

Debug: 360 297287 target.c:1333 target_read_buffer(): reading buffer of 4 byte at 0x08001872

Debug: 361 297362 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qSymbol::’

Debug: 362 297363 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qRcmd,68616c74’

Debug: 363 297382 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_halt

Debug: 364 297382 command.c:133 script_debug(): command - halt ocd_halt

Debug: 366 297402 target.c:2062 handle_halt_command(): -

Debug: 367 297402 cortex_m3.c:499 cortex_m3_halt(): target->state: halted

Debug: 368 297402 cortex_m3.c:503 cortex_m3_halt(): target was already halted

Debug: 369 297443 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qRcmd,736c65657020353030’

Debug: 370 297459 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_sleep 500

Debug: 371 297459 command.c:133 script_debug(): command - sleep ocd_sleep 500

Debug: 374 297992 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qRcmd,6764625f627265616b706f696e745f6f766572726964652068617264’

Debug: 375 298001 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_gdb_breakpoint_override hard

Debug: 376 298001 command.c:133 script_debug(): command - gdb_breakpoint_override ocd_gdb_breakpoint_override hard

User : 378 298004 gdb_server.c:2501 handle_gdb_breakpoint_override_command(): force hard breakpoints

Debug: 379 298007 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qRcmd,776169745f68616c74’

Debug: 380 298009 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_wait_halt

Debug: 381 298009 command.c:133 script_debug(): command - wait_halt ocd_wait_halt

Debug: 383 298015 gdb_server.c:2147 gdb_input_inner(): received packet: ‘qRcmd,736c65657020353030’

Debug: 384 298017 command.c:133 script_debug(): command - ocd_command ocd_command type ocd_sleep 500

Debug: 385 298017 command.c:133 script_debug(): command - sleep ocd_sleep 500

Debug: 388 298523 gdb_server.c:2147 gdb_input_inner(): received packet: ‘Pf=00000000’

Debug: 389 298523 gdb_server.c:1156 gdb_set_register_packet(): -

Debug: 390 298523 gdb_server.c:2147 gdb_input_inner(): received packet: ‘g’

Debug: 391 298523 gdb_server.c:2147 gdb_input_inner(): received packet: ‘m0,4’

Debug: 392 298523 gdb_server.c:1251 gdb_read_memory_packet(): addr: 0x00000000, len: 0x00000004

Debug: 393 298523 target.c:1333 target_read_buffer(): reading buffer of 4 byte at 0x00000000

Debug: 394 298526 gdb_server.c:2147 gdb_input_inner(): received packet: ‘m8000202,4’

Debug: 395 298526 gdb_server.c:1251 gdb_read_memory_packet(): addr: 0x08000202, len: 0x00000004

Debug: 396 298526 target.c:1333 target_read_buffer(): reading buffer of 4 byte at 0x08000202

Debug: 397 298533 gdb_server.c:2147 gdb_input_inner(): received packet: ‘Z1,8001872,2’

Debug: 398 298533 gdb_server.c:1451 gdb_breakpoint_watchpoint_packet(): -

Debug: 399 298533 target.c:1565 target_write_u32(): address: 0xe0002008, value: 0x88001871

Debug: 400 298535 cortex_m3.c:963 cortex_m3_set_breakpoint(): fpc_num 0 fpcr_value 0x88001871

Debug: 401 298535 cortex_m3.c:999 cortex_m3_set_breakpoint(): BPID: 1, Type: 0, Address: 0x08001872 Length: 2 (set=1)

Debug: 402 298535 breakpoints.c:102 breakpoint_add(): added hardware breakpoint at 0x08001872 of length 0x00000002, (BPID: 1)

Debug: 403 298535 gdb_server.c:2147 gdb_input_inner(): received packet: ‘vCont?’

Debug: 404 298535 gdb_server.c:2147 gdb_input_inner(): received packet: ‘Hc0’

Debug: 405 298535 gdb_server.c:2147 gdb_input_inner(): received packet: ‘c’

Debug: 406 298535 target.c:968 target_call_event_callbacks(): target event 7 (gdb-start)

Debug: 407 298535 gdb_server.c:1413 gdb_step_continue_packet(): -

Debug: 408 298535 gdb_server.c:1427 gdb_step_continue_packet(): continue

Debug: 409 298537 target.c:1516 target_read_u16(): address: 0x00000000, value: 0x0400

Debug: 410 298537 armv7m.c:129 armv7m_restore_context():

Debug: 411 298541 cortex_m3.c:1424 cortex_m3_store_core_reg_u32(): write core reg 15 value 0x1

Debug: 412 298541 armv7m.c:242 armv7m_write_core_reg(): write core reg 15 value 0x1

Debug: 413 298543 target.c:968 target_call_event_callbacks(): target event 4 (resumed)

Debug: 414 298543 cortex_m3.c:697 cortex_m3_resume(): target resumed at 0x1

Debug: 415 298664 cortex_m3.c:336 cortex_m3_debug_entry():

Debug: 416 298672 cortex_m3.c:151 cortex_m3_clear_halt(): NVIC_DFSR 0x3

Debug: 417 298678 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 0 value 0x20010000

Debug: 418 298682 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 1 value 0x2000fff0

Debug: 419 298686 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 2 value 0x2000026c

Debug: 420 298690 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 3 value 0x2000026c

Debug: 421 298694 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 4 value 0x9d

Debug: 422 298698 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 5 value 0xea3fdbc0

Debug: 423 298702 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 6 value 0xe51fecaa

Debug: 424 298706 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 7 value 0x2000fff0

Debug: 425 298743 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 8 value 0xfbffff7f

Debug: 426 298768 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 9 value 0xffeffffd

Debug: 427 298816 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 10 value 0x374fba7e

Debug: 428 298864 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 11 value 0x95654a70

Debug: 429 298925 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 12 value 0xfbfff7ff

Debug: 430 298968 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 13 value 0x2000fff0

Debug: 431 299020 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 14 value 0x8000203

Debug: 432 299051 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 15 value 0x8001872

Debug: 433 299114 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 16 value 0x61000000

Debug: 434 299174 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 17 value 0x2000fff0

Debug: 435 299192 cortex_m3.c:1346 cortex_m3_load_core_reg_u32(): load from core reg 18 value 0x8b28355c

Debug: 436 299235 cortex_m3.c:1378 cortex_m3_load_core_reg_u32(): load from special reg 19 value 0x0

Debug: 437 299282 cortex_m3.c:1378 cortex_m3_load_core_reg_u32(): load from special reg 20 value 0x0

Debug: 438 299323 cortex_m3.c:1378 cortex_m3_load_core_reg_u32(): load from special reg 21 value 0x0

Debug: 439 299362 cortex_m3.c:1378 cortex_m3_load_core_reg_u32(): load from special reg 22 value 0x0

Debug: 440 299362 cortex_m3.c:396 cortex_m3_debug_entry(): entered debug state in core mode: Thread at PC 0x8001872, target->state: halted

Debug: 441 299362 target.c:968 target_call_event_callbacks(): target event 2 (gdb-halt)

Debug: 442 299362 target.c:968 target_call_event_callbacks(): target event 3 (halted)

Debug: 443 299362 target.c:968 target_call_event_callbacks(): target event 8 (gdb-end)

Debug: 444 299362 gdb_server.c:2147 gdb_input_inner(): received packet: ‘g’

Debug: 445 299373 gdb_server.c:2147 gdb_input_inner(): received packet: ‘z1,8001872,2’

Debug: 446 299373 gdb_server.c:1451 gdb_breakpoint_watchpoint_packet(): -

Debug: 447 299373 cortex_m3.c:1022 cortex_m3_unset_breakpoint(): BPID: 1, Type: 0, Address: 0x08001872 Length: 2 (set=1)

Debug: 448 299373 target.c:1565 target_write_u32(): address: 0xe0002008, value: 0x00000000

Debug: 449 299383 breakpoints.c:127 breakpoint_free(): free BPID: 1 → 0

Debug: 450 299383 gdb_server.c:2147 gdb_input_inner(): received packet: ‘m8001872,4’

Debug: 451 299383 gdb_server.c:1251 gdb_read_memory_packet(): addr: 0x08001872, len: 0x00000004

Debug: 452 299383 target.c:1333 target_read_buffer(): reading buffer of 4 byte at 0x08001872

Info : 453 299411 server.c:433 server_loop(): rejected ‘gdb’ connection, no more connections allowed

Debug: 454 299411 gdb_server.c:2147 gdb_input_inner(): received packet: ‘k’

Debug: 455 299411 gdb_server.c:875 gdb_connection_closed(): GDB Close, Target: stm32.cpu, state: halted, gdb_actual_connections=0

Debug: 456 299411 target.c:968 target_call_event_callbacks(): target event 8 (gdb-end)

Debug: 457 299411 target.c:968 target_call_event_callbacks(): target event 26 (gdb-detach)

Info : 458 299411 server.c:455 server_loop(): dropped ‘gdb’ connection - error -400

Update:

Using Insight debugger (http://sourceware.org/insight) instead of GNU GDB I have managed to establish a debug connection to my target board from withing Eclipe, using the same script files and configuration.