cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 DISCO Print to /dev/tty

botmail2422
Associate II
Posted on June 10, 2016 at 19:20

I have seen several people use the ''cat /dev/USB<some number>'' can get information from the board printed to a Linux terminal via USB cable. I have followed a few guides (http://www.carminenoviello.com/2015/03/02/how-to-use-stm32-nucleo-serial-port/) and it isn't working. The example provided in the linked tutorial compiles perfectly, but my device doesn't show in the /dev folder. What is going wrong? Is there an easier way to print a lot of data to a terminal (semihosting is too slow for what I need)? Does my device have to be transmitting serial comm to get recognized by the /dev folder?

#printf #!stm32-!vcp-!/dev #!cables
10 REPLIES 10
botmail2422
Associate II
Posted on June 10, 2016 at 19:29

Also, when I run ''lsusb'' I get the following output:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 006: ID 0483:3748 STMicroelectronics ST-LINK/V2

Bus 002 Device 003: ID 413c:2112 Dell Computer Corp.

Bus 002 Device 002: ID 0461:4d81 Primax Electronics, Ltd Dell N889 Optical Mouse

Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

So I went to /dev/usb/002/ and ran the command ''sudo cat 006'' which gave me scrambled ascii chars....

When I run ''dmesg | grep tty'' I get the following output:

[    0.000000] console [tty0] enabled

which might help with debugging... Any advice?

Posted on June 10, 2016 at 20:46

You don't have a Nucleo board, the original STM32F4-DISCO (407G, 401C, 411) do not support mbed, and don't have a VCP on the ST-LINK

PA9 and PA10 USART1 are also not usable on the STM32F4-DISCO due to a large capacitor on the PA9 pin

The newer DISC1 variant supports mbed, but you have to solder serial pins to the ST-LINK part.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
botmail2422
Associate II
Posted on June 11, 2016 at 21:58

Thanks clive! What should I use to get output of a print function to my Linux terminal? I've successfully set up semihosting with gdb and openocd but it's WAY to slow. I need output like the end of the 20 second video:

https://www.youtube.com/watch?v=hHdDslVI7O0
Posted on June 11, 2016 at 23:13

Ok,

retargeting the input/output stream to a USART on Keil works fine. 9600 baud could yield ~1000 characters per second, 115200 around 11000 characters per second. Certainly should be capable of saturating the wire.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
botmail2422
Associate II
Posted on June 13, 2016 at 05:45

If I'm redirecting io stream to USART.... I'm going to need a USB to Serial cable where I only connect Tx and Rx pins, right? Like this one? http://goo.gl/NMondG or do I need a USART to USB like this one? http://goo.gl/XgNhTx

mark239955_stm1
Associate II
Posted on June 13, 2016 at 11:29

You can also use the USB OTG port on the DISC0; you just need to include code to have it enumerate as a CDC device (virtual COM port), then you can hook onto the OTG port with a micro-B USB lead.

Cube does include USB device example code, including CDC, but (as of last time I worked with Cube, about 4 version ago) it's very primitive and needs a fair bit of work to make it useful.

botmail2422
Associate II
Posted on June 13, 2016 at 15:18

Markt, I'm trying to use the CN5 connector but it is not working. When I have CN1 and CN5 connected (at the same time to the board) all LEDs shut off (including power). Is CN5 drawing too much power? And when CN5 is connected my device does not show in my dev folder. No matter what I do I can't get the board to show in dev... Any advice? This is the output of ''dmesg'': http://pastebin.com/FuTf7NW4

mark239955_stm1
Associate II
Posted on June 14, 2016 at 04:17

Having the DISC0 board shut down when both the debug/power lead (CN1) and the OTG lead (CN5) are connected is not a good sign, it suggests that a short is occurring somewhere.  Does your PC complain about excessive current been drawn from its USB port?  Are you still able to debug the  board?  Is there anything else connected to the board other than the two USB leads?  Have any modifications been made to the board at all?

I should add that I'm not a linux user, so your log dump is not particularly meaningful to me.

I'm not sure if Cube works under linux (I'd be surprised if it doesn't, but I just don't know), but a very simple Cube CDC example loaded into the DISC0 should be able to enumerate as a COM port (/dev/tty), although it probably won't be able to send or receive anything.  In any case, unless you've got a USB device driver loaded into the DISC0, connecting CN5 to a PC will do nothing useful.

botmail2422
Associate II
Posted on June 14, 2016 at 15:26

When I plug my CN5 in on a Windows machine it does complain about excessive current being drawn... :( This board hasn't had any other problems besides that one. Since my CN5 doesn't work, I changed my approach. I am using a UART connection to a modem that is programmed to convert to RS-232 (it's known good). I then have a RS-232 to USB converted plugged into the modem (so UART -> RS-232 -> USB). I used the STM3CubeMX (yes it does work on Linux) and came up with this sample code. Unfortunately, the modem isn't detecting any input. Is anything wrong with this code that uses PA2 as Tx and PA3 as Rx?

http://pastebin.com/ZpNMAmNv