2023-04-21 04:11 AM - edited 2023-11-20 07:31 AM
Im trying to jump to bootloader section from my Code. I'm trying to update the firmware over USART with the intergrated bootloader. In my application I'm using USART2 (PA2/PA3) on a STM32L431CCU6 Microcontroller running native FreeRTOS.
My Code to initialize should work:
// Set Memory Boot Jump address
SysMemBootJump = (void (*) (void)) (*((uint32_t *) 0x1FFF0004)); //device dependent parameter System Memory + 4
// Set Display to Firmware Update Mode
display_show( FW_UPDATE );
taskENTER_CRITICAL( );
{
// vTaskSuspendAll( );
// Turn off Peripherals
HAL_TIM_Base_MspDeInit(&htim15);
HAL_RTC_MspDeInit(&hrtc);
HAL_UART_MspDeInit(&huart2);
HAL_UART_MspDeInit(&huart1);
HAL_SPI_MspDeInit(&hspi2);
HAL_SPI_MspDeInit(&hspi1);
HAL_CRC_MspDeInit(&hcrc);
// Disable Interrupts
__disable_irq();
// Remap Memory
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
// Reset Systick timer
SysTick->CTRL = 0; //reset the Systick Timer
SysTick->LOAD = 0;
SysTick->VAL = 0;
__set_PRIMASK (1);
__set_MSP(*((uint32_t *)0x1FFF0000U)); //expected stack pointer value is the value at adress 0x1FFF0000U
SysMemBootJump();
while( FOREVER );
}
taskEXIT_CRITICAL( );
When I try to debugg it, I reach until the jump command and then the debugger is showing nothing anymore. So it looks like it makes the jump.
When analysing the USART interface I see that the device is receiving the 0x7F Command but does not responce on this.
My boot options are all checked:
The Bootpin BOOT0 (PH3) is connected to GND via a 10k resistor.
Do I missed something, that the bootloader does not response?
Solved! Go to Solution.
2023-04-24 01:16 AM
I missed
HAL_DeInit();
before jumping to bootloader.
taskENTER_CRITICAL( );
{
vTaskSuspendAll( );
// Turn off Peripherals
HAL_TIM_Base_MspDeInit(&htim15);
HAL_RTC_MspDeInit(&hrtc);
HAL_UART_MspDeInit(&huart2);
HAL_UART_MspDeInit(&huart1);
HAL_SPI_MspDeInit(&hspi2);
HAL_SPI_MspDeInit(&hspi1);
HAL_CRC_MspDeInit(&hcrc);
HAL_DeInit();
// Reset Systick timer
SysTick->CTRL = 0; //reset the Systick Timer
SysTick->LOAD = 0;
SysTick->VAL = 0;
// Remap Memory
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
// Disable Interrupts
__disable_irq();
__set_PRIMASK (1);
__set_MSP(*((uint32_t *)0x1FFF0000U)); //expected stack pointer value is the value at adress 0x1FFF0000U
SysMemBootJump();
while( FOREVER );
}
taskEXIT_CRITICAL( );
Bootloader is now working.
2023-04-21 08:59 AM
Your parity is set to Even ? 8 - E - 1
2023-04-21 09:52 AM
Yes it is set to Even. I also tried None but that also not worked.
2023-04-22 02:52 AM
Switch in Cubeprogrammer connect to USART and try connect
And primary read AN2606 diagram about interface detection order and check if no other interface is detected .
2023-04-22 04:59 AM - edited 2023-11-20 07:31 AM
I already did that. It is also not working.
According to AN2606 USART is the first interface to check.
2023-04-22 11:23 PM
Interfaces is checked in loop. Quickest as you 7F if other is detected...
Check your connections...
2023-04-23 07:28 AM
What should I check?
the Connection (Usart) is working in normal use.
The other interfaces are not used, they don‘t have a changing signal on the pins.
Are the boot option bits set correct? Or do I have to change something before jumping to bootloader?
2023-04-24 01:16 AM
I missed
HAL_DeInit();
before jumping to bootloader.
taskENTER_CRITICAL( );
{
vTaskSuspendAll( );
// Turn off Peripherals
HAL_TIM_Base_MspDeInit(&htim15);
HAL_RTC_MspDeInit(&hrtc);
HAL_UART_MspDeInit(&huart2);
HAL_UART_MspDeInit(&huart1);
HAL_SPI_MspDeInit(&hspi2);
HAL_SPI_MspDeInit(&hspi1);
HAL_CRC_MspDeInit(&hcrc);
HAL_DeInit();
// Reset Systick timer
SysTick->CTRL = 0; //reset the Systick Timer
SysTick->LOAD = 0;
SysTick->VAL = 0;
// Remap Memory
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();
// Disable Interrupts
__disable_irq();
__set_PRIMASK (1);
__set_MSP(*((uint32_t *)0x1FFF0000U)); //expected stack pointer value is the value at adress 0x1FFF0000U
SysMemBootJump();
while( FOREVER );
}
taskEXIT_CRITICAL( );
Bootloader is now working.