PinePhone

the pinephone is Article description::a cheap, generic, arm64 smartphone produced with the goal of supporting user-modifiable operating systems and hardware. It uses an Allwinner "sunxi" A64 processor, a Quectel EG-25G Modem, and can boot from either microSD (removable storage) or eMMC (internal storage). It comes in a couple variants that don't really affect the installation process.

Due to hardware differences, don't expect to run desktop programs normally. Consider using less computer-intensive and keyboard-dependent alternatives to common programs.

Option 1: using another operating system as installation medium
TODO: make an official gentoo minimal install iso for the pinephone? (or arm64 in general, but it would need touchscreen support)

This seems like the easiest option for installing on eMMC, although it takes a long time to compile.

this method works by installing another OS on the pinephone that can be ssh'd into, then using that to partition the flash, unpack stage3, and chroot, etcetera. You can install gentoo on eMMC by installing the other operating system on microSD, but you can also install gentoo on the microSD, by first installing another OS on the eMMC (https://wiki.pine64.org/index.php/PinePhone#Flashing_eMMC_using_Jumpdrive).

I've had problems with mounting and formatting eMMC with postmarketOS (seems it has to do with the way that filesystems are mounted by it's initramfs), but I have tried the unofficial fedora linux port, and it works fine. postmarketOS has a nice ssh-over-USB feature (https://wiki.postmarketos.org/wiki/SSH), which should be considered for any gentoo minimal install iso.

Option 2: cross-compilation from another gentoo system
TODO: write and test something similar to https://wiki.gentoo.org/wiki/Raspberry_Pi_3_64_bit_Install

this is the easiest option for installing on microSD.

the eMMC can be exposed via USB by installing jumpdrive on a microSD (https://wiki.pine64.org/index.php/PinePhone#Flashing_eMMC_using_Jumpdrive). TODO: see if you can mount the filesystem directly with jumpdrive and not just flash ISOs.

Compiling the Kernel
The (newer) mainline kernels include the pinephone device tree binary, which you need:

cd /usr/src/linux

mount /boot

make menuconfig (or some pinephone_defconfig)

make -j4

make modules_install

make install

make dtbs

make dtbs_install

TODO: test kernel configurations, write defconfig or config guide

Option 1: p-boot
p-boot is a bootloader designed specificially for the pinephone. it has a menu that lets you select different kernels at boot time, like grub does. It also allows you to boot into FEL mode.

It seems like p-boot doesn't compile with sys-devel/gcc, because it needs arm-specific options (such as -mthumb). I am trying to use crossdev, and if that doesn't work i'll try this: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm

because this package is hardware-specific should it be distributed as a binary?

TODO: figure this out and get back to you with an ebuild.

Option 2: U-boot
u-boot is a a bootloader for embedded devices. it's supported by the SoC manufacturer, and works on the pine64 which has the same processor.

TODO: figure this out and get back to you.

Installing the user interface
TODO: make a separate page for (each?) mobile WM?

Option 1: sway with custom configuration
TODO: make wayland on-screen keyboard

TODO: make touch-screen alternative to dmenu

You can bindsym to the volume and power buttons with XF86XK_AudioRaiseVolume, XF86XK_AudioLowerVolume, and XF86XK_PowerOff repectively

TODO: include an example ~/.config/sway/config

Option 2: framebuffer terminal with on-screen keyboard
TODO: port this from postmarketOS

Option 3: ubports' WM
TODO: port this from ubports

Option 4: Phosh
TODO: make an overlay with phosh

Option 5: KDE mobile
TODO: make an overlay with kde mobile

Wifi/Bluetooth
uses RTL8723BS/RTL8723CS

GPU
the Allwinner A64 has a mali 400 GPU, which is supported by the lima driver. To enable support for lima, add VIDEO_CARDS="lima" to your /etc/portage/make.conf.

The main way programs can take advantage the GPU on this hardware is through OpenGL. Specifically, it supports OpenGL ES 2, so consider using "gles2" and "gles2-only" alongside your other useflags. Don't enable the "opengl" useflag, as this seems to override the "gles2-only" useflag on packages like media-libs/mesa.