2026-01-27 2:29 AM - edited 2026-01-27 2:36 AM
Hi everyone,
I’m feeling a bit defeated by a task that should be "Hello World" level simple. I’m trying to get a basic printf to show up in PuTTY using a NUCLEO-G474RE, but I’m getting absolutely nothing in the terminal.
I do this all the time with my NUCLEO-H723ZG using USART3 and it works like a charm. For the G4, I’ve switched over to USART2, but no luck.
Here is my setup:
Toolchain: CubeMX + CMake.
The Logic: I've overwritten __io_putchar() with a HAL_UART_Transmit call.
The Config: USART2 is enabled, baud rate matches PuTTY (115200), and the clocks seem fine.
I even had a friend who uses G4 boards regularly take a look, and even he couldn't figure out why the data isn't hitting the ST-Link. It feels like I'm missing one tiny, G4-specific checkbox or jumper setting.
I've put together a bare-bones repository with just the code for the printf here: https://github.com/mpek29/nucleoG4
Has anyone else run into similar issues ?
Thanks in advance for any pointers, I'm sure it's something silly I've overlooked!
Solved! Go to Solution.
2026-01-27 6:01 AM
I’ve found the solution! It turns out I had mistakenly selected the wrong board/MCU part number during the initial setup in STM32CubeMX.
After restarting the project with the correct board profile and configuring LPUART1, everything is working perfectly. My apologies for the confusion, and thanks to everyone who took a look!
2026-01-27 2:39 AM - edited 2026-01-27 2:41 AM
1. Make sure to end the string with "\r\n"
2. Set the heap size in project settings to at least 1.5 KiB (0x600). printf() alone takes > 1 KiB. It's safer to use sprintf() which doesn't allocate anything.
2026-01-27 2:44 AM
Is your USART2 configured with pins PA2 as TX and PA3 as RX?
2026-01-27 3:06 AM
I have used pins PB2 as TX and PA15 as RX previously. But I have tried with pins PA2 as TX and PA3 as RX to see if it change anything but it's not the case. I still have nothing. To be able to use PA2 and PA3, I've disable LPUART1 who where used for something with the ST-Link
2026-01-27 3:08 AM
I'm currently working with the statement printf("Hello World!\r\n");, but I'm not seeing any output in my console. I've linked my repository below, if anyone has a moment to take a look or has an idea of what might be misconfigured, I'd really appreciate the help!
2026-01-27 3:19 AM - edited 2026-01-27 3:28 AM
Before adding the complications of printf, have you got it working with a basic blocking HAL_UART_Transmit ?
Use this to prove basic connectivity.
Use ST's example specifically for the NUCLEO-G474RE.
@mpek29 wrote:the data isn't hitting the ST-Link.
How did you test that?
If it is the case, it means you are using the wrong pins for your UART - which is a common mistake.
You must use whichever pins from the STM32 are physically connected to the ST-Link's VCP pins. - other pins will not work
To find which pins those are, see the board's User Manual and/or Schematics.
@mpek29 wrote:I do this all the time with my NUCLEO-H723ZG using USART3 and it works like a charm.
Most likely, the H7 board uses different pins.
@mpek29 wrote:For the G4, I’ve switched over to USART2, but no luck.
It's the pins which really matter!
Also check that your NUCLEO-G474RE hasn't been modified to disconnect the UART from the ST-Link.
PS:
via: https://www.st.com/en/evaluation-tools/nucleo-g474re.html#documentation
2026-01-27 3:20 AM - edited 2026-01-27 3:29 AM
Hello,
How are you using USART2? are you using a USB to UART converter? if yes how?
Are you aware that you can use the virtual comport over USART1 over STLINK on this board? but for that you need to solder SB12 and SB20 as they are not connected by default on the hardware.
2026-01-27 3:43 AM
I usually interface with my NUCLEO-H723ZG via the micro-USB port, utilizing the ST-Link Virtual COM port identified in the Device Manager (which maps to UART3 by default). I've gathered that it’s possible to achieve the same functionality using UART2 instead for the NUCLEO-G474RE. Given that a friend is successfully doing this on the same hardware without physical modifications.
2026-01-27 3:49 AM - edited 2026-01-27 3:51 AM
Each board has its own hardware configuration. On NUCLEO-H723, the VCP is connected to USART3 while on NUCLEO-G474RE, VCP is connected to USART1 and you should solder SB12 and SB20 as I stated previously.
2026-01-27 3:51 AM
@mpek29 wrote:I've gathered that it’s possible to achieve the same functionality using UART2 instead for the NUCLEO-G474RE. .
Where did you "gather" that?
Again, the place to look is the User Manual and/or the board scheematics:
via: https://www.st.com/en/evaluation-tools/nucleo-g474re.html#documentation