PINE64 PinePhone

From Gentoo Wiki
(Redirected from PinePhone)
Jump to:navigation Jump to:search
This article has been flagged for not conforming to the wiki guidelines (Use of 2nd person pronouns). Please help Gentoo out by starting fixing things.

The Pinephone is 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, The user should not expect to run desktop programs normally. Consider using less computer-intensive and keyboard-dependent alternatives to common programs.

Initial chroot and disk setup

Note
The disk setup depends a lot on the bootloader choice. if you use p-boot, you need a MBR partition table, and /boot stays on the / filesystem.

Option 1: Using another operating system as installation medium

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 the user can ssh into, then using that to partition the flash, unpack stage3, and chroot, etc. 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).

Option 2: cross-compilation from another Gentoo system

Note
TODO: write and test something similar to 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).

Note
TODO: see if you can mount the filesystem directly with jumpdrive and not just flash ISOs.

Compiling the kernel

The new mainline kernels include the sun50i-a64-pinephone-1.X.dtb file (where 1.X is the hardware version), which you need for your bootloader. As of December 2020, the latest stable gentoo-sources doesn't have it yet so you will have to add "sys-kernel/gentoo-sources ~arm64" to /etc/portage/package.accept_keywords to get a kernel that supports it.

root #emerge gentoo-sources
root #cd /usr/src/linux
root #make menuconfig # (or some pinephone_defconfig)
root #make -j4
root #make modules_install
root #make install
root #make dtbs
root #make dtbs_install
Note
TODO: test kernel configurations, write defconfig and config guide

Installing the bootloader

Option 1: p-boot

p-boot is a bootloader designed specifically for the pinephone[1]. 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[2].

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

Building from source

To compile p-boot, you need the ninja build system. You also need a second compiler (arm-none-eabi-gcc), which you can get with crossdev as so:

root #emerge -av git ninja crossdev
root #crossdev --target arm-none-eabi
root #cd p-boot/build
root #ninja

then you have to build the firmware, which requires aarch64-linux-musl-gcc and or1k-linux-musl-gcc compilers.

root #crossdev --target aarch64-linux-musl
root #crossdev --target or1k-linux-musl
root #cd ../fw
Important
In the case of default gold linker with lto, you should disable them for cross-or1k-linux-musl/musl in your portage environment before running crossdev for the or1k-linux-musl target.

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.

Note
TODO: figure this out and get back to you.

Installing the user interface

Note
TODO: make a separate page for (each?) mobile WM?

Option 1: sway with custom configuration

Sway is a wayland compositor. Unlike window managers such as i3, the user can use the mouse, therefore it would work well on a touchscreen. The user could increase the border size to make windows easier to drag and use window scaling to make things larger. The user just needs to replace dmenu with a touchscreen alternative, make an on-screen keyboard for wayland, could set those to the volume buttons respectively and then set swaylock to the power button. You would just need a way to drag windows between virtual workspaces with the touchscreen. This is slowed down by the phone's processor and the lack of touchscreen controls. it takes too long to scroll with the volume buttons for a good user experience.

The user can use wf-osk as an on screen keyboard.

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

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

Option 2: Phosh

Phosh can be installed from the official guru repository.

Enable the repository and sync:

root #eselect repository enable guru
root #emerge --sync

Install phosh:

root #emerge phosh-base/phosh-shell
Note
The user might want to also install a login manager which is capable of functioning under a touchscreen environment

Option 3: KDE mobile

Plasma mobile is available in the KDE ebuild repository.

Wifi/Bluetooth

uses RTL8723BS/RTL8723CS

GPU

the Allwinner A64 has a mali 400 GPU, which is supported by the lima driver[3]. To enable support for lima, add VIDEO_CARDS: -* lima to your /etc/portage/package.use.

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.

FILE /etc/portage/make.confRecommended graphics options
USE="gles2 gles2-only"
FILE /etc/portage/package.use/00video
*/* VIDEO_CARDS: -* lima

you can also adjust the GPU frequency [4]

Modem

The current user needs to be in the plugdev group in order to manipulate texts

See also

  • PINE64 ROCKPro64 — a Rockchip RK3399 (ARMv8-A, Cortex-A72/A53 big.LITTLE) based, exceptionally libre software friendly SBC.

References

  1. U-boot manual
  2. sunxi wiki page on the PinePhone
  3. building the kernel
  4. board support packages
  5. hope
  6. hardware/firmware information
  7. modem information
  8. [1] working image for a similar SBC
  9. someone's pinephone overlay, use at your own discretion
  10. cpu overclocking