Best way to communicate between Linux and Arduino program on milk-v duo?

I think the milk-v duo would be great for projects that need both a microcontroller and some kind of board to run an os, but I do not know anything about how to communicate between a sketch running on the 700mhz core and the linux running on the main core.

So far I have tried and been successful with serial, but it is somewhat slow and takes away the ability to use the console on the Linux core (to watch for boot errors, etc).

I have heard of stuff like mailboxes, but I do not know anything about how they work and if they would be better than serial.

1 Like

there is an example of how to use mailboxes on the milk’s github. IMHO, the problem is the mailbox buffer is just 8 bytes (for payload + overhead stuff), so it’s okay to pass a byte or two between the cores, but you can’t pass a string or an array that easily…

1 Like

Hi, the official duo-examples/mailbox-test at main · milkv-duo/duo-examples · GitHub example only uses the large core to communicate with RTOS. After using the arduino image, the small core does not run rtos, how does the big core communicate with arduino now? I want to send the data sampled in Arduino to the big core using mailbox, but I seem to be at a loss at the moment.

1 Like

Hi @mrpp have you had more success since posting this in communicating between cores when using Arduino?

Cheers, Geoff

1 Like

Hi! After a short attempt, I decided to use uart for communication between the two. Fortunately, the development board has enough uarts available. The small core controls the tx of uartA through arduino to send data, and the large core uses something like cat tty/S0 to receive. The received data can be easily stored in txt for me to process.

In addition, regarding arduino using mailbox for communication, the official has released a demo before: Introduction | Milk-V
This demo" can read the information sent by the large core from the MailBox and print it to the serial port, for serial port wiring"

3 Likes

Is the mailbox only 8 bytes total? I see a comment in both the RTOS and Arduino examples that indicate that.

If so I will need to run with serial also. Is there more comprehensive documentation on mailbox?

Thanks, Geoff

1 Like

Should it not theoretically be possible to have shared memory between the cores?

1 Like

In theory, it should be possible to use the rpmsg kernel framework and virtio to use shared memory to communicate between the cores.
I think that OpenAMP implement the RTOS side of that, but I’m not (yet) an expert of this domain.

1 Like

This is not Arduino but take a look at this.

2 Likes