2024-09-18 02:38 AM - last edited on 2024-09-18 05:21 AM by Andrew Neil
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.
Solved! Go to Solution.
2024-09-18 05:51 AM
@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
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!
2024-09-18 05:53 AM
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.
2024-09-18 06:06 AM - edited 2024-09-18 07:15 AM
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:
ST-LINK VCP part:
This is a sketch of all of this:
Hope it's more clear now in your mind.
2024-09-18 06:08 AM
@suhfi wrote:okay, we enable the usart connectivity, how do we connect them
The UART connection is carried over the USB link.
@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.
2024-09-18 08:55 AM - edited 2024-09-18 08:57 AM
@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:
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.
2024-09-18 09:56 AM
@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
2024-09-18 03:23 PM