User Tools

Site Tools


libre_computer_board_aml-s905x-cc_le_potato

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

Requirements

  • 2x microSD cards
  • USB microSD card adapter
  • Le Potato board
  • usb to tty cable so you can see whats going on over UART

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

  • Branch: v6.0/libretech-master
  • Start with Config from /boot (from Raspbian image)
  • make menuconfig/make/make install/make modules_install
  • emerge dracut
  • dracut –kver=“6.0.19-419654-g73f2949c2dd9”
  • grub-mkconfig -o /boot/grub/grub.cfg
  • grub-mkstandalone -O arm64-efi -o /boot/efi/EFI/BOOT/BOOTAA64.EFI “/boot/grub/grub.cfg=/boot/grub/grub.cfg”

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

  • emerge –ask app-emulation/qemu
  • QEMU_USER_TARGETS=“aarch64” QEMU_SOFTMMU_TARGETS=“aarch64” USE=“static-user static-libs” emerge –ask –buildpkg –oneshot qemu
  • cd /usr
  • mkdir potato
  • cd potato
  • tar xvf stage3*tar.xz
  • cp -rp kernel firmware headers modules to the new chroot env
  • ROOT=$PWD/ emerge --ask --usepkgonly --oneshot --nodeps qemu
  • make file requires -pid-sandbox in features or qemu bug rears its ugly head
  • mkdir any mount points that dont' exist for the chroot script
  • setup your package.use etc

/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

  • get public key from root user on potato
  • add potato root public key to authorized_keys file of a user with read access on the compile host
  • add feature and pkg host to /etc/portage/make.conf
PORTAGE_BINHOST="ssh://user@pkghost/usr/potato/var/potato/binpkgs"
FEATURES="getbinpkg"

Adding RTC

  • wire your RTC to the GPIO same as a raspberry pi
  • install deps
    emerge --ask dtc libgpiod
  • clone libretech-wiring-tool
    git clone https://github.com/libre-computer-project/libretech-wiring-tool.git
  • compile and install the overlays and commands
    make
    make install
  • create an init script to add the overlays:
    •  vim /etc/init.d/rtc
    • #!/sbin/openrc-run
      # Copyright 2023 Gentoo Authors
      # Distributed under the terms of the GNU General Public License v2
      
      name="i2c rtc overlays"
      description="make rtc "
      
      depend() {
          before hwclock
      }
      
      start() {
          /opt/librecomputer/libretech-wiring-tool/ldto enable i2c-ao
          /opt/librecomputer/libretech-wiring-tool/ldto enable i2c-ao-ds3231
      }
  • set make script executable and add too boot runlevel
    chmod 755 rtc
    rc-update add rtc boot
  • reboot and check dmesg, if it worked you'll see a log like so
    [   11.809520] rtc-ds1307 1-0068: registered as rtc0
    [   11.810886] rtc-ds1307 1-0068: setting system clock to 2023-05-04T11:58:05 UTC (1683201485)
  • you can also check with i2cdetect denoting the UU in 0x68 location
    mobilemouse ~ # i2cdetect -y 1
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:                         -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --

GPIO Reference

libre_computer_board_aml-s905x-cc_le_potato.txt · Last modified: 2024/01/30 13:53 by 127.0.0.1