Ok silly n00b question but its buggin' me. I've been writing some addtional support for newlib so that I can use the stdio calls rather than the ch versions (things like printf, fread, etc) anyway, I've got a stubs file that does all the right stuff but newlib blows up the stack for the 'main' thread if you use it in there. I'd love to change the size of the initial stack for main (I can allocate a new stack for a new thread but argh)
--Chuck
stack size
Moderators: RoccoMarco, lbednarz, tfAteba
Re: stack size
Ok, figured out how to change the stack size. (edit the linker script for my board change __main_stack_size__ from 0x400 to 0x1000)
But it still blows up if I try to call printf (as opposed to chprintf()). One would hope they could debug this with the STM utilities but alas on Linux they are sadly not very good.
--Chuck
But it still blows up if I try to call printf (as opposed to chprintf()). One would hope they could debug this with the STM utilities but alas on Linux they are sadly not very good.
--Chuck
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: stack size
I think printf() tries to allocate memory internally so you have to make sure that all the newlib interfaces are working.
Giovanni
Giovanni
Re: stack size
Well, on the newlib site they suggest you need to implement the basic system calls.
http://sourceware.org/newlib/libc.html#Stubs
I implemented them and added my own 'mini-heap' (statically allocated) so that presumably the malloc implementation would work correctly. I'll upload the stubs later (basically I copied this example and then for open added dev-entry structure which basically held a BaseChannel pointer. And my implementation of write then took that pointer and did chPutIO's on it. However, I don't get there. (using LED debugging
)
--Chuck
http://sourceware.org/newlib/libc.html#Stubs
I implemented them and added my own 'mini-heap' (statically allocated) so that presumably the malloc implementation would work correctly. I'll upload the stubs later (basically I copied this example and then for open added dev-entry structure which basically held a BaseChannel pointer. And my implementation of write then took that pointer and did chPutIO's on it. However, I don't get there. (using LED debugging
--Chuck
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: stack size
Note that you don't have to have a dedicated heap, you may use chCoreAlloc() and feed the newlib allocator from the ChibiOS heap.
Giovanni
Giovanni