Problem compiling ChibiOS with -O0 (no opt)

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
gentijo
Posts: 11
Joined: Sat Jul 21, 2012 5:00 am

Problem compiling ChibiOS with -O0 (no opt)

Post by gentijo »

So I am able to build and debug using:
Eclipse Juno
Eclipse GNU ARM tools
Zylin CDT
Yagarto 4.7.1
st-link (texane)

but when I am generically debugging, I run into messages like variable optimized
out and the cursor jumps when unexpectedly because of code minimization options.

So I changed the make file to use -O0, -O1, or not specifying an optimization level at
all.

When I do this, the code throws an exception before it gets to main(). The debugger
suspends in ctr0 @ __late_init(void) but I am not sure how it gets there. in my .gdbinit
I am setting a break point on ResetHandler but it never gets there.

-John Gentilin
gentijo
Posts: 11
Joined: Sat Jul 21, 2012 5:00 am

Re: Problem compiling ChibiOS with -O0 (no opt)

Post by gentijo »

Forgot to mention this is on a STM32 F4 Discovery board, running the vanilla board demo code
Abhishek
Posts: 266
Joined: Wed May 23, 2012 3:15 pm

Re: Problem compiling ChibiOS with -O0 (no opt)

Post by Abhishek »

Hi John,

Looks like I've also faced such a problem while debugging with the F4 Discovery. But it occurs even with the default settings. The code goes into an exception just after reset. I didn't check the call trace that time, but can confirm it occurred before main method gets called.

I found out that in such cases, resetting the chip after where the code hangs can fix the issue. Once I pressed the reset button, I get the chip to a breakpoint at main. However I'm using Atollic's GDB server, so I'm not sure if it'll work. Would you mind trying?

Best Regards
Abhishek
gentijo
Posts: 11
Joined: Sat Jul 21, 2012 5:00 am

Re: Problem compiling ChibiOS with -O0 (no opt)

Post by gentijo »

Interestingly I would of sworn this problem was the same with the command line version of GBD but after
re-reading the texane page, I saw that I needed to specify the target with extended-remote and not just
remote. This gave me the kill and run commands, now the command line works just fine and it also works
in http://www.affinic.com/?page_id=109 Debugger GUI. Eclipse is still failing with -O0, but works with -O2.
For the Eclipse - GDB bridge, I am using Xylin native Embedded Debug specifying the arm-none-eabi-gdb
debugger. If I use the standard GDB debugger profile, it looks like it wants to work but when it hits a
breakpoint, eclipse hangs saying "launching Project_name... 27%"

Abhishek, It appears that the Atollic GDB Server is only for Windows and I am running on a Mac...

-John Gentilin
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Problem compiling ChibiOS with -O0 (no opt)

Post by Giovanni »

-O0 works for me using Yagarto 4.6.3, could you give it a try?

Giovanni
gentijo
Posts: 11
Joined: Sat Jul 21, 2012 5:00 am

Re: Problem compiling ChibiOS with -O0 (no opt)

Post by gentijo »

Wow I did not expect that to work.. SF only has 4.6.2 for the Mac as a download so I gave it a try
and it worked under Eclipse using the Zylin native CDT GDB connector.. The standard default C/C++
application run configuration sill fails..

4.7.1 works, it just doesn't work using the Zylin Native native run configuration in Eclipse. If I
use the command line 4.7.1 GDB or the Affnic GUI wrapper, 4.7.1 works fine. I was thinking it
was somehow the Eclipse adapter even though it uses the command line gdb program from yagarto.

thank you..

-John Gentilin
gentijo
Posts: 11
Joined: Sat Jul 21, 2012 5:00 am

Re: Problem compiling ChibiOS with -O0 (no opt)

Post by gentijo »

I now notice that the standard C/C++ run configuration hangs because st-util terminates
after the load command so it's waiting for a response from st-link from the run command.
My gdbinit is as follows.

file build/ch.elf
br main
target extended-remote 127.0.0.1:4242
load

load works, then st-util terminates on the run command. This is with Yagarto 4.6.2 or 4.7.1

-John Gentilin
Post Reply