Showing results for 
Search instead for 
Did you mean: 

printf does not work in example project "LwIP_HTTP_Server_Netconn_RTOS" on Nucleo-STM32F767ZI board



I started a new project with selected target of Nucleo-STM32F767ZI board, and followed the instructions from 

"How to redirect the printf function to a UART for debug messages"

The printf works in the new project, however, when I did the same in the example project "LwIP_HTTP_Server_Netconn_RTOS", I did not get anything from printf.

I added the following into the main.c of the example project:









ST Employee

Hello @Chao ,

can you please attach the modification done in a text format because i can't read the pictures they are too much blurry .

in the meanwhile her are the step you need to follow to get Printf redirection with UART :

  1. choose the UART instance directly connected to the Virtual Com Port (VCP) of STLINK this can be found in the in you case UART3 PD8 and PD9.
  2. make sure that the application in which you are trying to implement the redirection of printf does not have any conflicting GPIO config with those pins or this UART instance (which dosn't seem to be the case in the lwip example )
  3. check if you enable the GPIOD clock the UART clock and you properly configured UART3 instance and selected pin PD_8 and PD_9
  4. define the putchar prototype as follows in main.c (for CubeIDE):
    1. #include "string.h"

      #include <stdio.h>

    2. int __io_putchar(int ch)


      /* Place your implementation of fputc here */

      /* e.g. write a character to the USART3 and Loop until the end of transmission */

      HAL_UART_Transmit(&huart3, (uint8_t *)&ch, 1, 0xFFFF);


      return ch;


you will find in this link a working implementation of printf redirection with uart on the Nucleo-STM32F767ZI board from which you can cross check all the necessary configuration  .


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.