STM32MP157A, enable USART2 through ST-LINK
Hi,
I have a STM32MP157A-EV1 board. I'm running it in the engineering boot mode and programming the Cortex-M4 directly through the STM32CubeIDE. At the moment, I do not use the Cortex-A7.
I would like to enable USART2 and use it through the ST-LINK to view the printf command that I do on the Cortex-M4.
What I did was enabling USART2 in STM32CubeMX :

I did not change any other configuration and simply regenerated the code. Then I used these functions:
In retarget.c
UART_HandleTypeDef *gHuart;
void RetargetInit(UART_HandleTypeDef *huart) {
gHuart = huart;
/* Disable I/O buffering for STDOUT stream, so that
* chars are sent out as soon as they are printed. */
setvbuf(stdout, NULL, _IONBF, 0);
}
In main.c
#include "main.h"
#include "cmsis_os.h"
...
UART_HandleTypeDef huart2;
static void MX_USART2_UART_Init(void);
...
int main(){
...
MX_USART2_UART_Init();
RetargetInit(&huart2);
...
while (1)
{
/* USER CODE END WHILE */
printf("\r\nYour name: \r\n");
scanf("%s", buf);
printf("\r\nHello, %s!\r\n", buf);
/* USER CODE BEGIN 3 */
}
}
However, when I use the Open console on MPU serial device I get absolutely no ouput.
It seems that UART is blocked on the UART_WaitOnFlagUntilTimeout in the stm32mp1xx_hal_uart.c.
Did I do something wrong or is there a simpler method ?
Thank you for your help.
