Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow in tickless mode with debug profile on NUCLEO-L476RG #8184

Closed
janjongboom opened this issue Sep 19, 2018 · 14 comments
Closed

Comments

@janjongboom
Copy link
Contributor

Description

Same as #7222? This is on Mbed OS 5.9 (949cb49) with mbed-os-example-lorawan on NUCLEO-L476RG:

++ MbedOS Error Info ++
Error Status: 0x80020125 Code: 293 Module: 2
Error Message: CMSIS-RTOS error: Stack overflow
Location: 0x8015BF9
Error Value: 0x1
Current Thread: Id: 0x200020E8 Entry: 0x8015BAD StackSize: 0x200 StackMem: 0x20002178 SP: 0x10007EC0 
-- MbedOS Error Info --

Upping the idle thread stack size to 0x400 solves the issue.

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug

janjongboom added a commit to janjongboom/uni-vienna-firmware that referenced this issue Sep 19, 2018
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 20, 2018

cc @ARMmbed/team-st-mcd

@bcostm
Copy link
Contributor

bcostm commented Sep 21, 2018

This stack size is defined in rtos/TARGET_CORTEX/mbed_rtx_conf.h

/** The idle thread's stack size can be configured by the application, if not explicitly specified, it'll default to 512 */
#ifndef MBED_CONF_APP_IDLE_THREAD_STACK_SIZE
#define MBED_CONF_APP_IDLE_THREAD_STACK_SIZE 512
#endif

As this value can be changed by the application I don't know what can we do on our side ?

@jeromecoutant
Copy link
Collaborator

jeromecoutant commented Sep 21, 2018

Are you expecting something like:

#ifndef MBED_CONF_APP_IDLE_THREAD_STACK_SIZE
#ifdef MBED_TICKLESS
#define MBED_CONF_APP_IDLE_THREAD_STACK_SIZE 1024
#else
#define MBED_CONF_APP_IDLE_THREAD_STACK_SIZE 512
#endif
#endif

@janjongboom
Copy link
Contributor Author

janjongboom commented Sep 22, 2018

@bcostm I know that it can be set by the application, but enabling tickless (a supported feature) mode on a NUCLEO board (a supported board) should never return in an instant hard fault. I thought this was acknowledged and fixed in #7222. If we cannot reduce stack usage in debug builds when using tickless we should increase idle thread stack size as @jeromecoutant is suggesting (I'd rather optimize this in a way that it's not required, but OK).

@jeromecoutant
Copy link
Collaborator

jeromecoutant commented Oct 1, 2018

Hi

For information, I am currently testing TICKLESS feature with NUCLEO-L476RG.
Tests are OK in default mode, but often crash in Stack overflow as soon as I added some stats (MBED_CPU_STATS_ENABLED in my case)...

Maybe ARM core experts can double check ?

Thx

@ARMmbed ARMmbed deleted a comment from ciarmcom Oct 1, 2018
@jeromecoutant
Copy link
Collaborator

jeromecoutant commented Oct 2, 2018

@0xc0170 @deepikabhavnani

@adbridge
Copy link
Contributor

adbridge commented Oct 4, 2018

Internal Jira reference: https://jira.arm.com/browse/IOTPART-6578

@jeromecoutant
Copy link
Collaborator

@c1728p9

@jeromecoutant
Copy link
Collaborator

@janjongboom do you any internal ARM contact to start the discussion about IDLE_THREAD_STACK_SIZE,
depending or not from TICKLESS ?
Thx

@janjongboom
Copy link
Contributor Author

@bulislaw @0xc0170 ^

@c1728p9
Copy link
Contributor

c1728p9 commented Oct 25, 2018

I took a look at the stack overflow on debug builds with the NUCLEO-L476RG and can confirm that the background thread is overflowing. It looks like most of the extra stack usage is coming from the low power ticker wrapper which is used on the background thread when tickless is enabled. Below is a breakdown of the stack usage.

Stack function Stack pointer Increase   Notes
update_present_time() 0x200015e0 120   Stack start = 0x20001070
schedule_interrupt() 0x20001658 56   Stack end = 0x20001870
ticker_insert_event_us() 0x20001690 32   Used = 656
mbed::TimerEvent::insert_absolute() 0x200016b0 32    
mbed::Ticker::setup() 0x200016d0 32    
mbed::Ticker::attach_us() 0x200016f0 24    
LowPowerTickerWrapper::_schedule_match() 0x20001708 96    
LowPowerTickerWrapper::set_interrupt() 0x20001768 16    
lp_ticker_wrapper_set_interrupt() 0x20001778 16    
schedule_interrupt() 0x20001788 56    
ticker_insert_event_us() 0x200017c0 32    
mbed::TimerEvent::insert_absolute() 0x200017e0 32    
rtos::internal::SysTimer::schedule_tick() 0x20001800 56    
rtos::internal::SysTimer::suspend() 0x20001838 16    
default_idle_hook() 0x20001848 16    
rtos_idle_loop() 0x20001858 8    
osRtxIdleThread() 0x20001860 16    
osThreadGetId() 0x20001870      

@jeromecoutant
Copy link
Collaborator

@janjongboom Could you review #8551 ?
Thx

@jeromecoutant
Copy link
Collaborator

This issue should be fixed by #8551
Thx

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 12, 2018

Please test and reopen if there is still issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants