Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save peterdk/d67fbfca373be92e151b5a6cd314badb to your computer and use it in GitHub Desktop.
Save peterdk/d67fbfca373be92e151b5a6cd314badb to your computer and use it in GitHub Desktop.
Install clean Ubuntu Server 25.04 from official Ubuntu sources on the OrangePi RV2

Install clean Ubuntu Server 25.04 from official Ubuntu sources on the OrangePi RV2

Introduction

I got a Orange Pi RV2 recently, and it only was supplied with a pre-build Ubuntu Server image from a Chinese website. I did not like that too much. It also used Chinese mirrors, and I prefer to have full control over my install. This guide shows you how to build / install Ubuntu Server 25.04 from the official RISCV Ubuntu install media and the provided kernel sources for the RV2.

Approach

  • Build kernel .deb files (using a Ubuntu 22.04 x86 VM)
  • Install Ubuntu 25.04 RISCV using a RISCV VM and a NVME drive that we will use with the RV2.
  • Install kernel deb files, manage the DTB properly, configure some needed stuff
  • Move the NVME to the RV2 and boot

Kernel

The Orange Pi RV2 uses some Ky rebranded Spacemit CPU. It has no official upstream support (yet?), so for the kernel we build it from the Orange Pi provided sources using their build tools. This will generate a few .deb files with the kernel, the DTB and the headers. We can then later install these debs and then get our system to boot on the real device.

We need a Ubuntu 22.04 (required by Orange Pi Build tools) x86/x64 VM. Create one in for example VirtManager or VirtualBox and boot it.

  • I created a KVM VM using VirtManager, added the 22.04 server Ubuntu ISO and a 100GB disk, installed Ubuntu 22.04, and then booted that. You can also use the Desktop Live CD ISO. Make sure to assign multiple CPU cores, since building otherwise is slow.

  • Install needed packages:

sudo apt update && sudo apt dist-upgrade
sudo apt install git
  • Clone the orangepi repo:
git clone https://github.com/orangepi-xunlong/orangepi-build.git
  • Build the kernel:
cd orangepi-build
./build.sh
# Choose Kernel package
# Choose Do not change kernel conf
# Scroll down to orangepirv2
# Wait a long long time while it downloads all dependencies and toolchains

