# Eclipse + OpenOCD 0.1.0 + STM32F103 Debuggng Setup

**URL:** <https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634>\
**Category:** MicroMod\
**Tags:** arm-lpc\
**Created:** [March 30, 2009, 9:09pm UTC](https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634 "2009-03-30T21:09:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![osborn](https://avatars.discourse-cdn.com/v4/letter/o/ee7513/32.png) [@osborn](https://community.sparkfun.com/u/osborn)\
**Post date:** [March 30, 2009, 9:09pm UTC](https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634/1 "2009-03-30T21:09:43Z")

</div>

Would someone be kind and provide their OpenOCD 0.1.0 configuration and GDB Initialization commands for Eclipse to allow debugging in the Eclipse environment.

The board I am using is the Olimex STM32-P103.

I can program the flash and make the LED blink, so I have OpenOCD configured to program the flash.

I created a debug configuration file and I can access OpenOCD via the telnet interface. I can even use GDB in text mode, however I cannot get Eclipse to work right. When I enter Eclipse Debugging mode the console window spits out:

> source .gdbinit
> 
> target remote :3333
> 
> 0x00000000 in ?? ()
> 
> monitor reset
> 
> JTAG tap: stm32.cpu tap/device found: 0x3ba00477 (Manufacturer: 0x23b, Part: 0xba00, Version: 0x3)
> 
> JTAG Tap/device matched
> 
> JTAG tap: stm32.bs tap/device found: 0x16410041 (Manufacturer: 0x020, Part: 0x6410, Version: 0x1)
> 
> JTAG Tap/device matched
> 
> target state: halted
> 
> target halted due to undefined, current mode: Thread
> 
> xPSR: 0x81000000 pc: 0x08000158
> 
> monitor sleep 500
> 
> monitor poll
> 
> target state: halted
> 
> target halted due to undefined, current mode: Thread
> 
> xPSR: 0x81000000 pc: 0x08000158
> 
> set mem inaccessible-by-default off
> 
> load
> 
> Loading section .text, size 0x2e98 lma 0x8000000
> 
> Loading section .data, size 0x534 lma 0x8002e98
> 
> Start address 0x8000000, load size 13260
> 
> Transfer rate: 6 KB/sec, 6630 bytes/write.
> 
> break main
> 
> Breakpoint 1 at 0x80001be: file p103.c, line 83.
> 
> continue
> 
> Note: automatically using hardware breakpoints for read-only addresses.

After this I cannot step, set breakpoints, view source, NOTHING.

Thanks.

---

<div class="post-metadata">

**Author:** ![omnix](https://avatars.discourse-cdn.com/v4/letter/o/ba8739/32.png) [@omnix](https://community.sparkfun.com/u/omnix)\
**Post date:** [April 1, 2009, 10:42am UTC](https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634/2 "2009-04-01T10:42:39Z")

</div>

I’m trying to flash STM32H103 on Olimex STM32-H103 board and I’m not able to do it.

In case that you are using Olimex USB JTAG Tiny, could you please post you cofiguration file here? I would be happy if I could just make the damn thing to flash the led.

---

<div class="post-metadata">

**Author:** ![osborn](https://avatars.discourse-cdn.com/v4/letter/o/ee7513/32.png) [@osborn](https://community.sparkfun.com/u/osborn)\
**Post date:** [April 1, 2009, 12:06pm UTC](https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634/3 "2009-04-01T12:06:16Z")

</div>

I got the LED Flashing thing going. I can program the Flash just fine. I am still having problems with Eclipse Debugging though.

I am using OpenOCD 0.1.0 with Olimex USB JTAG Tiny, so here is my flash programming configuration. I patched it together from various examples.

```auto
# Olimex STM32 P103 with STM32F103RBT.

# Source the default Olimex USB Tiny programmer
source [find interface/olimex-jtag-tiny-a.cfg]

# Use default telnet port
telnet_port 4444

# Use default GDB connection
gdb_port 3333

# Use default TCL port
tcl_port 6666

# Device has "Rev1" tap id.
set BSTAPID 0x16410041

# Source the default STM32.cfg file
source [find target/stm32.cfg]

init

reset halt

flash write_image erase p103.elf

verify_image p103.elf

resume

shutdown

```

---

<div class="post-metadata">

**Author:** ![omnix](https://avatars.discourse-cdn.com/v4/letter/o/ba8739/32.png) [@omnix](https://community.sparkfun.com/u/omnix)\
**Post date:** [April 2, 2009, 6:47pm UTC](https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634/4 "2009-04-02T18:47:03Z")

</div>

Thanks for the answer.

But I have a few more questions regarding this .cfg file:

- what is “source [find interface/olimex-jtag-tiny-a.cfg]” ?

- what is “source [find target/stm32.cfg]” ?

- whate is “p103.elf” ?

How did you name this .cfg? Is it eny of this .cfg in above questions?

---

<div class="post-metadata">

**Author:** ![osborn](https://avatars.discourse-cdn.com/v4/letter/o/ee7513/32.png) [@osborn](https://community.sparkfun.com/u/osborn)\
**Post date:** [April 7, 2009, 4:02pm UTC](https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634/5 "2009-04-07T16:02:00Z")

</div>

omnix,

The “source” command is a new feature of OpenOCD 0.1.0.

“p103.elf” is the name of the elf file to be programmed into flash.

The name of the .cfg file is your choice.

* * *

My question to everyone,

Is anybody successfully doing GDB debugging with Eclipse, OpenOCD 0.1.0, and STM32? If so, please post your OpenOCD config file and Eclipse command list to make this work. I still cannot get it to work properly.

---

<div class="post-metadata">

**Author:** ![mcr42](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@mcr42](https://community.sparkfun.com/u/mcr42)\
**Post date:** [April 16, 2009, 11:11am UTC](https://community.sparkfun.com/t/eclipse-openocd-0-1-0-stm32f103-debuggng-setup/10634/6 "2009-04-16T11:11:09Z")

</div>

I also had the problem with the debug not working, when I was trying to get the LED-blink demo to work.

My code was running when flashed into the device, but debugging was not possible. My problem was the hardware somehow got stuck in the BusFault or HardFault event handler. In the STlib, these are empty loops:

```auto
while (1) 
{
}

```

So when I issued resume, there was no breakpoint to stop it.

Try replacing the “resume” with “stepi”, and do a poll afterwards.

This should give you a hint where your program counter is at, and wether you are stuck with a Fault.
