Difference between revisions of "Quartz64 Installing Arch Linux ARM"

From PINE64
Jump to navigation Jump to search
m
Line 107: Line 107:


For a different type of Quartz64 device (e.g. Model B) replace the <tt>fdt</tt> line with the appropriate <tt>/boot</tt>-relative path to the device tree.
For a different type of Quartz64 device (e.g. Model B) replace the <tt>fdt</tt> line with the appropriate <tt>/boot</tt>-relative path to the device tree.
=== Finishing Touches ===


{{note|Here's where you'd do the part I said was iffy and won't be necessary with 5.16 anymore. You'll need an Arch Linux or Manjaro system. If it's not an aarch64 system, you'll also need <tt>qemu-user-static</tt>. First, get [https://overviewer.org/~pillow/up/e96363af01/linux-aarch64-rc-5.16.rc4-1-aarch64.pkg.tar.zst the linux-aarch64-rc package I patched and built], then copy it somewhere into your mounted root.
{{note|Here's where you'd do the part I said was iffy and won't be necessary with 5.16 anymore. You'll need an Arch Linux or Manjaro system. If it's not an aarch64 system, you'll also need <tt>qemu-user-static</tt>. First, get [https://overviewer.org/~pillow/up/e96363af01/linux-aarch64-rc-5.16.rc4-1-aarch64.pkg.tar.zst the linux-aarch64-rc package I patched and built], then copy it somewhere into your mounted root.

Revision as of 18:40, 6 December 2021

This page is a work in progress. If you are not familiar with user-mode QEMU, wait for the 5.16 kernel release. Right now there's still an iffy step left: installing a custom kernel package to get it booting. This will no longer be necessary with Linux 5.16.

Commands to be run as a normal user are prefixed with $, commands to be run as root are prefixed with #. We assume your target device is /dev/sdb, adjust accordingly.

Partitioning The Block Device

Here we assume your block device is /dev/sdb, adjust as needed.

Create a new partition table:

# parted -s /dev/sdb mklabel gpt

Create the partitions for loader and u-boot:

# parted -s /dev/sdb unit s mkpart loader 64 8MiB
# parted -s /dev/sdb unit s mkpart uboot 8MiB 16MiB

Create the partition for u-boot's environment:

# parted -s /dev/sdb unit s mkpart env 16MiB 32MiB

Create the "efi" boot partition and mark it as bootable:

# parted -s /dev/sdb unit s mkpart efi fat32 32MiB 544MiB
# parted -s /dev/sdb set 4 boot on

Create the root partition:

# parted -s /dev/sdb unit s mkpart root ext4 544MiB 100%

Creating The File Systems

Now create the file systems for boot and root:

# mkfs.vfat -n "efi" /dev/sdb4
# mkfs.ext4 -L "rootfs" /dev/sdb5

Fetching and Flashing U-Boot

For this we'll use the precompiled idblock and u-boot from pgwipeout's CI.

Go to https://gitlab.com/pgwipeout/quartz64_ci/-/pipelines and click the three dots, download the merge-job artifacts.

Unzip them:

$ unzip artifacts.zip

Flash idblock.bin and uboot.img:

# dd if=artifacts/idblock.bin of=/dev/sdb1
# dd if=artifacts/uboot.img of=/dev/sdb2

Fetching The Root File System Tarball

Fetch the root filesystem tarball and the PGP signature

$ wget -N http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz{,.sig}

Fetch the gpg keys:

$ curl 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x68b3537f39a313b3e574d06777193f152bdbe6a6' | gpg --import=-

Compare the key ID provided in the above command with the one listed here: https://archlinuxarm.org/about/package-signing (Take good note of the domain and HTTPS)

Verify the tarball's authenticity

$ gpg --verify ArchLinuxARM-aarch64-latest.tar.gz.sig
Do not skip verifying the authenticity. This is important. It also protects you from prematurely aborted transfers giving you a corrupt archive.

Installing The Root File System

# mount /dev/sdb5 /mnt/alarm-root
# mkdir /mnt/alarm-root/boot
# mount /dev/sdb4 /mnt/alarm-root/boot
# bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/alarm-root

Editing fstab

Find your partition UUIDs for both partitions using lsblk:

$ lsblk -o NAME,SIZE,MOUNTPOINTS,PARTUUID

In /mnt/alarm-root/etc/fstab, put the lines

PARTUUID=root-uuid-here  /       ext4    defaults        0       0
PARTUUID=boot-uuid-here  /boot   vfat    defaults        0       1

with your UUIDs in place of the placeholder.

Writing extlinux.conf

Create a /mnt/alarm-root/boot/extlinux/extlinux.conf with these contents:

default l0
menu title Quartz64 Boot Menu
prompt 0
timeout 50

label l0
menu label Boot Arch Kernel SDMMC
linux /Image
fdt /dtbs/rockchip/rk3566-quartz64-a.dtb
append initrd=/initramfs-linux.img earlycon=uart8250,mmio32,0xfe660000 console=ttyS2,1500000n8 root=/dev/mmcblk0p5 rw rootwait

For eMMC instead of SD, replace /dev/mmcblk0p5 with /dev/mmcblk1p5.

For a different type of Quartz64 device (e.g. Model B) replace the fdt line with the appropriate /boot-relative path to the device tree.

Finishing Touches

Here's where you'd do the part I said was iffy and won't be necessary with 5.16 anymore. You'll need an Arch Linux or Manjaro system. If it's not an aarch64 system, you'll also need qemu-user-static. First, get the linux-aarch64-rc package I patched and built, then copy it somewhere into your mounted root.

Next, arch-chroot into the mounted root:

# arch-chroot /mnt/alarm-root

and install the package

# pacman -U linux-aarch64-rc-5.16.rc4-1-aarch64.pkg.tar.zst

Then exit the chroot again once it's done installing.

Once done, unmount the partitions:

# umount /mnt/alarm-root/boot
# umount /mnt/alarm-root

Booting And Finishing Setup

Hook up your UART dongle to your Quartz64, open a serial terminal at 1.5mbauds. Install the SD card or eMMC module inside the Quartz64, and plug in the power.

Once you hit a login shell, log in as root with password root and run:

# pacman-key --init
# pacman-key --populate archlinuxarm

You are now ready to use Arch Linux ARM! Either delete or rename (and move the homedir of) the alarm user, and you're all set. Don't forget to install things like sudo and setting up sudo groups and such.