Supporting OpenCloudOS Adaptation for Milk-V Megrez Development Board
Recently, the OpenCloudOS RISC-V SIG successfully adapted the Milk-V Megrez development board. The adaptation results have been synchronized to the official OpenCloudOS mirror website and are available for download and testing
This work was completed by Malachite, an intern from the PLCT Laboratory of the Institute of Software, Chinese Academy of Sciences. The mentor was Sun Min, an engineer from Kubuds Technology, and the entrusted training community was the OpenCloudOS Community. This is part of the “RISC-V Prosperity 2036 Open-Source Intern Joint Recruitment and Training” program.
About OpenCloudOS Stream
OpenCloudOS Stream (hereinafter referred to as OC) is an independently controllable upstream distribution jointly developed by the OpenCloudOS community and its partners. Featuring full-stack optimization of both the kernel and user-space components, it provides an advanced, high-performance foundational environment. It effectively mitigates risks similar to the CentOS supply discontinuation and incorporates a series of proprietary kernel patches and features, such as allowing non-privileged processes to bind to low-numbered ports, process and mount point protection, and system call and socket auditing. This makes it particularly suitable for cloud-native and containerized applications.
Milk-V Megrez Development Board Introduction
The Milk-V Megrez is a RISC-V development board focused on AI and virtualization. It is equipped with a quad-core SiFive P550 CPU (ESWIN EIC7700X SoC, supporting the 64-bit RV64GBCH standard instruction set) with a maximum frequency of 1.8 GHz and supports up to 32 GB LPDDR5 memory (6400MT/s). The Megrez instruction set supports the H extension, which can effectively enhance native RISC-V virtualization performance.

Adaptation Results Showcase
Currently, OpenCloudOS Stream has achieved initial adaptation to the Milk-V Megrez, completing kernel compilation and boot-up processes. It can launch the minimal Wayland desktop environment, and various functions have been verified. The latest source code is available at [2]; feel free to check it out.


Experience the Adaptation Achievements in 3 Simple Steps
-
Obtain the Distribution / Burn the Image
Download the image file from the OpenCloudOS official website [1]. After decompression, write it to a storage medium such as an eMMC or SD card. Tools like Etcher are recommended for burning the image.
wget https://mirrors.opencloudos.tech/opencloudos-stream/releases/23/images/riscv64/sdcard/ocs_developer_sdcard-megrez.img.xz -
Power On and Boot
Note: Before powering on, the development board must be connected to the host machine via a serial cable (USB Type-C data cable)!
When the OpenCloudOS Stream image is written to the disk (SD card) and the board is powered on, U-Boot may not automatically detect the GRUB bootloader. Therefore, you need to open a U-Boot command line. To tell U-Boot where to boot from, select the appropriate command based on your storage medium, paste it into the U-Boot command line, and execute it.
#SATA hard drive setenv bootcmd 'load sata 0:1 0x84000000 EFI/BOOT/BOOTRISCV64.EFI; bootefi 0x84000000'; saveenv #eMMC module setenv bootcmd 'load mmc 0:1 0x84000000 EFI/BOOT/BOOTRISCV64.EFI; bootefi 0x84000000'; saveenv #SD card setenv bootcmd 'load mmc 1:1 0x84000000 EFI/BOOT/BOOTRISCV64.EFI; bootefi 0x84000000'; saveenvAfter saveenv succeeds, you can try executing the boot command to boot OpenCloudOS Stream.

-
Connect to the Network
You can successfully connect to a specified WiFi via the command line:
## Scan for nearby WiFi networks nmcli device wifi scan ## Connect to an access point nmcli device wifi connect 'SSID_of_desired_WiFi' password 'password'
Introduction to My Megrez Development Board

