Arm Mbed OS support forum

STM32H7A3ZI Custom Board printf not working

Hello,

I am running into issues with our custom board using the STM32H7A3ZI chip. I have followed the various guides when porting custom targets using the mbed-cli tools, specifically, using mbed export to generate the proper Makefile and mbed_config.h for my custom target. I haven’t had any issues with compilation, and i havent had any issues using any of the GPIO pins on the chip, PWM timers work as expected, and essentially the general things run as they should (blinker test, GPIO pin toggling, etc.).

My issues arise when trying to print serial messages. Specifically, with UART TX/RX. I have looked into different guides/forums on getting printing to work, specifically printf, with custom boards. The hitchhikers guide to printf in mbed OS 6 has been very helpful. However, for some reason I do not see any messages in my console while my program runs (multiple LED blinking to ensure code is running). I have changed the PinNames.h file in my custom target directory to define the CONSOLE_TX/RX pins to the defined MBED_CONF_TARGET_STDIO_UART_TX/RX which I set to the desired UART TX/RX pins on the chip (double checked with PeripheralPins.c) and I still do not see anything being printed to console. I have tried remapping the printf using the FileHandle mbed_override_console as well as defining a FILE* type for my unbuffered serial object and trying to print with fprintf. Nothing has worked for this chip in terms of communication however, all other aspects of the chip seem to work fine. Just printing to console and having messages show does not seem to work.

Any help or recommendations would be appreciated. Thank you in advance.

Best regards, Ioakeim

Hello Ioakeim,

I do not see any messages in my console

  • What is your console?
  • How is it connected to the custom board?

So i am using a Jetson nano to communicate with our custom board via UART RX/TX pins. I mapped the CONSOLE_TX/RX to the pins defined by the MBED_CONF_TARGET_STDIO_UART_TX/RX definitions. To view messages on a previous custom board (stm32F427ZG chip) I would screen on to the serial line directly to view the messages (this is what i am calling the console, i am unsure if thats correct terminology now that I think about it) but I would see messages both coming in and coming out. But essentially, my computer (Jetson nano) is connected to the custom board via the UART pins on both devices and my console is the serial line in which i am trying to print and read messages from.

  • Make sure the serial terminal program running on the Jetson nano is functional and configured to use the serial port connected to the STM board. The bit rate, number of data bits, parity and stop bits should match too.

  • The UART’s voltage level on both devices (Jeston nano and STM board) should be the same (3.3V).

  • When two devices communicate over a UART serial line the TX output of the first device should be connected to the RX input of the second device. And the other way round, the TX output of the second device should be connected to the RX input of the first device. Also make sure the grounds are connected to each other.

Hello Zoltan,

Yes, all my configurations for the serial port are the same for both. I used the format function part of the private member class in unbuffered serial object with the proper bit rate, number of data bits, etc. I also double checked to ensure TX/RX on Jetson Nano goes into RX/TX pins on stm respectively. One thing I didnt do and didnt have issues with other custom boards is not wire the power line as the Jetson nano and stm are powered separately. I have the grounds wired to each other. Do you think the power is necessary if both the Jetson nano and stm are powered anyways?

  • I don’t think the power rails shall be connected. It’s sufficient to connect the grounds one to another.

  • According to the corresponding PinNames.h file the PD_8 pin is configured as TX for printf and the PD_9 as RX, unless you decide to select other pins using the MBED_CONF_TARGET_STDIO_UART_TX and MBED_CONF_TARGET_STDIO_UART_RX macros.

  • To test whether the STM32H7A3ZI board sends data over the serial line disconnect the Jetson nano from the STM32H7A3ZI board and on the STM32H7A3ZI board connect the PD_8 pin (TX) to the PD_9 pin (RX).

  • The test requires an LED to be connected to a GPIO pin on the STM32H7A3ZI board and over a 4.7k Ohm resistor to the ground. You can select other than the LED1 pin but then modify the program accordingly.

  • Build a test program for example as below:

#include "mbed.h"

DigitalOut       led(LED1);
BufferedSerial   serial(PD_8, PD_9);

int main()
{
    while(true)
    {
        printf("Hello\r\n");
        while(!serial.readable());  // wait for serial data
        led = !led;                 // toggle the LED to indicate that serial data arrived
        ThisThread::sleep_for(500);
    }
}
  • Flash it to the STM32H7A3ZI board. Then check whether the LED on the STM32H7A3ZI board keeps flashing.

Apologies for the late response. It seems the issue was our clock speed setttings in our custom target file. Once we updated the clock speed setting the printing seems to be working. Thank you very much for your assistance.