Skip to content

Instantly share code, notes, and snippets.

@maximtrp
Last active May 4, 2024 20:03
Show Gist options
  • Star 24 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maximtrp/e9ad9b674c571279c291b4fcf5deec33 to your computer and use it in GitHub Desktop.
Save maximtrp/e9ad9b674c571279c291b4fcf5deec33 to your computer and use it in GitHub Desktop.
Guide on how to install Arch Linux ARM on SD card for your Orange Pi PC board

Orange Pi PC + Arch Linux ARM: installation guide

This guide is based on multiple guides as well as official instructions for the other boards found on the Internet:

  1. https://github.com/RoEdAl/alarm-uboot-sunxi-armv7
  2. https://uthings.uniud.it/building-mainline-u-boot-and-linux-kernel-for-orange-pi-boards
  3. https://archlinuxarm.org/platforms/armv7/allwinner/pcduino3

I have gone through all these steps recently and got a working board with my favorite Arch Linux ARM. I hope it will be helpful for someone else.

SD card

Replace sdX with the device name for your SD card. Zero the beginning of the SD card:

sudo dd if=/dev/zero of=/dev/sdX bs=1M count=8

Run fdisk to partition the SD card:

sudo fdisk /dev/sdX

At the fdisk prompt, delete old partitions and create a new one:

  1. Type o. This will clear out any partitions on the drive.
  2. Type p to list partitions. There should be no partitions left.
  3. Now type n, then p for primary, 1 for the first partition on the drive, 2048 for the first sector, and then press ENTER to accept the default last sector.
  4. Write the partition table and exit by typing w.

Create the ext4 filesystem:

sudo mkfs.ext4 /dev/sdX1

Mount the filesystem:

sudo mount /dev/sdX1 /mnt

Root filesystem

Download and extract the root filesystem:

wget http://os.archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz
sudo bsdtar -xpf ArchLinuxARM-armv7-latest.tar.gz -C /mnt
sync

Boot script

Install uboot-tools. In ArchLinux:

sudo pacman -S uboot-tools

Create boot.txt file in /boot dir.

cd /mnt/boot
nano boot.txt

Paste the following contents into it:

if test -n ${distro_bootpart}; then setenv bootpart ${distro_bootpart}; else setenv bootpart 1; fi
part uuid ${devtype} ${devnum}:${bootpart} uuid
setenv bootargs console=${console} root=PARTUUID=${uuid} rw rootwait

if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/zImage; then
  if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
    if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
      bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
    else
      bootz ${kernel_addr_r} - ${fdt_addr_r};
    fi;
  fi;
fi

Now create the boot script boot.scr:

sudo mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.txt boot.scr

Unmount your SD card:

sudo umount /mnt
cd /tmp

U-Boot

Clone U-Boot repo and checkout the latest tag (or the one you need):

git clone --depth 1 --branch v2023.04  https://github.com/u-boot/u-boot
cd u-boot

Install the cross compiler for ARM EABI (in Arch Linux):

sudo pacman -S arm-none-eabi-gcc

Compile bootloader (you need to have setuptools Python package to be installed):

export CROSS_COMPILE=arm-none-eabi-
export ARCH=arm
make distclean
make orangepi_pc_defconfig
make

Flash it to the device:

sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8

Booting

Insert the micro SD card into Orange Pi PC, connect Ethernet, and apply 5V power. Use the serial console or SSH to the IP address given to the board by your router. Login as the default user alarm with the password alarm. The default root password is root. Initialize the pacman keyring and populate the Arch Linux ARM package signing keys:

su
# Type in the password: root (by default)
pacman-key --init
pacman-key --populate archlinuxarm

And so on and so forth:

pacman -S sudo
visudo
@joshuataylor
Copy link

joshuataylor commented Jul 26, 2023

This is awesome, thanks so much for this. Might want to grab the kernel headers for the orange pi (5) from aur as well.

With u-boot, you can clone just what you need using this:

git clone --depth 1 --branch v2023.04 https://github.com/u-boot/u-boot

You'll save ~200mb download.

When doing the u-boot step, I get this error though:

sudo mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d boot.cmd boot.scr

mkimage: Can't stat boot.cmd: No such file or directory

How do we go about adding these steps to the archlinuxarm.org website? The wiki page has similar steps for other boards such as the Raspberry Pi 4 (https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4).

I'll reach out on IRC to see if we can get a wiki page added.

@maximtrp
Copy link
Author

maximtrp commented Jul 26, 2023

@joshuataylor I’m glad it was helpful for you! I have corrected git clone and mkimage commands. Thank you for these!

Adding this guide to the official site would be great. Thank you for taking this on!

@InfernalWolf666
Copy link

how install archlinux on orangepi 5 plus ?

@maximtrp
Copy link
Author

maximtrp commented Oct 22, 2023

@InfernalWolf666 OPI5+ is based on another architecture (aarch64). So you cannot use this guide, but you can try to modify it for your needs (replace image link and so on). I do not have any aarch64 devices on hand, so I cannot do it myself.

@osousa
Copy link

osousa commented Jan 22, 2024

Which boards have you tested? I bought a zero 2w, it seems to run Manjaro ARM but i'd much prefer the Arch ARM:

Thank you for this guide

@joshuataylor
Copy link

They're all completely different architectures, setup etc.

The first step is figuring out the chipset, arm version, etc.

Orange Pi 5 is a rockchip RK3588, every chipset has different requirements for building etc.

An example of the rockchip rk3588 for Ubuntu is https://github.com/Joshua-Riek/ubuntu-rockchip where it supports a bunch of boards.

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