cancel
Showing results for 
Search instead for 
Did you mean: 

Retaining GPIO Pin state when jumping from main application to bootloader

meimurugan
Associate II

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

5 REPLIES 5
Andrew Neil
Evangelist III
SHs
ST Employee

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
Guru

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".
SofLit
ST Employee

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

Thank you

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.

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.