STM32 standard method for remote firmware update

1

My question is about a special case for Bootloader sequence for The Discovery kit for STM32F0 series with STM32F072RBT6 MCU that we currently have implemented in some of our products in the field.

I will use ST's own bootloader to update my firmware but I want to do this remotely which means there is no way of physically shorting the BOOT0 and BOOT1 pins as described in the user manuals to go in "BOOT" mode.

—> lets say the firmware I uploaded is not a good version, it’s buggy or I want to upload a newer version of my firmware later. My Issue here is that I have no way of going back to the ST’s ROM Bootloader to get new firmware AFTER I am running the User application. If I reset the board it will start executing instructions from the flash again and not the ROM.

Is the only solution a custom bootloader?

If the solution is a custom bootloader, I have already implemented a dummy bootloader that I download to the sections 0 and 1 (and more if needed) of my flash. This Dummy bootloader will run first all the time on reset. All it does is that I will decide to jump to the User application code in sections 2-7 of the FLASH or to the ST’s original bootloader in system memory (ROM). It will do so by setting the Main Stack pointer(MSP) to the starting address of sections mentioned, see code below.

void jumpToBootloader()
{
  resetAll();

  // Remap system memory to 0x00000000
  SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SystemFlash);

  __set_MSP(*((uint32_t*) 0x00000000));
  ((void (*)(void)) *((uint32_t*) 0x00000004))();
}

void jumpToMainApp()
{
  resetAll();

  // Tell processor the address of the new vector table before jumping to the main app
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, MAIN_APP_OFFSET);
  __set_MSP(*((uint32_t*) (0x8000000 + MAIN_APP_OFFSET)));
  ((void (*)(void)) *((uint32_t*) (0x8000004 + MAIN_APP_OFFSET)))();
}

This is good as if my firmware is corrupted I can just reset and I am good to upload new code if needed.

How is this done in the industry is there a standard 3rd party tool/lib I can use that provides the same functionality as my bootloader but it is much more stable?

stm32
boot
bootloader
stm32ldiscovery
asked on Stack Overflow Dec 23, 2019 by Ali You • edited Dec 23, 2019 by Ali You

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0