Skip to main content
VChau
Associate II
July 25, 2022
Question

Stack Memory start address

  • July 25, 2022
  • 3 replies
  • 1731 views

HI All,

How to test Stack Over flow in Keil (STM32L0)

Is there any document ? or any process to test Stack over flow

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    July 25, 2022

    The top of the stack is computed via a symbol in startup.s and it moves downward.

    Typical method to determine usage is to start from bottom checking for normal fill pattern, and/or checking ​SP periodically at function or interrupts entry.

    You'd have thought this would be taught in classes..​

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    JPeac.1
    Visitor II
    July 26, 2022

    You'd have thought this would be taught in classes.

    Website programming doesn't deal with any kind of memory management other than the state bag passed with the URL. Chances are the instructor lets the PC OS trap the stack overflow.

    in a single task design, all that's required is a relatively high priority timer driven interrupt that checks the MSP and PSP to see if it's too close to the lower stack limits (remember, M series has two stack pointers).

    For a multi-tasking design, check the system MSP and task PSP for boundary limit when the pre-emptive timer is triggered.

    Another solution is to use an MCU (M3, M4 and newer) with a memory management unit. The MMU is programmed with the stack size and will fault if the SP tries to access memory outside the stack region. The CM0 doesn't have an MMU.

    S.Ma
    Principal
    July 26, 2022

    It is a typical need and usually max out the stack area until the heap size fails build.

    Some compilers estimate stack depth recursively when function are not. ISR are added to it and it makes a pretty expectable stack size. Use function pointers also defeat it. RTOS simplify multitask at the expense of creating an extra stack per task.... I guess to be able to program a memory segment by user to create exception is worth exploring (pcrop?)