Skip to main content
Visitor 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

    This topic has been closed for replies.

    4 replies

    Super User
    July 17, 2024
    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,

    Super User
    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.

    Visitor 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.

     

    Super User
    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

    Technical Moderator
    July 17, 2024

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

    Thank you