5 years, 10 months ago.

No USB or UART on STM32F407 Discovery

Hi all.

I have a STM32F407VG discovery board, but I'm stuck in getting simple serial communication to work.

Simple code like

Serial pc(USBTX, USBRX);
pc.printf("GHello world!");

or

Serial out(PA_9, PA_10);
out.printf("Hello world!");

does not work. I have tried on all UARTs on the board, on two boards and on 2 computers.

2 Answers

5 years, 10 months ago.

Which version of the Discovery board do you use. The older editions dont support the Virtual Com Port (VCP) on the ST-Link. Some of the newer edition Discovery boards do provide the mbed compatible UART connection in principle. They are named something like ''STM32 XXX DISC1". However, even for the new boards you need to connect the F407 UART pins for Serial pc (USBTX,USBRX) to the ST-Link part so that pc.printf and printf work. You may attempt a hack as explained here and in the user manual or alternatively use a separate USB-Serial converter (eg FTDI 232) instead.

Accepted Answer

Hello,

Jenny: Yes, I believe I have the latest version: V2.J31.M21

Win: I use the STM32F407VG-DISC1 board. MB997D D-01. I suppose it is one of the new boards?

posted by Kasper Madsen 20 Jun 2018

Hi Wim Huiskamp, Thanks for your response. I am using the latest board "STM32F407VG - DISC1". Hope that helps!

posted by raju sambandam 20 Jun 2018

See updated text above: the new DISC1 boards still need a modification before the USB serial port is operational.

posted by Wim Huiskamp 20 Jun 2018

Hi Wim,

Just to make sure that I understand you correctly, In the link you posted above with the explanation to connect pins 12 and 13 on the STLink chip to USART2, the purpose here is to enable communication from the main CPU to the STLink chip and then to a PC console, correct? This is what I would achieve? And I will be able to use Serial pc(PA_2, PA_3); pc.out.printf("Hello world"); to print messages to a PC console?

posted by Kasper Madsen 21 Jun 2018

Hello Kasper, that is correct. The ST-Link functions as a serial-to-USB converter between the target (F407) and the host PC. That is the ST-LINKs second function next to the drag-and-drop programming of the target. The STM Nucleo boards and some of the recent STM Discovery boards already have the correct default wiring for the serial port. The F407 Discovery board is an older type that does not support this feature at all (DISCO version) or only after modifications (DISC1). In case the soldering job needed for the modification is too much of a challenge you can also use an external (FDTI type) serial-to-USB module instead (hardware costs is only a few dollars online).

posted by Wim Huiskamp 21 Jun 2018

Thank you, Wim. I soldered the wires and I now get console serial data via the USB cable connected to the STLink.

posted by Kasper Madsen 22 Jun 2018
5 years, 10 months ago.

Hi Kasper,

Have you tried using just printf without the Serial object? For example:

#include "mbed.h"

int main() {
    printf("Hello World!\n\r");
}

Also, please make sure that your serial terminal viewer is set to view your board's serial output with a 9600 baud rate. This is the default baud rate that the Serial object uses.

The answer I provided on this question may help as well: https://os.mbed.com/questions/81577/Unable-to-send-output-to-a-Terminal-Usin/

Also, there is also a new ST-LINK firmware upgrade available for download here: http://www.st.com/en/development-tools/stsw-link007.html

Please let me know if you have any questions!

- Jenny, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

Hi Jenny,

Yes, I have tried that. I have managed to get signals on UART4 on PA0 and PA1. I used 9600 for all trials. And I updated the firmware :-) But that is by using STM32Duino. I am unable to get it going in mBed, unfortunately.

posted by Kasper Madsen 20 Jun 2018

Hi again Kasper,

The newest ST-LINK firmware was just released today, did you update your firmware again today? http://www.st.com/en/development-tools/stsw-link007.html

Also, please let me know if you see any error messages. Does anything happen at all when you try to compile/flash with Mbed?

- Jenny, team Mbed

posted by Jenny Plunkett 20 Jun 2018

Hi Jenny, Yes, I believe I have the latest version: V2.J31.M21 I don't get any errors. The rest of the program works. Just not serial... I tried with Serial out(PA1, PA0); out.printf("Hwllo world"); But I get nothing on the pins.

posted by Kasper Madsen 20 Jun 2018