cancel
Showing results for 
Search instead for 
Did you mean: 

Directing Printf to UART4 Linked to Onboard ST-LINK of STM32MP157C-DK2

Jatala
Associate II

Hi,

I am developing firmware on the STM32MP157C-DK2 in engineering mode and using STM32Cube_FW_MP1_V1.4.0 and STM32CubeIDE. I must say this is my first project with a STM device and the tools. I am unable to direct printf to the UART4 linked to the onboard VCP of the STLink debugger. The cube package example 'UART_Receive_Transmit_Console' seems to directing printf to USART3 port, not the UART4. After reading the application note 'AN4989 Rev 3: STM32 microcontroller debug toolbox', printf redirection to uart port seems quite simple task. But since UART4 cannot be assigned to the CortextM4, it is shared port. I am unable to figure out where the handle of UART4 port is defined, which is essentially needed to redirect printf command. Thanks in advance for any help in making it work.

Kind regards

Hafeez

1 ACCEPTED SOLUTION

Accepted Solutions
Olivier GALLIEN
ST Employee

Hi @Jatala​ ,

Indeed UART4 is used as default Linux console port.

But for usage in Enginering mode where A7 is on HOLD you can consider that UART4 is available from M4.

You can simply change UART3 to UART4 in the UART_Receive_Transmit_Console.

For reference you can also force UART4 allocation to M4 inside a CubeMX DK2 project, and let it generate the init code.

Don't forget that once you will switch to "production mode" with Linux you have to avoid usage of UART4 from M4.

Hope it help,

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Olivier GALLIEN
ST Employee

Hi @Jatala​ ,

Indeed UART4 is used as default Linux console port.

But for usage in Enginering mode where A7 is on HOLD you can consider that UART4 is available from M4.

You can simply change UART3 to UART4 in the UART_Receive_Transmit_Console.

For reference you can also force UART4 allocation to M4 inside a CubeMX DK2 project, and let it generate the init code.

Don't forget that once you will switch to "production mode" with Linux you have to avoid usage of UART4 from M4.

Hope it help,

Olivier

Olivier GALLIEN
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Thanks Olivier. It worked.

Kind regards

Jatala

Hi Olivier,

The printf is routed to the UART4 and I can get the messages in minicom terminal on /dev/ttyACM0. But at times (not always), some characters (not same character) are not received, random behavior; although I have set the port configuration on both ends correctly - baud-rate (115200), stop bit (1 bit) and parity (non). First time experiencing something like this. Any idea what could be reason.

Kind regards

Jatala