2024-05-28 08:43 AM - edited 2024-05-28 08:47 AM
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:
Thanks in advance,
Paolo
Solved! Go to Solution.
2024-05-29 02:05 AM - edited 2024-05-29 04:26 AM
@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);
2024-05-28 09:31 AM
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?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-05-29 12:18 AM
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...)
2024-05-29 02:05 AM - edited 2024-05-29 04:26 AM
@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);
2024-05-30 03:44 AM
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!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.