Page 1 of 1

thread stack start address

Posted: Sat Oct 27, 2012 5:27 pm
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 :)

Re: thread stack start address

Posted: Sat Oct 27, 2012 7:48 pm
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

Re: thread stack start address

Posted: Sat Oct 27, 2012 11:11 pm
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!

Re: thread stack start address

Posted: Sun Oct 28, 2012 6:17 am
by susu88
Hi!
Updating from 2.4.0 to 2.4.2 did solve the problem, no more stack overflow after ChThdSleepMilliseconds()
Thanks again!