Zephyr OS running on the small core

Here’s a blinky app for the small core using Zephyr OS: GitHub - kinsamanka/milkv-zephyros: Zephyr OS running on Milk-V Duo secondary processor

A pre-compiled binary is available here.

Make sure to use the latest Arduino image in order to run this binary.

To test, just copy zephyr.elf to /lib/firmware directory and issue the following commands:

echo stop > /sys/class/remoteproc/remoteproc0/state
echo -n zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
echo start > /sys/class/remoteproc/remoteproc0/state

If successful, the onboard led will blink and the uart4 tx (pin 4) will print the current led state.

Enjoy!

6 Likes

This looks interesting, thank you for sharing

thank you for sharing

This is what I was waiting for! Thank you so much for sharing!

The small core can now communicate using the rpmsg framework.

The sample code can be found under the openamp directory. This is a modified version of the zephyr ipc sample.

Note that this example needs updated kernel modules. The sources can be found here.

A pre-build sd image is available here.

1 Like

I have flashed the release milk-v duo sd image (milkv-duo_sdcard.img), however the uart cant output the normal info, the Bps is 115200, is there anything wrong with my step?

Is the output garbled or no output at all?

If garbled, try a different uart adapter.

1 Like

the output garbled, it is interesting, reflashed the sd image and changed another uart adapter it works, and changed uart adapter back again, it also worked, anyway thks for your advice.

Here’s the OpenEmbedded/Yocto layer that uses the updated remoteproc driver.

The zephyr sample programs can now be built using Yocto. (The blinking led is run from the secondary core using Zephyr OS)

1 Like

have you tried to port remoteproc to develop branch (duildroot-sdk), I have cherrt-picked the1c655766bebffe3d377b0a7f70c1ec2654157f11 into develop branch, but I cant echo stop into " echo stop > /sys/class/remoteproc/remoteproc0/state
sh: write error: Invalid argument"

What exactly have you committed? The remoteproc driver needs an updated mailbox driver too. You can see the needed changes here.

Also, the “stop” command will fail if remoteproc is not yet running.

Could you please post the output of dmesg?

1 Like

I only cherry-picked

[(add remoteproc and burn support for arduino · milkv-duo/duo-buildroot-sdk@7221d23 · GitHub)]
from arduino branch to develop branch, I will try to apply all your patch for rpc, thks.

dmesg:

[root@milkv-duo]~# echo stop > /sys/class/remoteproc/remoteproc0/state
sh: write error: Invalid argument
[root@milkv-duo]~# dmesg
[ 1625.138322] bm-dwmac 4070000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

1 Like

Hi, I am new to riscV and zephyr, I was wondering if this project was compatible with the MilkV duo 256m version of the board. I guess its not because milkv duo 256m is based on sg2002 soc not on CV1800B like the duo. In case it’s not compatible, which steps should I follow, or which steps did you follow to add compatibility to this board ?

I am interested in doing some academic research on it, any information is useful thank you.

1 Like

The small core is the same so the code should still work.

The only difference would be on the memory location where the code resides.

Try comparing the differences between the FreeRTOS code on the original buildroot.

I have no boards to test with but a duo-s is coming soon.

2 Likes

Okay thanks a lot, I will check it out :dizzy:

1 Like

Hi, I am trying to load the zephyr blinky led example. but remoteproc seems to be failing. I am using the arduino image. I am using duo 256m.

[root@milkv-duo]~# echo -n /lib/firmware/zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
[root@milkv-duo]~# echo start > /sys/class/remoteproc/remoteproc0/state
sh: write error: No such file or directory
[root@milkv-duo]~# dmesg | grep remoteproc
[    1.095225] remoteproc remoteproc0: c906l_rproc@0 is available
[    1.101538] remoteproc remoteproc0: powering up c906l_rproc@0
[    1.118152] remoteproc remoteproc0: Direct firmware load for cvirtos.elf failed with error -2
[    1.132706] remoteproc remoteproc0: request_firmware failed: -2
[  212.552214] remoteproc remoteproc0: powering up c906l_rproc@0
[  212.552356] remoteproc remoteproc0: Direct firmware load for /lib/firmware/zephyr.elf failed with error -2
[  212.552376] remoteproc remoteproc0: request_firmware failed: -2
[  212.559501] remoteproc remoteproc0: Boot failed: -2
[root@milkv-duo]~#

Is remoteproc driver not working ? Or is it the zephyr elf is failing ?

1 Like

The code here has not been tested on both the 256m and duo-s.

1 Like

So the problem was actually very simple (my own fault as it was perfectly described in this post), as I was echoing the wrong firmware name to sys/class/remoteproc/remoteproc0/firmware. Error -2 in remoteproc means it cant find the file. Remoteproc looks for the filename written into sys/class/remoteproc/remoteproc0/firmware in the /lib/firmware directory.

After that, renaming it correctly it did work, so I guess this is also valid for duo 256m (at least the blinky example).

One thing to consider also, is that in order to load any firmware to the small core with remoteproc, the file has to declare a .resource_table section (you can check that with readelf -S zephyr.elf), else remoteproc will throw error -22.

1 Like

There was a patch for the resource table on the original firmware.

The firmware provided here or the one built using yocto does not have this requirement.

2 Likes