2020-06-08 11:41 AM
Hi,
I use the following code to jump to the bootloader:
typedef void (*pFunction)(void); /*!< Function pointer definition */
#define SYSMEM_ADDRESS (uint32_t)0x1FFF0000
void Bootloader_JumpToSysMem(void)
{
uint32_t JumpAddress = *(__IO uint32_t*)(SYSMEM_ADDRESS + 4);
pFunction Jump = (pFunction)JumpAddress;
HAL_RCC_DeInit();
HAL_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
__set_MSP(*(__IO uint32_t*)SYSMEM_ADDRESS);
Jump();
while(1)
;
}
int main(void)
{
HAL_Init();
SystemClock_Config();
Bootloader_JumpToSysMem();
}
Notes:
If you could share any tips why the STM32F411 may behave differently than STM32F407 in this case.
2020-06-09 03:26 PM
If you put Bootloader_JumpToSysMem() as the first function in main(), does the DFU bootloader get recognized correctly? If so, you need to deinitialize some stuff before jumping.
2020-06-09 09:46 PM
Could you please clarify?
As I wrote it works fine on STM32F411. I believe I deinitialized everything.
2020-06-10 06:20 AM
int main(void)
{
Bootloader_JumpToSysMem();
}
Try this:
2020-06-10 06:26 AM
Got it.
You want to verify if in case of the STM32F407 (because STM32F411 works fine so this is very specific to STM32F407) something is NOT deinitialized.
I will try it.
2020-06-10 09:59 AM
Unfortunately it did NOT help.
Maybe the problem is caused by the deinitialization code...
2020-06-10 10:06 AM
I also simplified the Bootloader_JumpToSysMem():
void Bootloader_JumpToSysMem(void)
{
uint32_t JumpAddress = *(__IO uint32_t*)(SYSMEM_ADDRESS + 4);
pFunction Jump = (pFunction)JumpAddress;
// HAL_RCC_DeInit();
// HAL_DeInit();
// SysTick->CTRL = 0;
// SysTick->LOAD = 0;
// SysTick->VAL = 0;
// __HAL_RCC_SYSCFG_CLK_ENABLE();
// __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
__set_MSP(*(__IO uint32_t*)SYSMEM_ADDRESS);
Jump();
while(1)
;
}
And also no help.
2020-06-12 12:20 AM
Hi,
I gave up the idea of jumping to the bootloader on this STM32F407 board.
Actually it's EvoPrimer, an old and decent piece of hardware, unfortunately somewhat constrained if it comes to using build-in bootloader or external SWD-based programmer (no boot pins exposed to the user, no SWD pins).
I decided to craft my own bootloader compatible with STM32Programmer and I did it yesterday (now I am able to upload the code to the SRAM (and run it) using UART6 - the only UART available to the user).
I do use the HSE (just to test the HSE as the USB bootloader leverages it and one may think it fails).
So I am done from my use case point of view.