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:13 AM
Sorry I didn’t understand the content of the image you shared!
2024-09-18 05:15 AM - edited 2024-09-18 05:18 AM
OK, I just dug out an RPi and Nucleo board, and tried it.
Before plugging-in the Nucleo board:
After plugging-in the Nucleo board, I get the pop-up for the MSC:
and there is a new /dev/ttyACM0:
@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.
2024-09-18 05:25 AM - edited 2024-09-18 05:28 AM
@suhfi wrote:
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 !!
2024-09-18 05:26 AM - edited 2024-09-18 05:26 AM
As I expected it needs to be automatically detected on Linux. I thought it would be named ttyUSB.
Glad to know that!
2024-09-18 05:28 AM
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.
2024-09-18 05:31 AM
Which middleware?? USB device?
you dont need any middleware you just need to use the UART connected to the stlink. Nothing else!
2024-09-18 05:37 AM
@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/
2024-09-18 05:42 AM
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
2024-09-18 05:43 AM
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 .
2024-09-18 05:44 AM - edited 2024-09-18 05:57 AM
@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:
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:
This has been reported to ST, but not yet corrected: