Increasing stack size seems to cause failure

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

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Increasing stack size seems to cause failure

Post by barthess »

I have something strange problems with stack overflow too.

At first everything was fine, but suddenly I began to get into port_halt() trap when try to insert chThdSleepMilliseconds(n) after chThdCreateStatic(). I have cut out all code except blinking thread and get this problem too. After reading articles in http://www.chibios.org I understand that stack overflow occurs. Switching on and off CH_DBG_ENABLE_STACK_CHECK flag has confirmed this. I have try to increase __main_stack_size__ and __process_stack_size__ to 0x0800, but this does not help. After a long "brute force" search I found, that adding -fomit-frame-pointer flag to compiler (both Codesourcery and Yagarto) solve problem. It is very strange, because earlier my project compile and run fine without this flag. I think that I do something totally wrong. But what and where?

I use: MCU - STM32F103RBT6, compiler - Codesourcery, version of ChibiOS - 2.3.0
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Increasing stack size seems to cause failure

Post by Giovanni »

That option has always been part of the default makefile options.

What other options are you using? are you compiling without optimizations or with optimizations? it is possible there is some problem with GCC.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Increasing stack size seems to cause failure

Post by barthess »

Earlier I have use this options "-O0 -ggdb -Wall -Wextra". Now is "-O0 -ggdb -fomit-frame-pointer -falign-functions=16 -Wall -Wextra".
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Increasing stack size seems to cause failure

Post by Giovanni »

I think that -fomit-frame-pointer is implicitly used when compiling with optimizations while it must be manually added if compiling using -O0.

I'll try to verify this.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Increasing stack size seems to cause failure

Post by Giovanni »

It is possible that is the Idle Thread stack overflowing because the extra frame, try increasing just that one.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Increasing stack size seems to cause failure

Post by barthess »

I have try to add in the begin of main.c string "#define IDLE_THREAD_STACK_SIZE 64" without any positive results.

Any way, "-fomit-frame-pointer" solve my problems.
Post Reply