2024-07-17 03:01 AM - last edited on 2024-07-17 06:03 AM by SofLit
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
2024-07-17 03:15 AM
Please see the posting tips for how to properly post source code:
2024-07-17 05:50 AM
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,
2024-07-17 05:55 AM
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.
2024-07-17 05:56 AM
Next time please use </> button when you copy paste your code.
Thank you
2024-07-17 08:37 AM
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.
2024-07-17 09:40 AM
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