====== Linux Mobile ======

\\
===== PinePhone Pro =====

The PinePhone Pro is PINE64’s flagship smartphone announced on October 15, 2021. It features 4GB of RAM, an 128GB eMMC and is using an Rockchip RK3399S SoC, which is a specialized version of the RK3399 made specifically for the PinePhone Pro.

The guides (Arch Linux ARM & postmarketOS) are based on creating your own image on Arch Linux.

\\
==== Tow-Boot ====

This is required for the following operating systems. Tow-Boot is already installed by default on newer PPPs. 

Download the latest release for your PPP - https://github.com/Tow-Boot/Tow-Boot/releases.

Extract it and flash ''spi.installer.img'' onto a SD card:

<code>
dd if=spi.installer.img of=/dev/XXX bs=1M oflag=direct,sync status=progress
</code>

Insert the SD card into your PPP and __**press**__ and //__hold__// the //__volume down__// button. Now //__press__// the //__power button__// until the __//first vibration occurs//__, then release the //__power button__// but continue to //__hold__// the //__volume down__// until the __second vibration occurs__.\\
You should now see a //__blue LED__// and the Tow-Boot start screen should appear.\\
''Install Tow-Boot to SPI Flash''.

When everything is done, switch off your device and remove the SD card.

\\
==== Arch Linux ARM ====

danctnix - https://github.com/dreemurrs-embedded/Pine64-Arch.

<alert type="danger" icon="fa fa-warning">Encryption (fde) is not possible. Let's hope this will change in the future.</alert>

\\
=== Packages ===

<code>
pacman -S dosfstools arch-install-scripts qemu-user-static qemu-user-static-binfmt
</code>

<code>
systemctl restart systemd-binfmt.service
</code>

Check that the ARM architecture exist (aarch64)
<code>
ls /proc/sys/fs/binfmt_misc | grep aarch64
</code>

\\
=== Build image ===

<code>
git clone https://github.com/dreemurrs-embedded/arch-pine64-build.git
cd arch-pine64-build
mkdir /tmp/ppp-cache
</code>

<code>
./build.sh -a aarch64 -d pinephone-pro -u plasma -h pinephonepro --noconfirm --cachedir /tmp/ppp-cache
</code>

''%%[-a ARCHITECTURE] [-d device] [-u ui] [-h hostname] [--osk-sdl] [--noconfirm] [--cachedir directory] [--no-cachedir]%%''

''-u ui'':
  * barebone
  * phosh
  * plasma
  * plasma_desktop
  * sxmo

\\
=== Flash the image ===

Switch to //USB mass storage// - __//press//__ and //__hold__// the //__volume up__// button and //__press__// the //__power button__// once. You should now see a //__blue LED__//. Connect the device to your PC via USB.

<code>
cd arch-pine64-build/build/
dd if=archlinux-pinephone-pro-plasma-*.img of=/dev/XXX bs=1M oflag=direct,sync status=progress
</code>

Start the device and follow e.g. our backup guides https://wiki.techsaviours.org/en/backup/server. 

\\
=== Local Arch repo (optional) ===

Create your own Arch repository to keep older packages in case you need to downgrade your system/phone. It can be more difficult to downgrade than with the x86_64 architecture.\\
https://git.techsaviours.org/.ORG/local-arch-repo

\\
==== postmarketOS ====

\\
=== Package ===

<code>
pacman -S pmbootstrap
</code>

\\
=== Initialization ===

<code>
mkdir -p ~/build/postmarketOS
pmbootstrap init
</code>

Simply follow the questions. Some necessary steps are listed below to use your PPP, the rest is up to you.

<code>
Work path [/home/USER/.local/var/pmbootstrap]: ~/build/postmarketOS
Vendor [qemu]: pine64
Device codename: pinephonepro
</code>

\\
=== Install ===

Switch to //USB mass storage// - __//press//__ and //__hold__// the //__volume up__// button and //__press__// the //__power button__// once. You should now see a //__blue LED__//. Connect the device to your PC via USB.

<code>
pmbootstrap install --sdcard=/dev/XXX --fde
</code>

''%%--fde%%'' is to encrypt your phone.

<alert type="info" icon="fa fa-info-circle">Run ''pmbootstrap log'' in another terminal to see what is going on.</alert>

<alert type="danger" icon="fa fa-warning">If direct to eMMC (//USB mass storage//) does not work, create just the image ''%%pmbootstrap install --fde%%'' and flash it to your internal storage with ''%%dd if=~/build/postmarketOS/chroot_native/home/pmos/rootfs/pine64-pinephonepro.img of=/dev/XXX bs=1M oflag=direct,sync status=progress%%''.</alert>

Once everything is done "umount, unregister binfmt":
<code>
pmbootstrap shutdown
</code>