If it hangs for a a long time (5m) when downloading, cancel it with CTRL-C and start over (You might need to delete the failed files in toolchains/[..] In my experience, only the ky-toolchain download consistently fails these days. Since this is a spacemit rebrand, the toolchain seems just to be renamed and can be downloaded from a more stable mirror. So download https://archive.spacemit.com/toolchain/spacemit-toolchain-linux-glibc-x86_64-v1.0.1.tar.xz, extract it in toolchains/ and rename it to ky-toolchain-linux-glibc-x86_64-v1.0.1. Make sure to run touch .download-complete in the ky-toolchain dir to trick the build script into accepting it.

  • Kernel should now start building and then generate .deb files (This will also take significant time)
  • Also build the firmware .deb file:
./build.sh
# Choose 'Rootfs and all deb packages'
# Select 'orangepirv2'
# Select 'Noble [..] 24.04'
# Select 'no'
# Select 'no'
# Now it will start building `orangepi-firmware_1.0.0_all`
  • When it reaches Installing base system (should not take long) and starts processing Ubuntu stuff, press CTRL-C to abort the build script, cause we only need the firmware deb
  • Copy all the generated .deb files from output/debs/*.deb to a place where you can access them later. (Using scp for example over SSH)

Install Ubuntu 25.04 RISCV

  • Create a new VM with RISCV architecture (I use Ubuntu and KVM/Libvirt/QEMU) with your NVME drive that you will be using in the OrangePi RV2 attached, and boot the Ubuntu 25.04 Server RISCV ISO (https://cdimage.ubuntu.com/releases/25.04/release/ubuntu-25.04-live-server-riscv64.iso)
  • Install and configure Ubuntu server however you like, with the NVME drive as target drive.
  • After installation reboot the VM and start the installed Ubuntu. (Still using the VM)
  • Copy the kernel deb files to this running VM
  • Install dependencies:
sudo apt update && sudo apt dist-upgrade
sudo apt install build-essential
  • Install the relevant debs:
sudo dpkg -i linux-dtb-current-ky_1.0.0_riscv64.deb linux-headers-current-ky_1.0.0_riscv64.deb linux-image-current-ky_1.0.0_riscv64.deb orangepi-firmware_1.0.0_all.deb
  • If install fails due to missing dependencies:
sudo apt --fix-broken install
  • Fix DTB setup. The DTB files are setup for uboot, but we can just use GRUB as is already installed. We need to point to a single DTB file, not the dtb dir that is currently setup in /boot:
cd /boot
sudo mv dtb-6.6.63-ky dtb-6.6.63-ky-orig
sudo ln -s dtb-6.6.63-ky-orig/ky/x1_orangepi-rv2.dtb dtb-6.6.63-ky
sudo rm dtb # To be able to boot the default Ubuntu kernel in VM later on if needed, we need to remove the dtb default fallback, otherwise the VM won't boot
sudo update-grub
  • Configure GRUB to boot our new kernel by default, and also not to rename network interfaces so we can use eth0/eth1 and wlan0, instead of other generated names:
sudo nano /etc/default/grub
  • Add the following line at the end of the file for default boot:
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 6.6.63-ky"
  • Change the GRUB_CMDLINE_LINUX_DEFAULT to:
GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0"
  • Change default menu timeout:
GRUB_TIMEOUT=5
  • If you are planning to boot headless (so without HDMI connected), the OrangePi RV2 won't boot with/to GRUB without the following change:
GRUB_TERMINAL=console  #Uncomment this line
  • Save the file and update grub:
CTRL+O
ENTER
CTRL+X
sudo update-grub

Configure needed firmware

  • Clone the orangepi repo:
cd ~
git clone https://github.com/orangepi-xunlong/orangepi-build.git
  • Copy the esos firmware file to the root filesystem:
cd orangepi-build/external/packages/bsp/ky
sudo cp usr/lib/firmware/esos.elf /lib/firmware/
  • Copy the initramfs hook for the firmware to the root system:
sudo mkdir -p /etc/initramfs-tools/hooks/
sudo cp etc/initramfs-tools/hooks/add_firmware_to_initrd.sh /etc/initramfs-tools/hooks/
  • Regenerate the initramfs now that the hook and firmware file are present
sudo update-initramfs -k all -c

Setup ethernet and WIFI

  • Reboot the VM, and make sure to choose the original Ubuntu kernel, not the preselected ky one.
sudo reboot
  • Configure the ethernet and WIFI connections using netplan config (You can skip parts you don't need):
sudo nano /etc/netplan/00-network-setup.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: false
      optional: true
    eth1:
      dhcp4: true
      dhcp6: false
      optional: true
  wifis:
    wlan0:
      optional: true
      dhcp4: true
      dhcp6: false
      access-points:
        "your-acces-point-name":
          password: "your-wifi-password"
  • Set permissions properly for the netplan file
sudo chmod 600 /etc/netplan/00-network-setup.yaml
  • In case you indeed want to use WIFI, we need to install wpasupplicant and also force load a kernel module:
sudo apt install wpasupplicant
sudo nano /etc/modules-load.d/wifi-rv2.conf
# Add the following line to it:
bcmdhd
  • Save the file and exit editor:
CTRL+O
ENTER
CTRL+X
  • Generate network configuration:
sudo netplan generate

We are ready to boot the Orange Pi RV2!

  • Shutdown Ubuntu VM:
sudo shutdown -h -P now
  • Disconnect the NVME drive and place it at the bottom side of the Orange PI RV2 (The upper 2230 slot does not support booting, only the backside one)
  • Connect HDMI, Ethernet, Keyboard and Power
  • Boot
  • Wait for the orangepi boot loader logo, and then after a short while, see it boot GRUB and then the ky kernel!
  • It should boot properly into Ubuntu and you will get the terminal login screen. Network should also work if connected.

You are now running a fresh and upstream Ubuntu 25.04 on your OrangePi RV2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment