STM32G0 bootloader usart loop
Hi,
I am using built-in usart bootloader on stm32g0. And I am also using the same usart for communication in my user app. I enabled the bootloader via boot option bits. When I start the debug session, I can see the flow stepping over through the program flow, going over HAL_Init(), SystemClock_Config(), MX_GPIO_Init() and MX_USART1_UART_Init(), and then the program flow comes to my first "HAL_UART_Receive(..." function.
It is at this function that the program jumps to the Bootloader and the bootloader starts to respond to my uasrt commands. After I exit the bootloader, via the "Go command(I use address 0x08000000)", the program flow stops at breakpoint I have at "HAL_Init()" and then when I step over again, I see that as soon as I hit the "HAL_UART_Receive(..." function again, it goes back into bootloader.
So, my thinking now is that after I exit the bootloader, I should modify the boot bit (nBOOT0) in my user code, to disable it and then enabling it again via the uart command later, if i want to return to bootloader?
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
//MX_ADC1_Init();
/* USER CODE BEGIN 2 */
char tmp[1]; //Dummy variable for next line HAL uart receive function.
HAL_UART_Receive(&huart1, tmp, 1, 500);
//cha...
