Skip to content

Instantly share code, notes, and snippets.

@css459
Created January 22, 2022 21:23
Show Gist options
  • Save css459/70a9b1aea163fed391e02c6e92325163 to your computer and use it in GitHub Desktop.
Save css459/70a9b1aea163fed391e02c6e92325163 to your computer and use it in GitHub Desktop.
Installing Arch Linux on ClockworkPi DevTerm A06 (WIP)

Installing Arch Linux on ClockworkPi DevTerm A06

Cole Smith

January 22, 2022

Introduction

This document will walk you through installing Arch Linux ARM on the DevTerm A06. At the time of writing, only Armbian is supported on the DevTerm.

We will create a root file system based on the rock64 architecture (rk3328). This will include patching our bootloader and kernel with the patches provided by ClockworkPi.

Setup

This guide assumes you are already using Arch Linux. Some package names or procedures may differ depending on your distribution.

Setting up Chroot Environment

We will start by creating an ARM chroot environment to build our root filesystem using this guide.

  1. Install the required packages
   $ yay -S binfmt-qemu-static and qemu-user-static base-devel arch-install-scripts

   # systemctl restart systemd-binfmt.service
  1. Verify that an aarch64 executable exists in
   $ ls /proc/sys/fs/binfmt_misc
  1. Download the base root FS to use. We will use the aarch64 tarball from Arch Linux ARM
   $ wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
  1. Create the mount point and extract the files as root (not via sudo)
   $ mkdir root 
   $ sudo su
   
   # bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C root
   # mount --bind root root
  1. Chroot into the newly created environment
   # arch-chroot root
  1. Inside the chroot, populate and init the pacman keyring
   # pacman-key --init
   # pacman-key --populate archlinuxarm
  1. Finally, update the packages
   # pacman -Syu

Configuring The Root Filesystem

We will start with lightly configuring our system before compiling the packges.

For this section, all commands will be run inside the chroot.

  1. Install some useful tools
   # pacman -S git vim wget ranger sudo
  1. Set the Locale by editing /etc/locale.gen and uncommenting your required locales.
  2. Run
   # locale-gen

Switch to the alarm user

  1. We can avoid working with the root account by granting alarm, the default Arch Linux ARM user, sudo privileges.
   # EDITOR=/usr/bin/vim visudo
  1. And add the corresponding line for alarm after the one for root
   alarm ALL=(ALL) ALL
  1. Switch to the alarm user
   # su alarm

   $ cd

NOTE: The default password for the alarm user is alarm

Compiling Required Packages

We are now ready to compile versions of U-Boot and the Linux kernel that are compatible with the DevTerm. We will do this inside the chroot environment.

The Manjaro community has done a great job in porting both U-Boot and the Linux kernel to the DevTerm using AUR packages. In the following sections, we will use their PKGBUILDs.

For this section, all commands will be run inside the chroot.

Acquiring GCC Build Tools

U-Boot depends on the arm-none-eabi-gcc executable to be built, and since this program is not available in the Arch Linux ARM repositories, we will download it directly from ARM's website.

  1. Download the binaries
   $ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-aarch64-arm-none-eabi.tar.xz
  1. Extract the binaries to another directory
   $ mkdir gcc 
   $ tar -xJf gcc-arm-10.3-2021.07-aarch64-arm-none-eabi.tar.xz -C gcc
  1. Add the toolchain to your PATH
   $ cd gcc/gcc-arm-10.3-2021.07-aarch64-arm-none-eabi.tar.xz
   $ export PATH=$PATH:$(pwd)
   $ cd

Compiling The Linux Kernel

  1. Download the git repository
   $ git clone https://gitlab.manjaro.org/manjaro-arm/packages/core/linux-clockworkpi-a06.git
  1. Build the package. This can take a long time!! Especially since we are emulating an aarch64 architecture. The package build tool makepkg, supports a flag called MAKEFLAGS. Below, we will append MAKEFLAGS="-j$(nproc)" to the makepkg command to instruct the compiler to use one worker for each core.
   $ cd linux-clockworkpi-a06 
   $ MAKEFLAGS="-j$(nproc)" makepkg -si 
   $ cd

Compiling U-Boot

  1. Download the git repository
   $ git clone https://gitlab.manjaro.org/manjaro-arm/packages/core/uboot-clockworkpi-a06.git
  1. Build the package
   $ cd uboot-clockworkpi-a06 
   $ MAKEFLAGS="-j$(nproc)" makepkg -si 
   $ cd
  1. Rebuild the initramfs (just in case)
    # mkinitcpio -p linux-clockworkpi-a06

Exit the chroot

  1. Exit alarm
   $ exit
  1. Exit root
   # exit

Unmount The Root Filesystem

    # umonut root

Tar The Root Filesystem

We are now ready to package up the root filesystem into a compressed tarball.

    # cd root
    # tar cpJf ../arch-linux-devterm-a06-root-fs.tar.xz .
    # cd ..

Change ownership of the tarball and exit the root account

    # chown <user>:<user> arch-linux-devterm-a06-root-fs.tar.xz
    # exit

You now have a root filesystem tarball to bootstrap the SD card!

Prepare the SD Card

We will now put our prepared filesystem onto the SD card. We will follow Arch Linux ARM's guide for the rock64, but use our tarball in place of theirs.

  1. Zero the beginning of the SD card
   # dd if=/dev/zero of=/dev/sdX bs=1M count=32
  1. Start fdisk to partition the SD card
   # fdisk /dev/sdX
  1. Inside fdisk,

    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. Type n, then p for primary, 1 for the first partition on the drive, 32768 for the first sector
    4. Press ENTER to accept the default last sector
    5. Write the partition table and exit by typing w
  2. Create the ext4 filesystem without a Journal

   # mkfs.ext4 -O ^has_journal /dev/sdX1
  1. Label the filesystem the following, since that is what the bootloader expects
   # tune2fs -L ROOT_MNJRO /dev/sdX1
  1. Mount the filesystem
   # mount /dev/sdX1 /mnt
  1. Install the root filesystem (as root not via sudo)
    # sudo su
    # bsdtar -xpf arch-linux-devterm-a06-root-fs.tar.xz -C /mnt
    # exit
  1. Install the bootloader to the SD card
   # cd /mnt/boot
   # dd if=idbloader.img of=/dev/sdX seek=64 conv=notrunc,fsync
   # dd if=u-boot.itb of=/dev/sdX seek=16384 conv=notrunc,fsync
  1. Unmount and eject the SD card
   # cd
   # umount /mnt
   # eject /dev/sdX

Done!

The SD card is now ready to be booted by the DevTerm! Good luck!

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