2025-02-05 2:05 AM - last edited on 2025-04-02 3:03 AM by mƎALLEm
Hello,
I am working on the development of a bootloader for the STM32L4S5ZIT6, and I need help to implement a feature where the bootloader is triggered after receiving a user request in the main application (the main app saves a marker in memory).
Here is what I am trying to achieve:
My question
I tried using SRAM to store a marker, then I perform a reset. What I don't understand is that the data is not cleared with the code below. Could you please clarify this for me
__attribute__((section(".backup_sram"))) volatile uint32_t marker;
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
if(marker == 0x12345678U)
marker = 0x00000000;
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* Enable SRAM2 retention in Standby mode */
//HAL_PWREx_DisableSRAM2ContentRetention();
marker = 0x12345678U;
HAL_NVIC_SystemReset();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/****** Linker script ************/
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
RAM2 (xrw) : ORIGIN = 0x10000000, LENGTH = 64K
RAM3 (xrw) : ORIGIN = 0x20040000, LENGTH = 384K
SHARED_MEMORY (xrw) : ORIGIN = 0x2003FF9C, LENGTH = 100 /* SRAM2 */
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
}
/* Sections */
SECTIONS
{
.backup_sram :
{
. = ALIGN(4);
*(.backup_sram)
. = ALIGN(4);
} > SHARED_MEMORY
I would greatly appreciate any help or suggestions.
Thank you very much!
Solved! Go to Solution.
2025-04-02 3:09 AM
Hello,
According to the product datasheet, SRAM2 retains the data after reset.
Regarding the backup SRAM, it is designed to retain its content even after reset, as long as the backup domain is powered.
2025-04-02 3:09 AM
Hello,
According to the product datasheet, SRAM2 retains the data after reset.
Regarding the backup SRAM, it is designed to retain its content even after reset, as long as the backup domain is powered.
2025-04-02 4:20 AM
Hello,
Thank you for your feedback.
Yes, I used this memory to implement this feature, It' work perfectly.
Thank you.