thread stack start address

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

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
susu88
Posts: 3
Joined: Sat Oct 27, 2012 3:21 pm

thread stack start address

Post by susu88 »

Hi!

I'm developing software for an STM32F100 VLDiscovery using ChibiOS. I already have 5-6 threads but sometimes I run into unhandled exceptions, for which I suspect stack overflow to be blamed. I've already read the stack size tutorial, which suggested to fill up the stack with 0xAA's, and check memory while debugging to see which stack gets full. My pretty noob question is how can I find out the starting address of each thread stack? That tutorial mentioned the map file, but I don't really know what to look for exactly...

My other (probably noob) question to this topic: how much stack space do math.h functions eat up? And float operations? (since FPU is not present)

Thanks very much for the answers, btw I'm pretty amazed by ChibiOS. It makes embedded development so easy and fun :)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: thread stack start address

Post by Giovanni »

Hi,

You don't need to do that manually, among the other debug options in chconf.h there is also the stack checking and the stack filling. Try enabling all the debug options you can find there.

Note, if you use Eclipse, there is a debug plugin that is able to calculate the stack usage for each thread.

Giovanni
susu88
Posts: 3
Joined: Sat Oct 27, 2012 3:21 pm

Re: thread stack start address

Post by susu88 »

Hi!
First of all, thanks for the quick reply!
I have installed this Eclipse plugin, and i'm happy to see, that it seems to be working. Nice tool! :)
What I experience now is when I disable all the debug options in chconf, the code is running fine. But with enabled debug options, the system goes into port_halt() after the first chThdSleepMilliseconds(10) in main() and says "stack overflow". But in the thread tab StkUnused is 892 for main, 8 for idle...
Is this a familiar issue? What may be the workaround?
Thank you very much for your help!
susu88
Posts: 3
Joined: Sat Oct 27, 2012 3:21 pm

Re: thread stack start address

Post by susu88 »

Hi!
Updating from 2.4.0 to 2.4.2 did solve the problem, no more stack overflow after ChThdSleepMilliseconds()
Thanks again!
Post Reply