Skip to main content
Explorer
May 28, 2024
Solved

[STM32U585] FreeRTOS hard fault after wake up from STOP3 mode

  • May 28, 2024
  • 3 replies
  • 1681 views

Hello everyone.

I have an application that is based on FreeRTOS and works in power saving mode with STOP3 mode. I have configured each WakeUp pin and all the necessary arrangements for the entrance and exit from low power mode. However, so far I've experienced big troubles at Wake Up: the microcontroller detects a hard fault in the FreeRTOS utilities (debugging from __get_PSP() I've got the Program Counter and Link Register related to the uxQueueMessagesWaiting function, every single time the fault is detected).

I've tried everything: increasing the size of the stack to be allocated to the OS, being careful to be within the maximum size, re-initializing the system with SystemInit()... the microcontroller resets giving no more information than I shared. I attach the main features of the system in use:

- Interrupt Vector Table relocated at: (0x20000000UL)

- Boot loader at 0x08000000 which verifies program file integrity then jumps at it

- Main application at 0x08026000

The main application basically creates all of the tasks, do some stuff in order to initialize all the peripherals and data structures, then enters in STOP3 mode with these three simple HAL functions.

 

HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2_HIGH_2);

HAL_NVIC_SetPriority(PWR_S3WU_IRQn, 0, 0);

HAL_NVIC_EnableIRQ(PWR_S3WU_IRQn);

/* Enter in STOP3 mode */

HAL_SuspendTick();

HAL_PWREx_EnterSTOP3Mode(PWR_STOPENTRY_WFI);

/* Exit from STOP3 Mode */

SystemClock_Config();

HAL_ResumeTick();

 

At last but not least:

  • on STOP2 mode the issue never occurs
  • on debug (no low power mode enabled) this issue never occurs.

Thanks in advance,

Paolo

    This topic has been closed for replies.
    Best answer by pa0grg

    @Sarra.S some news for you. 

    Right now my application takes up about 300 kb of RAM. I have reduced its size by a third and have not noticed any problems with STOP3 mode. So, I did a test to see if the problem was accessing RAM immediately after waking up the microcontroller: I instantiated a (global) buffer of 170*1024 elements and tried to access the element (170*1024 - 1) of the buffer. The result was hard fault.

     

    From the .map:

    .bss._vBYTE_TempBuffer

    0x2000041c 0x2a800 ./Components/Tasks/TASK/TASK_Md0.o
    0x2000041c _vBYTE_TempBuffer

     

    On STOP2 mode and debug no issues experienced. So i think there's a huge problem on accessing RAM right after waking up. Plus, from power saving configuration on "Power and Thermal" section from CubeMX, SRAM1/2/3/4 power down on STOP3 is disabled.

    ---------------------------------

    Update. The problem seems fixed using

       HAL_PWREx_EnableSRAM2ContentStandbyRetention(PWR_SRAM2_FULL_STANDBY);

    3 replies

    ST Employee
    May 28, 2024

    Hello @pa0grg

    Ensure all task stacks are properly aligned since misalignment can cause hard faults... If it's not the case, could you provide a minimal code to reproduce the issue: a minimal system that only wakes up from STOP3 mode and performs a simple task?

    pa0grgAuthor
    Explorer
    May 29, 2024

    Hello @Sarra.S 

    All task stacks should be aligned, I don't se any trobules there. I can provide you the requested code, but first I need to understand how to send it (copy-paste here, send it via e-mail...) 

    pa0grgAuthorAnswer
    Explorer
    May 29, 2024

    @Sarra.S some news for you. 

    Right now my application takes up about 300 kb of RAM. I have reduced its size by a third and have not noticed any problems with STOP3 mode. So, I did a test to see if the problem was accessing RAM immediately after waking up the microcontroller: I instantiated a (global) buffer of 170*1024 elements and tried to access the element (170*1024 - 1) of the buffer. The result was hard fault.

     

    From the .map:

    .bss._vBYTE_TempBuffer

    0x2000041c 0x2a800 ./Components/Tasks/TASK/TASK_Md0.o
    0x2000041c _vBYTE_TempBuffer

     

    On STOP2 mode and debug no issues experienced. So i think there's a huge problem on accessing RAM right after waking up. Plus, from power saving configuration on "Power and Thermal" section from CubeMX, SRAM1/2/3/4 power down on STOP3 is disabled.

    ---------------------------------

    Update. The problem seems fixed using

       HAL_PWREx_EnableSRAM2ContentStandbyRetention(PWR_SRAM2_FULL_STANDBY);

    ST Employee
    May 30, 2024

    Hello @pa0grg

    The test of the large buffer in RAM that you did is a smart choice, this suggests that there might be an issue with the RAM retention or initialization when exiting low-power mode and the RAM section where _vBYTE_TempBuffer is located is not retained during STOP3 mode.

    Glad you've found the solution!