Skip to main content
Visitor II
May 5, 2021
Solved

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

  • May 5, 2021
  • 1 reply
  • 1334 views

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

    This topic has been closed for replies.
    Best answer by Olivier GALLIEN

    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

    1 reply

    Technical Moderator
    May 5, 2021

    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

    JatalaAuthor
    Visitor II
    May 5, 2021

    Thanks Olivier. It worked.

    Kind regards

    Jatala