Arch Linux On Milkv-duo

First, let’s look at the image:

Pasted image 20230723210101

By replacing the root file system (rootfs), it is possible to run the Arch Linux RISC-V system on milkv-duo.

The following compilation work was done on Ubuntu, and serial connection was made using MobaXterm on Windows.

Step 1: Compilation

Modifying the kernel configuration

First, we need to modify the kernel configuration to add the required features (mainly to meet the dependencies of systemd):

Path:

build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig

diff --git a/build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig b/build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig

index 6c05a05df..d214f4fe0 100644

--- a/build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig

+++ b/build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig

@@ -260,3 +260,23 @@ CONFIG_ADVISE_SYSCALLS=n

 CONFIG_SIGNALFD=n

 CONFIG_TIMERFD=n

 CONFIG_EPOLL=n

+

+# for arch linux

+CONFIG_CGROUPS=y

+CONFIG_CGROUP_FREEZER=y

+CONFIG_CGROUP_PIDS=y

+CONFIG_CGROUP_DEVICE=y

+CONFIG_CPUSETS=y

+CONFIG_PROC_PID_CPUSET=y

+CONFIG_CGROUP_CPUACCT=y

+CONFIG_PAGE_COUNTER=y

+CONFIG_MEMCG=y

+CONFIG_CGROUP_SCHED=y

+CONFIG_NAMESPACES=y

+CONFIG_OVERLAY_FS=y

+CONFIG_AUTOFS4_FS=y

+CONFIG_SIGNALFD=y

+CONFIG_TIMERFD=y

+CONFIG_EPOLL=y

+CONFIG_IPV6=y

+CONFIG_FANOTIFY

Other configuration modifications

Increase the size of memory and the root file system partition (the default size may not be enough for the Arch Linux root file system that we will use later):

diff --git a/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py b/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py

index 84161267a..99d640134 100644

--- a/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py

+++ b/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py

@@ -40,7 +40,7 @@ class MemoryMap:

​     \# =================

​     \# Multimedia buffer. Used by u-boot/kernel/FreeRTOS

​     \# =================

\-    ION_SIZE = 26.80078125 * SIZE_1M

\+    ION_SIZE = 0 * SIZE_1M

​     H26X_BITSTREAM_SIZE = 0 * SIZE_1M

​     H26X_ENC_BUFF_SIZE = 0

​     ISP_MEM_BASE_SIZE = 0 * SIZE_1M

diff --git a/milkv/genimage-milkv-duo.cfg b/milkv/genimage-milkv-duo.cfg

index 40a95c7fb..ef89f3d79 100644

--- a/milkv/genimage-milkv-duo.cfg

+++ b/milkv/genimage-milkv-duo.cfg

@@ -13,7 +13,7 @@ image rootfs.ext4 {

 	ext4 {

 		label = "rootfs"

 	}

-	size = 256M

+	size = 1G

 }

 

 image milkv-duo.img {

Starting compilation

Compile directly using the official command:

cd duo-buildroot-sdk/
./build_milkv.sh

or

export MILKV_BOARD=milkv-duo
source milkv/boardconfig-milkv-duo.sh

source build/milkvsetup.sh
defconfig cv1800b_milkv_duo_sd
clean_all
build_all
pack_sd_image

Step 2: Modifying the root file system

Importing the Arch Linux root file system

First, download the root file system from the Arch Linux RISC-V project:

cd to/a/location
wget https://archriscv.felixc.at/images/archriscv-2023-07-10.tar.zst

Then mount the img image that was compiled earlier for modification:

  1. Find the loop device:
sudo losetup -f

In my case, the output is /dev/loop18, you will need to modify this number according to your actual situation in the future.
2. Binding img Image with loop Device:

sudo losetup -P loop18 /path/to/duo-buildroot-sdk/install/soc_cv1800b_milkv_duo_sd/milkv-duo.img
  1. Mounting the rootfs Partition
sudo mkdir /mnt/duo-rootfs
cd /mnt/duo-rootfs

Delete the original content

sudo rm -rf ./*

Unzip the arch linux root file system here

tar -xvf /path/to/archriscv-2023-07-10.tar.zst -C .

Downloading Required Packages

You can download the required packages from https://mirror.iscas.ac.cn/archriscv/repo

After changing the root file system, the official ko and sh scripts may not be available (they can be copied from the previous root file system, but dependencies may be missing and need to be resolved later). It is recommended to install the rz and sz commands first to use serial transmission of files.

cd /mnt/duo-rootfs/root
wget https://mirror.iscas.ac.cn/archriscv/repo/extra/lrzsz-0.12.20-8-riscv64.pkg.tar.zst

The folks who have resolved the network issue on the development board can directly use pacman to install applications

Flashing the TF Card

After downloading and copying the contents to the microSD card, you can unmount the img image:

sudo umount /dev/loop18p2
sudo losetup -d /dev/loop18

Then you can burn the img image into the TF card

3. Power On and Connect

After inserting the battery and powering on the board, connect to the development board through the serial port. If everything goes smoothly, you should see the login screen after about 40 seconds.

Pasted image 20230723220757

Default username: root
Default password: archriscv

After successfully logging in, run ls to see the previously downloaded lrzsz package. Install it first:

pacman -U ./lrzsz-0.12.20-8-riscv64.pkg.tar.zst

After installation is successful, you can use the rz command to transfer files:

  1. Type rz, and the shell will prompt you to waiting to receive.
  2. In MobaXterm, press Ctrl + right-click and select “Send file using Z-modem”, then select the file you want to upload. I have selected the pre-downloaded neofetch-7.1.0-2-any.pkg.tar.zst package.
  3. Wait for the transfer to complete.

Note: I encountered a phenomenon where the development board became unresponsive when using the rz command to transfer large files. It is recommended to avoid transferring large files as much as possible.

Install neofetch using pacman, run it, and you should see the interface at the beginning of the article.

Pasted image 20230723210101

I am limited in skills and welcome any corrections or suggestions for improvement! Let’s work together!

1 Like