Blink the LED on Milk-V Duo (256M) with RuyiSDK Examples
This tutorial shows how to find the LED Blink example in the extension and use its package manager, virtual environment, and source extraction features to make the board's LED blink.
Prerequisites
- Install the RuyiSDK extension from the VS Code Marketplace.
- Connect to the internet to access RuyiSDK Examples.
- Boot a Milk-V Duo (256M). See the official Milk-V Duo documentation.
- Connect the board and host to the same network. The board's default IP address is
192.168.42.1.
Steps
1. Find the Blink example
-
In VS Code, press
Ctrl+Shift+P, typeruyi home, and choose Ruyi: Open Home. -
On the RuyiSDK Examples card, select Open RuyiSDK Examples.

-
In the board list, select Milk-V Duo (256M), labeled SG2002 · Sophgo · Milk-V.

-
Select Blink to read the example instructions.
You can also open the panel by running
ruyi.board-docsfrom the Command Palette.
2. Install the toolchain
-
Select the Ruyi icon in the sidebar to open the extension home page.
-
In Packages, find and install
gnu-plct.
3. Create a virtual environment
-
In Virtual Environments, click
+:
- Select the
manualprofile. - Select the installed
gnu-plcttoolchain. - Optionally select an emulator.
- Enter a name and path, create the environment, and click its name to activate it.
- Select the
4. Extract the sample code
-
In Explorer, right-click your working directory and select Extract RuyiSDK Package.
-
Find and select
milkv-duo-examplesto extract it into the current directory.
5. Build the Blink program
-
Open the VS Code terminal and activate the environment by selecting it in Virtual Environments. The toolchain is added to the terminal's
PATH. Switch to theblinkdirectory:bashcd blink -
Build with the toolchain from the virtual environment:
bashriscv64-plct-linux-gnu-gcc blink.c -o blink \ -I../include/system \ -L../libs/system/musl_riscv64 \ -lwiringxOr pass the settings to the project's Makefile:
bashmake TOOLCHAIN_PREFIX=riscv64-plct-linux-gnu- \ CFLAGS="-I../include/system" \ LDFLAGS="-L../libs/system/musl_riscv64 -lwiringx" -
Check the resulting binary:
bashfile blink
6. Copy and run the program
-
Copy the program to the board:
bashscp blink root@192.168.42.1:/root/ -
Connect over SSH. The default username is
rootand the default password ismilkv:bashssh root@192.168.42.1 -
Disable the system's Blink script to prevent it from interfering:
bashmv /mnt/system/blink.sh /mnt/system/blink.sh_backup && sync reboot -
After the reboot, reconnect and run the program:
bashssh root@192.168.42.1 ./blink -
The terminal reports the LED state as the blue LED on the board blinks:
textDuo LED GPIO (wiringX) 25: High Duo LED GPIO (wiringX) 25: Low Duo LED GPIO (wiringX) 25: High Duo LED GPIO (wiringX) 25: Low ... -
Press
Ctrl+Cto stop the program.
7. Restore the default LED behavior
After testing, restore the system's original Blink script:
ssh root@192.168.42.1
mv /mnt/system/blink.sh_backup /mnt/system/blink.sh && sync
rebootNotes
- This tutorial uses the Milk-V Duo (256M) with an SG2002. The Milk-V Duo (64M) uses a CV1800B.
- To get help from Copilot, select the blue Open in VS Code button in the upper-right corner of the example. Its contents are copied to Copilot Chat.
- If you do not have a board, select a suitable QEMU emulator when you create the virtual environment and run it from the terminal.