Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 1 month ago.
Thread stack underflow - i have no clue
After working with mbed and cli for about two month now, porting mbed to a custom board based on the STM32F072VB.
128KB Flash, 16KB SRAM. Stack Pointer is on 0x20004000UL, and this is my code:
main.cpp
#include "mbed.h"
Serial myserial(PA_9,PA_10, 9600);
Thread t1,t2;
void toggle_on(Serial *thisserial) {
for(;;){
thisserial->printf("Thread-number: %d", Thread::gettid());
}
}
int main() {
// Start the event queue
t1.start(callback(toggle_on, &myserial));
t2.start(callback(toggle_on, &myserial));
for(;;){
}
}
And my error-msg: ThreadCMSIS-RTOS error: Stack underflow (status: 0x1, task ID: 0x200014F4, task name: (null))
I have no clue whats going wrong. I already decreased the main-stack-size(2kB) and thread-stack-size (512byte). With more stack-sizes, i get an error that i dont have enough memory for allocation.
Best regards Chris
1 Answer
8 years, 1 month ago.
Hello Chris,
"ThreadCMSIS-RTOS error: Stack underflow (status: 0x1, task ID: 0x200014F4, task name: (null))" indicates stack overflow. ( I agree that its confusing to have the word "underflow" ). So, please try increasing your stack size and see if that fixes the problem. You can set a custom stack size using osThreadAttr_t struct.
Thanks, Senthil
Using printf in this context leads to cluster fuck. Question answered.
posted by Christopher Meis 25 Oct 2017