Home > ARM, Компьютер, Контроллеры, Mac OS X, stm32 > arm-none-eabi-gdb – Segmentation fault: 11 – b 2

arm-none-eabi-gdb – Segmentation fault: 11 – b 2

UPD 14.10.13: This is a bug of GDB. It is already known and fixed.

Terry Guo: The gdb 7.4.1.20130913 in this release has some problem to decode DWARF debug information generated by -g3 option. For the time being, please recompile your project with -g or -g2 to work around this issue.

——-

I am trying to program stm32f303vct6 core on stm32f3discovery board via Eclipse+arm-none-eabi-gdb+openOCD. Source for this stm32 can be built with no errors. I use GNU Tools for ARM Embedded Processors. Also it can be uploaded to MCU. But there are some troubles with debugging: gdb can’t read symbols from the firmware. This means that there will be no breakpoints in code. It is awful.

No symbol file

No symbol file

We can specify file with symbols under Debug Configuration -> GDB Hardware Debugging -> Load Image and Symbols. Okay, let’s turn it on.

Load symbols!

Load symbols!

Now we have to start debugging process (do not forget to connect board and launch openOCD). Wow, error message!

Connection is shut down

Connection is shut down

And that’s all. No reason. Log in openOCD is pretty short too:

Info : accepting 'gdb' connection from 3333 Warn : acknowledgment received, but no packet pending Info : dropped 'gdb' connection

So we need to go deeper to do it manually. First of all you have to run arm-none-eabi-gdb in terminal. You will see (gdb). Connect gdb to openOCD:

target extended-remote localhost:3333

Halt device because it’s impossible to write to MCU when it is not stopped.

monitor reset halt

Load firmware

load /long/long/path/to/your/firmware.elf

And now breakpoints.

b 2

GDB will answer that no symbol table is loaded and we should use “file” command. Use it.

file /long/long/path/to/your/firmware.elf

GDB should print this: Reading symbols from /long/long/path/to/your/firmware.elf...done. Now, breakpoints!

b 2

Answer is swesome.

Segmentation fault: 11

Solution

It is simple. You have to call arm-none-eabi-gdb with your firmware file as a parameter.

arm-none-eabi-gdb /long/long/path/to/your/firmware.elf

GDB will read symbols from file immediately. Now connect GDB to openOCD, halt the core and flash firmware.

target extended-remote localhost:3333 target extended-remote localhost:3333 target reset halt load

Now we can access breakpoints. Proof:

Breakpoints

Breakpoints

Awesome! But how can we do the same thing but from Eclipse?

My solution is to build toolchain yourself: https://github.com/jsnyder/arm-eabi-toolchain

After successful build you have to open Debug Configuration -> GDB Hardware Debugging -> Our Configuration -> Debugger and change “GDB Command” to this new arm-none-eabi-gdb after that go to “Startup” and enable all options (Reset and Delay, Halt, Load Image, Load Symbols, Set Breakpoint and Resume).

Everything have to be OK.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: