bootloader for stm32G031k8t6
hello,
I try to write a bootloader function fo the STM32g03 MCU
this is the code:
void JumpToBootLoader(void)
{
UART_HandleTypeDef huart2;
// System boot function pointer:
void (*StartBootLoader)(void);
// System address for the F76xxx family (see ST AN2606):
volatile uint32_t rom_addr = 0x1FFF0000;
// RAM address for the F76xxx family (see ST AN2606):
volatile uint32_t ram_addr = 0x20001000;
// System bootloader location:
StartBootLoader = (void (*)(void)) (*((uint32_t *)(rom_addr + 4)));
// The code below emulates reset conditions:
HAL_RCC_DeInit();
HAL_DeInit();
// Stop & disable SysTick:
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__set_PRIMASK(1); // Disable interrupts
__set_MSP(*(uint32_t*) ram_addr); // Stack pointer
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_EVEN;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
StartBootLoader(); // Jump to the bootloader address
}
as you can see before the end of the function I added the definition of the UART2
I use the cube programmer application and choose UART and CONNECT.
when pressing the CONNECT button I get this error:
Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again
I use a com convertor with 2 LEDS and I can see the LEDS blinking when I press the CONNECT button.
but keep getting the error.
what can I check?
thanks in advanced
