Keil Logo

ARM: RTXv5 Reports Error "osRtxErrorStackUnderflow"


Information in this knowledgebase article applies to:

  • Keil MDK Version 5
  • Pack: ARM CMSIS v5.00 or later
  • RTX Version 5

SYMPTOM

When using RTXv5, an implementation of CMSIS RTOSv2 API, my application throws the following error:

osRtxErrorStackUnderflow

before entering into an endless loop in the function osRtxErrorNotify().

What could be causing this issue?

CAUSE

Likely, the stack of a thread was not allocating enough memory, before the thread started executing.

RESOLUTION

To find out which thread requires more resources, select the Source component variant for RTXv5, from the Manage Run-Time Environment dialog.

Manage RTE RTXv5 source variant

  • Note: In all versions of Arm's CMSIS pack, some users may receive the following warning or error message in the source file "rtx_kernel.c". Modify your project's settings accordingly:

    C:\Keil_v5\ARM\PACK\ARM\CMSIS\5.0.1\CMSIS\RTOS2\RTX\Source\rtx_kernel.c(32):
    error:  #29: expected an expression   { .os_id = osRtxKernelId,
    

    Arm Compiler 5 users can either enable "C99 Mode" or add the flag "--c99" to a source file's Options dialog => C/C++ tab => Misc. Controls to resolve the error.

    C:/Keil_v5/ARM/PACK/ARM/CMSIS/5.0.1/CMSIS/RTOS2/RTX/Source/rtx_kernel.c(33):
     warning: designated initializers are a C99 feature [-Wc99-extensions]
    

    To avoid these warnings, Arm Compiler 6 users can either select "c99" from the "Language C:" drop-down list in the C/C++ (AC6) tab, or use the flag "--std=c99".

After bringing in the RTXv5 source, in editor mode, go to the definition of the function osRtxThreadStackCheck(). Set a breakpoint at the call to osRtxErrorNotify(). Users can do this at optimization level 0. In debug mode, a custom Component Viewer dialog called RTX RTOS (View => Watch Windows => RTX RTOS) displays the status of all v2 threads. After running to the breakpoint, find the active thread. Exit debug mode, and increase the thread's stack size.

MORE INFORMATION

SEE ALSO

Last Reviewed: Monday, January 11, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.