xnux.eu - site map - news

How to install Arch Linux ARM on Allwinner Devices

General steps should be well known to most Arch Linux users:

Where this differs is that there's no generic kernel for all devices, so you have to build a specific one, with configuration suited to the device or a small set of similar devices. And the installation of the kernel and u-boot is a manual process not handled by the package manager.

Getting the rootfs

If installing on ARMv8 device (A64, H5, H6, …)

wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz

If installing on ARMv7 device (H3, A83T, A13, …)

wget http://os.archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz

Prepare the partition table and filesystems

If your distro is using udisk or automountig, you need to be careful or disable it. The guide assumes your distro is not doing some magic automounting in the background.

Replace /dev/sdX with the device where your SD card is located.

sfdisk /dev/sdX <<EOF
label: dos
unit: sectors

4MiB,252MiB,
256MiB,,
EOF

mkfs.vfat -n BOOT /dev/sdX1
mkfs.f2fs -f -l ROOT /dev/sdX2

Mount the filesystems and extract the rootfs tarball

mount /dev/sdX2 /mnt
mkdir -p /mnt/boot
mount /dev/sdX1 /mnt/boot

bsdtar -xpf ArchLinuxARM-armv7-latest.tar.gz -C /mnt
# or (see above)
bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt

Fixup configuration

Setup /mnt/etc/fstab at the very least.

You'll need it to contain:

/dev/mmcblk0p1 /boot vfat rw 0 1
/dev/mmcblk0p2 / f2fs rw,relatime 0 0

You may also want to setup wifi, or enable USB networking, via g_ether driver and some systemd-netword config files to setup the IP addresses and gateways. How to do that should be a general Linux networking knowledge, and it is documented on Arch Linux wiki.

Install the kernel and the bootloader

For the sake of brevity, I'll only tell you how to install my pre-built binary kernel and bootloader.

Go to https://xff.cz/kernels/ and download the latest version of the right kernel package. Names mean: pp for PinePhone, pb for PocketBook, one, pc, pc2, pi3 for Orange Pi One/PC/PC2/3 respectively.

Extract the package and follow the README file inside. You'll just need to copy some files to the right place in your mounted filesystems on the SD card, and flash the bootloader to the boot block via dd, and perhaps customize the kernel boot arguments to tell the kernel where to find the root filesystem. You'll need to install uboot-tools to be able to package the bootloader configuration script.

Umount the filesystems

umount /mnt/boot
umount /mnt
sync

Now you should have a bootable microSD card. Just put it in your device and have fun.

PinePhone Example

For example, when trying to install the kernel and the bootloader on a SD card for PinePhone, the end result is expected to look like this:

Connecting to your device

The challenge here is to configure networking without having a shell access to the running PP.

You'll have to update the configuration files for PP using the SD card reader on your PC.

By default Arch Linux ARM will load most of the modules that are needed to enable networking over USB, except for g_cdc.

With this module loaded, PinePhone will see a usb0 network interface. When connected via USB to a PC, the PC will create network interface for the other side of the network link, too. On my workstation's Ar­ch Linux, this interface is named predictably enp0s20u1 :). The name will be different based on what port you'll stick the PP's USB cable to. You can check dmesg or ip l to get the interface na­me.

You'll also have to configure the both ends of the network link. There are many ways to do it, so let's just use the simplest way and assign a static IP addresses to both sides of the link (10.0.0.2 on PP and 10.0.0.1 on the PC).

PinePhone SD card

Add a configuration file at etc/modules-load.d/usb0.conf to make sure g_cdc module is loaded on boot:

g_cdc

Add the etc/systemd/network/usb0.network file to the rootfs on the SD card so systemd-networkd will configure the network interface:

[Match]
Name=usb0

[Network]
Address=10.0.0.2/24
Gateway=10.0.0.1
DHCP=no

To be able to easily ssh to the PP, you may also copy your key to /root/.ssh/authorized_keys at this time.

PC

On your PC, if you're using systemd, create the following file at /etc/systemd/network/pp.network:

[Match]
Name=yourinterfacename

[Network]
Address=10.0.0.1/24
DHCP=no

Don't forget to restart systemd-networkd.

Put the SD card to the PinePhone and you should now be able to ssh to root@10.0.0.2.