Skip to main content
Associate II
July 17, 2024
Question

Retaining GPIO Pin state when jumping from main application to bootloader

  • July 17, 2024
  • 4 replies
  • 2019 views

Hi all,

Am using STM32L010R8T6 device how to retain gpio state when jumping from main application to bootloader section. i want to retain one gpio pin state from main application to bootloader. How to achieve it. Is there anyway to achieve it. Please help me to resolve this issue.

Here is the code for jumping application to bootloader.

 

void BootLoader_jumpToApp(void)

{

volatile uint32_t *appVT;



// main app's vector table

if (g_eeprom->active_image == FW_IMG_B)

{

// Bank B

appVT = (volatile uint32_t *)UPGRADE_APP_BASE;

LOG_INFO(MAIN_LOG, "Main APP : Jump to App B %x", appVT);

HAL_Delay(TICKS_2MS);

g_BootLoaderJumpFlag = JUMP_TO_MAIN_APPLICATION;

HAL_NVIC_SystemReset();

while(1);

}

else

{

// Bank A

appVT = (volatile uint32_t *)FLASH_BASE;

LOG_INFO(MAIN_LOG, "Main APP : Jump to App A %x", appVT);

HAL_Delay(TICKS_2MS);

g_BootLoaderJumpFlag = JUMP_TO_BOOTLOADER;

HAL_NVIC_SystemReset();

while(1);

}

 

 

Thanks,

Meimurugan

4 replies

Andrew Neil
Super User
July 17, 2024
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ST Employee
July 17, 2024

Hello @meimurugan ,

The STM32 HAL library provides a function to lock the GPIO configuration. Locking the GPIO pin can help prevent it from being reconfigured unintentionally. You can use the HAL_GPIO_LockPin function to lock the pin. 

HAL_GPIO_LockPin(GPIOx, GPIO_PIN_y);

Please make sure that the bootloader code does not reconfigure the GPIO pin you want to retain.

 

BRs,

"Please close this topic by clicking on “Accept as solution"" button if it fully answered your question."
TDK
July 17, 2024

The bootloader only configures pins it uses. Other pins are left alone.

However it looks like your jump to bootloader involves a reset of the chip. There's no way to retain pin configuration past a reset (for most pins). They will have their default state after reset.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate II
July 17, 2024

Thanks guru,

Is there anyway to jump from application to boot loader without calling nvic reset function to retain gpio states. Any alternative solution if it’s. Please help me to resolve this issue.

 

TDK
July 17, 2024

Here is example code for how to jump from the application to the bootloader without resetting:

How to jump to system bootloader from application ... - STMicroelectronics Community

"If you feel a post has answered your question, please click ""Accept as Solution""."
mƎALLEm
ST Technical Moderator
July 17, 2024

Next time please use </> button when you copy paste your code.

Thank you

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.