Gentoo Installation on AML-S905X-CC (Le Potato)

Requirements

Steps

  1. flash raspian image from Libre Computer to both microSD cards Download
  2. insert one of the microSD cards you flashed into the Le Potato and boot (follow initial setup as required)
  3. insert the second microSD into usb adapter and insert adapter into usb slot on Le Potato, this is where you will make changes and install Gentoo
  4. delete root partion (second partition)
  5. create a swap partition if desired
  6. create a new root partition
  7. mkfs.btrfs on the new root partition
  8. mount new partition at /mnt/gentoo (mkdir if needed)
  9. mount the existing EFI partition on /mnt/gentoo/boot/efi (mkdir first)
  10. cp -rp the firmware, kernel modules, kernel headers and the rest of /boot from the raspian microSD you are booted on to the one on the adapter to the same path
  11. use lsmod and put list of modules into /etc/modules-load.d/raspian-modules.conf
  12. at this point you can mostly follow the normal gentoo amd64 handbook for setup (use end0 for ethernet device)
  13. make sure you adjust /etc/inittab if you want to use the uart interface
    # Architecture specific features
    f0:12345:respawn:/sbin/agetty 115200 ttyAML0 vt100
  14. when you get to bootloader installation/configuration emerge grub with efi-64 (add following to /etc/portage/make.conf)
    GRUB_PLATFORMS="efi-64"
  15. grub-mkconfig -o /boot/grub/grub.cfg
  16. grub-mkstandalone -O arm64-efi -o /boot/efi/EFI/BOOT/BOOTAA64.EFI “boot/grub/grub.cfg=/boot/grub/grub.cfg”

Custom Kernel

Qemu chroot environment (For compiling packages on amd64 host with more memory/cpu)

/etc/portage/package.make

# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="-O2 -pipe -march=armv8-a+crypto+crc -mabi=lp64 -mtune=cortex-a53"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable before changing.
CHOST="aarch64-unknown-linux-gnu"
MAKEOPTS="-j4"
FEATURES="-pid-sandbox buildpkg"
#FEATURES="-collision-protect sandbox buildpkg noman noinfo nodoc"
PKGDIR=/var/potato/binpkgs/
# NOTE: This stage was built with the bindist Use flag enabled

# This sets the language of build output to English.
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C
USE="-X gpm fbcon alsa -udev"
ACCEPT_LICENSE="-* @FREE @BINARY-REDISTRIBUTABLE"
GRUB_PLATFORMS="efi-64"
PORTDIR_OVERLAY="/var/db/repos/portage_overlay"

potato-chroot.sh

/etc/init.d/qemu-binfmt start

cd /usr/potato
mount -t proc none proc
mount -o bind /dev dev
mount -o bind /var/db/repos/gentoo var/db/repos/gentoo
mount -o bind /sys sys
cp /etc/resolv.conf etc/resolv.conf
echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-aarch64:' > /proc/sys/fs/binfmt_misc/register

chroot . /bin/bash --login

umount sys
umount var/db/repos/gentoo
umount dev
umount proc

Configuring binary package repo over ssh

PORTAGE_BINHOST="ssh://user@pkghost/usr/potato/var/potato/binpkgs"
FEATURES="getbinpkg"

Adding RTC

GPIO Reference