Gettiing started with the Milk-V Duo.. As noted in the title this project will cater to Linux users - the examples given will use Linux conventions.  If you are a Windows user - I'm so sorry!!

* What is the Milk-V Duo ?

- The Duo gets it's name from the multiple cores internal to the MCU.  There are 2 main flavours of this board, each of which use different MCU chips. Each chip has a different number of cores. Each of the chips has a small independent 8051 core used mostly for watchdog functions. The smallest chip is called the CV1800B and is featured on the Duo-64Meg board from Milk-V, and to no surprise has 64Meg of internal DDR-2 RAM. It has 2 main RISC-V cores, 1 clocked at 1 GHz, normally used to run Linux; the other is clocked at 700 MHz and according to Milk-V is the freeRTOS core, but for our purposes we will be using it to run Arduino sketches. The 256Meg chip is the SG2002, featuring DDR-3 RAM, and has the same cores as the 64Meg as well as an additional ARM Cortex-A53 core we will not be discussed here.

The board has 2 main I/O ports which allow us to communicate with these chips.  Besides a 100M RJ45 Ethernet port there is a USB Type-C.  The USB connection provides 2 ports for accessing the cores:  A serial port on /dev/ttyACM0 which will be used to upload sketches, and a network port which can be used to SSH into the Linux core via IP address 192.168.42.1.

Although it is transparent to regular Arduino operations the actual mechanisms of uploading is not quite what one would expect.  The Arduino IDE will connect to and upload through the serial port but it is actually implemented on the Linux core.  This relieves the Arduino core from uploading protocol overhead.  Once the sketch is uploaded and verified, the Linux core will assign it to the Arduino core and start it executing.  This also means that the Serial monitor of the IDE will not act as expected - It needs to be connected to the UART3 pins (pins 6 & 7) on the board via a CP2102/4 or FTDI UART to USB adapter. Normal Arduino Serial function are available including printf().  Serial is actually Serial3 - ie. Serial.begin(115200) does the exact same function as Serial3.begin(115200).

To get all these functions happening on the Linux core we need to burn a micro SDcard with the images provided for Duo-64Meg or Duo-256Meg and place it into the socket provided on the board. Note - At the time of writing this blog (June 2024) version 1.0.9 is the most recent that supports Arduino.

As we look through the documentation we will see references to the wiringX library. This is from the old wiring lib that is the foundation that Arduino was built on.  It has familiar functions such as pinMode() and digitalRead().  This library may also be used to write Arduino like 'C' programs to run on the Linux core.  I will be making another blog on this theme.

Now that we have an overview of the architecture we can get started with some example Arduino programs.

Blink on the Arduino Core:

As with any new Arduino board we first need to install the appropriate boards package.  Find it at:

https://github.com/milkv-duo/duo-arduino/releases/download/V1.0.0/package_sg200x_index.json

and add it to the "Additional Boards Manager URL" in the IDE Preferences dialog.  Then go to the Tools -> Boards Manager and search for "Duo" and install it.  Set the port to /dev/ttyACM0.

Next we need to kill the Blink program that is running on the Linux core by default.  We do this via SSH, either on the Linux command line or even easier using Putty.

Enter ssh root@192.168.42.1, and answer "yes" and then the password milkv.  You should get a Linux prompt.  To disable the Linux "Blink", rename the BASH script by entering:

mv /mnt/system/blink.sh /mnt/system/blink.sh_backup && sync

Cycle power to the card...

Now we can use the standard Arduino Blink sketch.  Compile and upload in the...

Read more »