I am porting ChibiOS 2.6.4 to new platform. Unfortunately, my demo application crashes when a context switch to the main thread takes place. I figured out that the main thread context contains garbage data. I think this happens because the context isn't setup like it is for other normal threads.
How do the other ports handle this?
Why doesn't the main thread need a SETUP_CONTEXT?
Re: Why doesn't the main thread need a SETUP_CONTEXT?
chSysInit() setups the context for the main thread, if it's corrupted then you might have a stack overflow.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: Why doesn't the main thread need a SETUP_CONTEXT?
Correct, it uses the same macro, there must be some other detail causing this. All ports do the same thing for the main() thread, it is not port-dependent.
Giovanni
Giovanni
Re: Why doesn't the main thread need a SETUP_CONTEXT?
I can see that mainthread is passed to _thread_init, but that doesn't use SETUP_CONTEXT. Could you point me to the code line or provide a call stack?
(It's not that I don't believe you, but I want to understand where the main thread's context is setup)
(It's not that I don't believe you, but I want to understand where the main thread's context is setup)
Re: Why doesn't the main thread need a SETUP_CONTEXT?
SETUP_CONTEXT isn't required because the main thread is already running when it is initialized. All other threads need the SETUP_CONTEXT so that the first context switch can happen successfully.
After the chSysInit() the context gets pushed to the main thread stack in the same way as all other threads (because of an interrupt or a blocking OS call).
After the chSysInit() the context gets pushed to the main thread stack in the same way as all other threads (because of an interrupt or a blocking OS call).
Who is online
Users browsing this forum: No registered users and 37 guests