My Adaptation Plan
Before I adapted OpenCloudOS, two operating systems had already been adapted for Megrez: Fedora and RockOS. The adaptation strategy for the OpenCloudOS kernel was: Port hardware-related source code like drivers and device trees from RockOS, which currently has the best compatibility with it. Here are the challenges and solutions I encountered during the kernel porting process.
Looks Like Kernel Patches Need Merging
The OpenCloudOS kernel is based on version 6.6.68 and includes many custom patches, while RockOS has not released this version—leading to “merge conflicts” between the two. To prevent issues like incomplete driver porting and overwriting of OpenCloudOS proprietary patches, I needed to read the source code, summarize the characteristics of files related to the EIC7700 SoC, and perform batch searches. For example, I placed both kernel source trees in the $HOME directory (~), then used the following command to identify driver code related to the SoC:
for i in $(grep -ril -e 'eswin' -e 'eic7' -e 'win2030' -e 'sifive' .)
> do
> if cmp -s $i ~/OpenCloudOS-Kernel/$i; then
> echo $i
> fi
> done
Then, using the meld tool to compare the two directories, copying files missing in OpenCloudOS over, and for files existing in both, performing line-by-line comparison and selective integration to “resolve the merge conflicts.”
Puzzling UAPI Header Files
During porting, several UAPI header files failed the HDRTEST. However, they compiled successfully in RockOS, and the failures in OpenCloudOS were due to reasons like “contains C++ style comments, non-compliant with ANSI C standard,” “size_t undefined,” etc. Judging them as necessary for driver compilation and that these errors typically wouldn’t occur during user operation, these header files were added to the no-header-test list in usr/include/Makefile.
From 6.6.73 to 6.6.88
At the beginning of the adaptation work, I mistakenly thought that for porting convenience, I should select the RockOS kernel version 6.6.73, which had the closest version number and the least number of differing patches. However, after porting to a bootable state, I encountered several boot dmesg errors that couldn’t be resolved regardless of modifying the config or providing user-space firmware. Hardware like USB_DWC3 and mailbox failed to initialize properly.
Inspection revealed that the device tree in RockOS version 6.6.73 was still incomplete. Replacing the device tree required synchronous changes to the drivers, forcing a complete restart using the latest RockOS kernel source code, version 6.6.88. After initially completing the code porting, the kernel compilation config also needed adjustments.
The NUMA Configuration Option Puzzled Me
Initially, I tried exporting it from /proc/config.gz in OpenCloudOS Stream 23 QEMU, then…
make oldconfig
After compilation, I found that many options related to EIC7700 were not enabled by default, resulting in a kernel that couldn’t boot properly. Adjusting based on RockOS’s eic7700_defconfig was very cumbersome. In contrast, OpenCloudOS related options were quite clear in menuconfig. Therefore, I ultimately chose to create the .config from the eic7700_defconfig template, and then adjust specific options (like NUMA, Tencent Kernel features, etc.) in menuconfig. This should, in theory, make compiling a kernel that boots and drives various hardware normally much easier.
However, if following RockOS’s configuration by not setting NUMA, the compilation of mm/memcontrol.c would fail; enabling NUMA resulted in two early boot dmesg warnings about NUMA:
[ 0.000000] NUMA:Warning: invalid memblk node 8[mem 0x0000000480000000-0x000000087ffccfff]
[ 0.000000] NUMA:Faking a node at [mem 0x0000000080000000-0x00000010003fffff]
This occurred because the memory layout information obtained by the kernel from the device tree did not match the expected NUMA node configuration, causing a fallback to UMA. Since RockOS does not enable NUMA and the EIC7700X only has four cores, it was inferred that “the device tree does not support NUMA”. For full hardware adaptation, NUMA should be disabled—but this prevented successful compilation.
Uncovered an OCS Kernel Patch BUG
After reading the source code for troubleshooting, I found this was an issue introduced by a proprietary OpenCloudOS kernel patch [3]. When enabling MEMCG but disabling NUMA, some functions in mm/memcontrol.c would call other functions that weren’t compiled under those conditions, leading to compilation errors. This fault could also be reproduced on x86_64.
After managing to fix this defect, compilation succeeded when MEMCG was enabled but NUMA was disabled. The patch fixing this defect has currently been pushed to the latest development branch of OpenCloudOS-Kernel [4].
The Joy of Success
At this point, the kernel could compile normally, generate the initramfs via dracut based on the kernel modules, and boot into the system. After boot, aside from a win2030-noc error (the other two distributions adapted for Megrez also have the same issue, speculated to be caused by the RTC having no battery, leading to inability to write to the clock register), and errors from drivers for DSP, NPU, etc., failing to load due to missing user-space proprietary firmware, there were basically no other errors. Functional verification could then begin.
Incidentally Verifying KVM Functionality
-
Read CPU Information

-
Compile and Run KVM Test Items from the Kernel Successfully

-
Successfully Boot Ubuntu Image Using KVM and Large Memory in Snapshot Mode
After downloading the u-boot-qemu DEB package from the RockOS software repository and extracting the S-mode ELF-format U-Boot (not available in the OpenCloudOS Stream software repository), execute:
qemu-system-riscv64 --enable-kvm -M virt \
-cpu host -m 16384-smp 4-nographic \
-kernel ./uboot.elf \
-drive file=ubuntu-25.04-preinstalled-server-riscv64.img,format=raw,if=virtio,snapshot=on

This method does not write changes to the disk image. In the future, it can be promoted to the package testing and development process of OpenCloudOS—simplifying deployment and providing a clean environment free from build dependency contamination with minimal performance loss.
Eager to Verify Tencent Kernel Features
-
Allow Non-Privileged Users to Bind Specific Low-Numbered Ports

-
Load the aegis Kernel Module, Read execve System Call Audit Reports

-
Use the Same Kernel Module to Read Socket Audit Reports

A Few More Words
Currently, the OpenCloudOS Stream kernel adapted for the Milk-V Megrez platform has completed adaptation for most hardware functions (including KVM) and retains proprietary features such as Enhanced MM and Tencent Kernel. The current OpenCloudOS Stream image is not fully complete—it lacks a usable desktop environment. Further steps are needed, including integrating a user-space rootfs (no additional configuration required), firmware and drivers, and improving the boot process for general users.
The Road Ahead is Long
- Functional Adaptation Direction: Issues related to ESWIN SDK, NPU kernel drivers, user-space GPU drivers, and graphics stacks require support and collaboration from ESWIN officials.
- Performance Optimization Direction: Conduct targeted optimization work combining OpenCloudOS’s kernel characteristics and cloud-native business scenarios.
Reference Links
[1] https://mirrors.opencloudos.tech/opencloudos-stream/releases/23/images/riscv64/sdcard/ocs_developer_sdcard-megrez.img.xz
[2] https://gitee.com/malachite/OpenCloudOS-Kernel/tree/p550-dev/
[3] https://gitee.com/OpenCloudOS/OpenCloudOS-Kernel/commit/321e018e4b3fa18cbcc73a97f9cba48a8f911624
[4] https://gitee.com/OpenCloudOS/OpenCloudOS-Kernel/pulls/438