cancel
Showing results for 
Search instead for 
Did you mean: 

Struggling with a simple UART printf on NUCLEO-G474RE (works on H7, not here)

mpek29
Associate II

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!

14 REPLIES 14

@mƎALLEm wrote:

on NUCLEO-G474RE, VCP is connected to USART1 and you should solder SB12 and SB20 as I stated previously.


The User Manual says LPUART1 by default, or USART1 by changing SBs ?

Screenshot above.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

@Andrew Neil wrote:

@mƎALLEm wrote:

on NUCLEO-G474RE, VCP is connected to USART1 and you should solder SB12 and SB20 as I stated previously.


The User Manual says LPUART1 by default, or USART1 by changing SBs ?

Screenshot above.


In fact, it could be both (USART1):

mALLEm_0-1769515156275.png

or (LPUART1 the default configuration)

mALLEm_1-1769515292101.png

 

He needs to play with the solder bridges.

Meanwhile, @mpek29 you can use the printf example provided by the CubeG4 over this link:

https://github.com/STMicroelectronics/STM32CubeG4/tree/master/Projects/NUCLEO-G474RE/Examples/UART/UART_Printf

 

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.

@Andrew Neil wrote:

@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?


@mpek29  Did you ask ST's AI assistant, "Sidekick" ?

It does say UART2:

AndrewNeil_0-1769515771195.png

But that is wrong!

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
waclawek.jan
Super User

USART2 can be used at PA2&PA3 in the same way as LPUART1 can be.

waclawekjan_0-1769521934899.png

Something has probably got lost in the clicking.

Debug as usually, by observing all relevant (RCC, USART, GPIO) registers' content (assuming you've checked the hardware already - pins connections, clock) and observing the waveforms on given pins using oscilloscope/LA.

JW

mpek29
Associate II

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!