cancel
Showing results for 
Search instead for 
Did you mean: 

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

suhfi
Senior

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

@Andrew Neil wrote:

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


You know? it could be a subject of a knowledge base/Article, unfortunately I don't have a Raspberry board to do the hands on!

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.

okay, we enable the usart connectivity, how do we connect them. in google when i searched, i saw some tx to rx as i mentioned before. but i can say the stm32 nucleo board and raspberry pi 4 has voltage differences and i dont want jumper pins to be connected. Could you please mention how to connect and my problem will be solved.

@suhfi 

I think things are mixed up in your mind.

Let me summurize.

As stated by @Andrew Neil CN1 is the USB connector of the STLINK NOT the USB OTG FS interface of STM32F411 MCU. It's true  that STM32F411 has USB OTG interface but not exported on the board. So what you need to use in this case is the UART (see this reply from @Andrew Neil ). It's a regular UART communication Tx/Rx and there is no need for any USB middleware in your case.

These Tx/Rx pins are connected to STLINK that acts as a Virtual Comport. 

The Raspberry board will act as a PC. This PC is LINUX OS based.

On Linux, VCP interface is detected automatically as stated by me here and tested by @Andrew Neil here.

So all you need to do is to configure USART2 PA2/PA3 (according to the schematics):

STM32F411 MCU part:

SofLit_0-1726664660582.png

ST-LINK VCP part:

SofLit_1-1726664705044.png

 

This is a sketch of all of this:

SofLit_0-1726668916620.png

Hope it's more clear now in your mind.

 

 

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.

@suhfi wrote:

okay, we enable the usart connectivity, how do we connect them


The UART connection is carried over the USB link.

  • Whatever is sent from the UART on the STM32 will be received on the host via its Virtual COM Port; eg, COM13 on your PC or /dev/ttyACM0 on my Raspberry Pi
  • Whatever is sent to the Virtual COM Port on the host (eg,COM13 or /dev/ttyACM0) will be received at the UART on the STM32.

@suhfi wrote:

but i can say the stm32 nucleo board and raspberry pi 4 has voltage differences 


That's all taken care of by the USB link

 


@suhfi wrote:

 i dont want jumper pins to be connected. 


The default configuration of the Nucleo board is that USART2 of the stm32f411re microcontroller chip is connected to the ST-Link's VCP - you shouldn't need to modify any links.


@Andrew Neil wrote:


@suhfi wrote:

but i can say the stm32 nucleo board and raspberry pi 4 has voltage differences 


That's all taken care of by the USB link


Consider, for example, the well-known FTDI* cables:

AndrewNeil_0-1726674560947.png

AndrewNeil_1-1726674583890.png

AndrewNeil_2-1726674598713.png

AndrewNeil_3-1726674903390.png

 

 

They support a whole load of different voltage levels at the UART end, but exactly the same interface at the USB Host end.

So the device at the USB Host end (PC, Raspberry Pi, whatever) is completely oblivious to the voltages used by the UART end.

This is one of the key features of standard interfaces like USB - it means the Host can remain completely ignorant of the internal hardware details (voltages, etc) of the Device.

 

* Other USB-to-UART manufacturers are available.


@suhfi wrote:

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. 


It's unclear if you know for sure you're sending data from the STM32 but are not able to receive on the Raspberry Pi?

 

I know on our SBC with Linux, we had to enable it for it to communicate with an FTDI adapter even though we can see it attached. So  you may need to enable the serial port on the Raspberry Pi. 

~$ sudo usermod -a -G dialout $USER 
~$ sudo reboot

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.