Enabling OpenCloudOS Adaptation for Milk-V Megrez Development Board
Recently, the OpenCloudOS RISC-V SIG successfully adapted EDK II, and the adaptation results have been recognized by the OpenCloudOS community. Experience the fascinating journey from firmware to operating system with just one command. Currently, the distribution containing EDK II has been released on the official OpenCloudOS mirror website [1]. We welcome you to try it out.
This work was completed by Luna, an intern at the Institute of Software, Chinese Academy of Sciences PLCT Laboratory, with mentorship from Engineer Sun Min of Kubuds Technology. The delegated training community is the OpenCloudOS community, forming part of the ‘RISC-V Prosperity 2036 Open Source Intern Joint Recruitment and Training Program’.
Introduction to OpenCloudOS
OpenCloudOS (abbreviated as OC) is an open-source cloud-native operating system project jointly initiated and maintained by leading domestic technology companies. Designed as a next-generation OS for cloud infrastructure and edge computing scenarios, its core features include:
- Cloud-native architecture
- High-performance kernel
- Full-stack domestic adaptation
- Security and compliance system
Introduction to OC Community RV SIG
The OC RISC-V Special Interest Group (OC RV SIG) is a core working group within the OpenCloudOS community focused on RISC-V architecture adaptation. Its primary missions include:
- Hardware adaptation and kernel support In-depth adaptation for mainstream RISC-V cores like SG2042, EIC7700x, UR-DP1000 Co-source kernel support, providing LTS maintenance for the RISC-V architecture under oc-kernel
- Software stack construction Development of lightweight Runtime containers, supporting cross-architecture RISC-V container image builds Support for the RVA23 baseline, building a high-performance RISC-V operating system。
Introduction to EDK II
EDK II is an open-source BIOS project developed by Intel, used for building BIOS firmware. The project provides a complete BIOS development environment, including compilation toolchains, compilation scripts, and BIOS source code. As an open-source UEFI project itself, it is based on Intel’s UEFI standard and is also applicable to the RISC-V architecture.
Adaptation Approach
Boot chain:
> QEMU built-in OpenSBI -> EDK II Boot -> GNU GRUB -> OpenCloudOS Kernel -> OpenCloudOS Initramfs -> OpenCloudOS Rootfs
- The EDK II boot chain reads the first
vfatformatted disk and loads the filebootriscv64.efi(since the system is 64-bit) as the bootloader. - This file is provided by the EDK II project for booting the EDK II project itself.
- GNU GRUB is used as the bootloader within the chain to load the OpenCloudOS Kernel.
- GNU GRUB loads the OpenCloudOS Kernel and the OpenCloudOS Initramfs, then proceeds to the rootfs.
Adaptation Challenges
- In the OpenCloudOS kernel, CONFIG_NUMA needs to be enabled.
- In the OpenCloudOS rootfs, the UUID of the target hard disk to be read is hardcoded in
/etc/fstab. Therefore, when migrating this rootfs, the current hard disk UUID must be manually written. - The self-compiled kernel and the hardware architecture must match — if extended features are enabled at the OS level, the corresponding extended features must be present in the virtual machine (or physical hardware).
- The two UEFI files generated by EDK II are recommended to be set to 32MB to match the ROM loading process during RISC-V boot.
How to Experience the Distribution with QEMU?
Note! Requires QEMU version: >=8.0.0
Build the Image Yourself
Refer to the links at the end [2][3][4].
Run the Official Image Directly
wget -r -np -nH --cut-dirs=6 -P ocs-riscv --reject="index.html*" https://mirrors.opencloudos.tech/opencloudos-stream/releases/23/images/riscv64/uefi-qemu/ && cd ocs-riscv && unxz -dv ocs23-riscv-uefi-20250716.qcow2.xz
Booting via QEMU Emulation
- In a Linux environment:
qemu-system-riscv64 \
-machine virt,pflash0=pflash0,pflash1=pflash1,acpi=off \
-cpu max \
-nographic \
-m 8G \
-smp 8 \
-blockdev node-name=pflash0,driver=file,read-only=on,filename=./uefi/RISCV_VIRT_CODE_32M.fd \
-blockdev node-name=pflash1,driver=file,filename=./uefi/RISCV_VIRT_VARS_32M.fd \
-drive file=./luna_oc_riscv_6.6.94.qcow2,format=qcow2,if=virtio,index=0,media=disk
- In a Windows PowerShell environment:
qemu-system-riscv64 ^
-cpu max ^
-m 8G ^
-smp 8 ^
-nographic ^
-machine virt,pflash0=pflash0,pflash1=pflash1,acpi=off ^
-blockdev node-name=pflash0,driver=file,read-only=on,filename=./uefi/RISCV_VIRT_CODE_32M.fd ^
-blockdev node-name=pflash1,driver=file,filename=./uefi/RISCV_VIRT_VARS_32M.fd ^
-device usb-ehci,id=ehci ^
-device usb-kbd,bus=ehci.0 ^
-serial mon:stdio ^
-boot menu=on ^
-drive file=./luna_oc_riscv_6.6.94.qcow2,format=qcow2,if=virtio ^
-netdev user,id=net0,hostfwd=tcp::88-:22,hostfwd=tcp::396-:5432 ^
-device virtio-net-device,netdev=net0
Screenshots of Successful QEMU Boot
Linux environment

Windows PowerShell environment

Next Steps
Currently, efforts are underway to build an automated program that can generate a bootable Linux system ISO image based on EDK2 and GNU GRUB.
This issue depends on the resolution of some upstream driver-related problems in the system; otherwise, existing configuration files will still need to be used.
Acknowledgments
Thanks to the technical support from the UEFI team led by Professor Dai Hongjun of Shandong University and the strong support from Teacher Chen Xinlong of the OC community.
About Intern Luna
“A large feline who likes to take it easy, sometimes sitting by the computer with a cup of coffee all day.”
Reference Links
[1] https://mirrors.opencloudos.tech/opencloudos-stream/releases/23/images/riscv64/uefi-qemu/
[2] https://github.com/LunaticLegacy/OpencloudOsLaunch.git
[3] https://gitee.com/lunaneko/OpencloudOsLaunch
[4] https://github.com/AII-SDU/rv-sp-test-mod.git