cancel
Showing results for 
Search instead for 
Did you mean: 

Communication between Nucleo-F411RE and Raspberry Pi using ST-Link VCP

suhfi
Associate II

Hello, i am using STM32F411RE with raspberry pi 4. i want to communicate rasp with stm32 through usb cable from pi to CN1 of stm32. i want the communication both ways. could you please tell me how to do it?
Thank you in advance.

26 REPLIES 26

Sorry I didn’t understand the content of the image you shared!

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.

OK, I just dug out an RPi and Nucleo board, and tried it.

Before plugging-in the Nucleo board:

AndrewNeil_0-1726661247833.png

After plugging-in the Nucleo board, I get the pop-up for the MSC:

AndrewNeil_1-1726661305479.png

and there is a new /dev/ttyACM0:

AndrewNeil_3-1726661502738.png

 

@suhfi so here,  the /dev/ttyACM0 is the ST-Link's Virtual COM Port on the Raspberry Pi;  you use it just as you would use any other "COM port" (ie, /dev/tty... device) on a Linux system - there is nothing special or specific to STM32 as far as Linux & the Raspberri Pi are concerned.

The actual /dev/tty... device assigned may be different - just like you get different COMxx: numbers in Windows - so use the above method to discover what device is created on your particular system.

 

 


@suhfi wrote:
AndrewNeil_0-1726662198765.png

That's on Windows - not a Raspberry Pi !

And the code you've shown is trying to use the USB peripheral within stm32f411re the chip - not the UART that's connected to the ST-Link's VCP.

PS:

And pasting that code into TeraTerm's clipboard won't do anything useful at all !!

As I expected it needs to be automatically detected on Linux. I thought it would be named ttyUSB. 
Glad to know that!

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.

yes, thank you so much for the reply. And i have understood what you have said, i tried it and got the port. but my biggest concern is while using usb_device in the middleware, i am not able to send any data. like the send function which i am using is sending the blank space to the raspberry pi, so i want to know what exactly to be written in the code to send the data and the debugging process. 

Which middleware?? USB device?

you dont need any middleware you just need to use the UART connected to the stlink. Nothing else!

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.

@SofLit wrote:

I thought it would be named ttyUSB. 


I added a 2nd Nucleo board, and it appeared as  /dev/ttyACM1 

An FTDI cable gets  /dev/ttyUSB0 

AndrewNeil_0-1726662760622.png

Some Google hits on ACM vs USB:

https://rfc1149.net/blog/2013/03/05/what-is-the-difference-between-devttyusbx-and-devttyacmx/

https://www.reddit.com/r/linux/comments/11y07qn/what_is_the_difference_between_devttyusb_and/ 

so, can you specifying me, while using usb connector we can write the code in usart to communicate raspberry pi 4 and stm32 nucleo- f411re board

did you connect by usb connector, or did you connect tx of nucleo board to rx of raspberry pi and vice versa, ground to ground .


@suhfi wrote:

 i have understood what you have said


Clearly, you haven't.

The CN1 connector on the Nucleo-F411RE board connects only to the ST-Link - it does not connect to the stm32f411re microcontroller chip.

The ST-Link's VCP is connected to USART2 of the stm32f411re microcontroller chip:

AndrewNeil_0-1726663381730.png

Therefore, if you want to communicate via the ST-Link's VCP, you need to use USART2 of the stm32f411re microcontroller chip.

You do not use the USB within the stm32f411re microcontroller chip.

 

PS:

The current User Manual for the Nucleo board is unhelpful in that it doesn't clearly show the VCP connection:

AndrewNeil_0-1726664185039.png

This has been reported to ST, but not yet corrected:

https://community.st.com/t5/stm32-mcus-boards-and-hardware/nucleo-user-manuals-don-t-show-the-vcp-uart-connection/m-p/644959/highlight/true#M17438