Difference between revisions of "PinePhone Pro/Create a multi-distribution image using rk2aw"

From PINE64
Jump to navigation Jump to search
 
(344 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= Rk2Aw BootLoader & Multi-Distro on PinePhonePro =
This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.
''References: https://xff.cz/kernels/rk2aw/rk2aw-rk3399-pinephone-pro/INSTALL and https://xnux.eu/rk2aw/''


''Requirements: SSH connection from linux machine to PinePhonePro, internet connection.''
== Multi-distro on microSD Card ==


''Note: Preloader and userspace utility to flash it are non-free.''
This article explains how to install megi's [https://xnux.eu/rk2aw/ rk2aw loader], U-Boot to SPI and a multi-distribution image to the microSD card and/or eMMC of the [[PinePhone Pro]]. Further instructions regarding ''rk2aw'' can be found on megi's website under https://xff.cz/kernels/rk2aw/rk2aw-rk3399-pinephone-pro/INSTALL. Please note that loader and userspace utility to flash it are free, but not open-source.


''Thanks: Megi at https://xnux.eu/log/''


== Flash Rk2Aw BootLoader to SPI ==
=== Flash rk2Aw loader to SPI ===


# ''Connect PinePhonePro to linux machine and start a ssh connection''
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.
# <code>ssh <user>@<phoneip></code> ''# set a connection''
# <code>cd ~/Downloads</code> ''# enter to directory''
# <code>curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz</code> ''# download installer''
# <code>tar -xvzf ppp.tar.gz -C ~/Downloads</code> ''# extract''
# <code># scp -r ~/Downloads/ppp <user>@<phoneip>:~/Downloads</code> ''# copy to phone, non needed''
# <code>sudo ./spinor-flash-initial-setup.sh</code> ''# flash SPI''


== Flash Multi-Distro SD Card ==
ssh <user>@<phoneip>
cd ~/Downloads
curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz
tar -xvzf ppp.tar.gz -C ~/Downloads
# scp -r ~/Downloads/ppp <user>@<phoneip>:~/Downloads'' # copy to phone, non needed''
cd ppp
sudo ./spinor-flash-initial-setup.sh


# ''Get distro compressed images and decompress them. (i.e. Manjaro.phosh.beta34, Mobian.6.1, ArchLinux)''
=== Build multi-distro on the microSD card ===
# ''Mount distro images both partitions "/boot", "/root" for each distro''
 
# <code>lsblk</code> ''# find /loop, /sd references. Use <code>blkid</code> to see the UUID for the partition''
If necessary wipe the microSD card
#: ├─loop0p1 /media/xxx/BOOT_MNJRO
 
#: └─loop0p2 /media/xxx/ROOT_MNJRO
  sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''
#: ├─loop1p1 /media/xxx/boot
sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''
#: └─loop1p2 /media/xxx/rootfs
sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''
#: ├─loop2p1    /media/xxx/52CA-6165  
sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb
#: └─loop2p2 /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441
 
#: └─sdb disk '' (after each dd command you'll see the partition id name to adjust into scripts.)''
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition "cleared". Than remove all partitions with gParted.
# <code>sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress</code> ''# quick erase sd card. i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''
 
# or <code>sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress</code> ''# slow erase sd card. i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta) )''
sudo wipefs /dev/sdb # shows current signatures
# ''Partition sd card (min <del>64</del>32GB)''
sudo wipefs --all --force /dev/sdb # erase current signatures
  sudo sfdisk /dev/sdb <<EOF
 
label: gpt
 
first-lba: 64
==== Partition the microSD card ====
table-length: 8
 
start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name="loader", attrs=RequiredPartition
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}
size=10G, name="ALARM", attrs="RequiredPartition,LegacyBIOSBootable"
 
size=10G, name="MANJARO", attrs="RequiredPartition,LegacyBIOSBootable"
  sudo sfdisk /dev/sdb --wipe always <<EOF
size=+, name="MOBIAN", attrs="RequiredPartition,LegacyBIOSBootable"
  label: gpt
  first-lba: 64
  table-length: 8
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name="loader", attrs=RequiredPartition
  size=11G, name="ALARM", attrs="RequiredPartition,LegacyBIOSBootable"
  size=11G, name="MANJARO", attrs="RequiredPartition,LegacyBIOSBootable"
  size=11G, name="MOBIAN", attrs="RequiredPartition,LegacyBIOSBootable"
  size=11G, name="PMOS", attrs="RequiredPartition,LegacyBIOSBootable"
  size=11G, name="UT", attrs="RequiredPartition,LegacyBIOSBootable"
  size=+, name="extra", attrs="RequiredPartition,LegacyBIOSBootable"
EOF
 
Checking that no-one is using this disk right now ... OK
Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors
Disk model: SD Card Reader 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79
Old situation:
>>> Script header accepted.
>>> Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).
The maximal number of partitions is 8 (default is 128).
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.
  /dev/sdb8: Done.
New situation:
Disklabel type: gpt
Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C
Device        Start      End  Sectors  Size Type
  /dev/sdb1        64    32767    32704  16M unknown
  /dev/sdb2      32768  23101439 23068672  11G Linux filesystem
  /dev/sdb3  23101440  46170111 23068672  11G Linux filesystem
  /dev/sdb4  46170112  69238783 23068672  11G Linux filesystem
  /dev/sdb5  69238784  92307455 23068672  11G Linux filesystem
  /dev/sdb6  92307456 115376127 23068672  11G Linux filesystem
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
 
 
==== Build Arch Linux partition ====
 
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.
 
cd ~/Downloads/ppp/distros
wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz
xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz && mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img
sudo losetup -P /dev/loop1 archlinux.img
sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd
sudo mount /dev/loop1p1 /mnt/archlinux/boot/ && sudo mount /dev/loop1p2 /mnt/archlinux/root/
 
sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync
sudo mount /dev/sdb2 /mnt/archlinuxsd/
sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot
sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG
sudo mkdir /mnt/archlinuxsd/boot/extlinux && sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux && sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab
 
sudo cat << EOF > /mnt/archlinuxsd/boot/extlinux/extlinux.conf
#/boot/extlinux/extlinux.conf
MENU TITLE Pinephone Pro Boot Menu
LABEL l0
MENU LABEL ALARM
FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
KERNEL /boot/Image.gz
INITRD /boot/initramfs-linux.img
APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF
 
sudo cat << EOF > /mnt/archlinuxsd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=ALARM /        ext4      rw,relatime 0 1
EOF
 
 
==== Build Manjaro partition ====
 
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.
 
cd ~/Downloads/ppp/distros
wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz
xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz && mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img
sudo losetup -P /dev/loop2 manjaro.img
sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd
sudo mount /dev/loop2p1 /mnt/manjaro/boot/ && sudo mount /dev/loop2p2 /mnt/manjaro/root/
 
sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync
sudo mount /dev/sdb3 /mnt/manjarosd/
sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot
sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG
sudo mkdir /mnt/manjarosd/boot/extlinux && sudo chmod a=rwx /mnt/manjarosd/boot/extlinux && sudo chmod a=rwx /mnt/manjarosd/etc/fstab
 
sudo cat << EOF > /mnt/manjarosd/boot/extlinux/extlinux.conf
#/boot/extlinux/extlinux.conf
MENU TITLE Pinephone Pro Boot Menu
LABEL l0
MENU LABEL MANJARO
FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
KERNEL /boot/Image
INITRD /boot/initramfs-linux.img
APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF
 
sudo cat << EOF > /mnt/manjarosd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=MANJARO  /  ext4    defaults    0  1
EOF
 
==== Build Mobian partition ====
 
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.
 
cd ~/Downloads/ppp/distros
wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz
xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz && mv mobian-pinephonepro-phosh-20240107.img mobian.img
sudo losetup -P /dev/loop3 mobian.img
sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd
sudo mount /dev/loop3p1 /mnt/mobian/boot/ && sudo mount /dev/loop3p2 /mnt/mobian/root/
 
sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync
sudo mount /dev/sdb4 /mnt/mobiansd/
sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot
sudo chmod a=rwx /mnt/mobiansd/boot/extlinux && sudo chmod a=rwx /mnt/mobiansd/etc/fstab
 
sudo cat << EOF > /mnt/mobiansd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=MOBIAN / ext4 defaults,x-systemd.growfs 0 1
EOF
 
sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf
  >adjust ## /boot/extlinux/extlinux.conf file
  >MENU LABEL MOBIAN
  >linux /boot/vmlinuz-6.6-rockchip
  >initrd /boot/initrd.img-6.6-rockchip
  >fdtdir /boot/dtb-6.6-rockchip/
  >APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
  ># append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial>
 
Ctrl+X to save, Yes, Enter.
 
==== Build PostmarketOS partition ====
 
For PostMarketOS you can use bootstrap to generate distro image or download image as for the other distros. Make sure you install pmbootstrap before building images
 
git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap
mkdir -p ~/.local/bin
ln -s "$PWD/pmbootstrap/pmbootstrap.py" ~/.local/bin/pmbootstrap
source ~/.profile ''# remember to update your environment''
pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''
''# PATH="$HOME/.local/bin:$PATH" # optional''
 
Create 2GB empty image file, format and mount it.
 
sudo su
dd if=/dev/zero of=postmarketos.img bs=1 count=0 seek=2G status=progress && sync
mkfs.ext4 postmarketos.img
losetup -P /dev/loop0 postmarketos.img
exit
 
Build PMOS image via pmbootstrap
pmbootstrap init ''# follow all the setup directions''
pmbootstrap status
pmbootstrap pull
pmbootstrap install --sdcard=/dev/loop0
pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''
 
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.
 
cd ~/Downloads/ppp/distros
wget https://images.postmarketos.org/bpo/v23.12/pine64-pinephonepro/phosh/20240103-1352/20240103-1352-postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz
xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz && mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img
sudo losetup -P /dev/loop4 postmarketos.img
sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd
sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ && sudo mount /dev/loop4p2 /mnt/postmarketos/root/
 
sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync
sudo mount /dev/sdb5 /mnt/postmarketossd/
sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot
sudo mkdir /mnt/postmarketossd/boot/extlinux && sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux && sudo chmod a=rwx /mnt/postmarketossd/etc/fstab
 
sudo cat << EOF > /mnt/postmarketossd/boot/extlinux/extlinux.conf
#/boot/extlinux/extlinux.conf
default l0
menu title U-Boot menu
prompt 0
timeout 10
label l0
  menu label PMOS
  linux /boot/vmlinuz
  initrd /boot/initramfs-extra
  fdtdir /boot/dtbs-pine64-pinephonepro/
APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF
 
sudo cat << EOF > /mnt/postmarketossd/etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
PARTLABEL=PMOS / ext4 defaults 0 0
EOF
 
==== Build Ubuntu Touch partition ====
 
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.
 
cd ~/Downloads/ppp/distros
wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz
xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz && mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw
sudo losetup -P /dev/loop5 ubuntu.raw
sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd
sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ && sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/
 
sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync
sudo mount /dev/sdb6 /mnt/ubuntutouchsd/
sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot
sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab
# sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux
sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf
 
sudo cat << EOF > /mnt/ubuntutouchsd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=UT / ext4 defaults 0 1
  EOF
  EOF


  <code>lsblk</code> ''# list partitions on sd and mounted distro images''
  sudo nano /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf
  : Device        Start      End  Sectors  Size Type
>adjust ## /boot/extlinux/extlinux.conf file
  /dev/sdb1        64    32767    32704  16M unknown
  >menu label UT
  /dev/sdb2    32768 16809983 16777216    8G Linux filesystem
  >linux /boot/vmlinuz-6.5.0-okpine-ut
  /dev/sdb3 16809984 33587199 16777216    8G Linux filesystem
  >initrd /boot/initrd.img-6.5.0-okpine-ut
  : /dev/sdb4  33587200 60524543 26937344 12.8G Linux filesystem
  >fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/
   
  >#append root=UUID=9f3cfee6-e7ed-4d4a-bfeb-e54ef502cec7 console=ttyS2,115200n8 consoleblank=0 loglevel=7 ro splash plymouth.ignore-serial-consoles vt.global_cursor_default=0
  >APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait


# ''Copy files for Arch Linux ARM''
## <code>sudo dd if=/dev/loop2p2 of=/dev/sdb2 bs=1M status=progress conv=fsync</code> ''# copy rootfs to sd part2''
## <code>sudo mount /dev/sdb2 /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441</code>
## <code>sudo scp -r /media/xxx/52CA-6165/* /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441<del>1</del>/boot</code> ''# copy bootfs to to part2/boot''
## <code>sudo mv /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441<del>1</del>/boot/boot.scr /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441<del>1</del>/boot/boot.scrORIG</code> ''# hide auto-menu item''
## <code>sudo nano /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441<del>1</del>/etc/fstab</code> ''# add PARTLABEL=ALARM and delete UUID=xxx from second line, delete /boot entry''
## <code>sudo mkdir /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441<del>1</del>/boot/extlinux</code> ''# add directory''
## <code>sudo nano /media/xxx/3d99072c-9fd6-4316-8526-9192e192c441<del>1</del>/boot/extlinux/extlinux.conf</code> ''# add file''
  <nowiki>#</nowiki>/boot/extlinux/extlinux.conf
  MENU TITLE Pinephone Pro Boot Menu
  LABEL l0
  MENU LABEL ALarm
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
  KERNEL /boot/Image
  INITRD /boot/initramfs-linux.img
  APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait fbcon=rotate:0 pinephone_keyboard.disable_input


# ''Copy files for ManJaro''
==== Unmount and detach all images ====
## <code>sudo dd if=/dev/loop0p2 of=/dev/sdb3 bs=1M status=progress conv=fsync</code> ''# copy rootfs to sd part3''
 
## <code>sudo mount /dev/sdb3 /media/xxx/ROOT_MNJRO1/</code>
sudo umount /mnt/*/* && sudo umount /mnt/* && sudo umount /media/*/*
## <code>sudo scp -r /media/xxx/BOOT_MNJRO/* /media/xxx/ROOT_MNJRO1/boot</code> ''# copy bootfs to to part3/boot''
sudo rm -r /mnt/*/* && sudo rm -r /mnt/* && sudo sudo rm -r /media/*/*
## <code>sudo nano /media/xxx/ROOT_MNJRO1/etc/fstab</code> ''# change UUID=xxx to PARTLABEL=MANJARO, delete /boot line''
sudo losetup -D
## <code>sudo mv /media/xxx/ROOT_MNJRO1/boot/boot.scr /media/xxx/ROOT_MNJRO1/boot/boot.scrORIG</code> ''# hide auto-menu item''
 
## <code>sudo mkdir /media/xxx/ROOT_MNJRO1/boot/extlinux</code> ''# add directory''
==== Switching On Device ====
## <code>sudo nano /media/xxx/ROOT_MNJRO1/boot/extlinux/extlinux.conf</code> ''#add file''
 
  <nowiki>#</nowiki>/boot/extlinux/extlinux.conf
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]
  MENU TITLE Pinephone Pro Boot Menu
 
  LABEL l0
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:
  MENU LABEL ManJaro
 
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.
  KERNEL /boot/Image
 
  INITRD /boot/initramfs-linux.img
Press shortly power button. Graphical menu appears, than just press onto the image to boot from.
  APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait fbcon=rotate:0 pinephone_keyboard.disable_input
 
# ''Copy files for MObian''
Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images.
## <code>sudo dd if=/dev/loop1p2 of=/dev/sdb4 bs=1M status=progress conv=fsync</code> ''# copy rootfs to sd part4''
''In example:
''
## <code>mount /dev/sdb4 /media/xxx/rootfs1/</code>
''Led blinks once each second and 1st image is selected
;''
## <code>sudo scp -r /media/xxx/boot/* /media/xxx/rootfs1/boot</code> ''# copy bootfs to to part4/boot''
''Led blinks twice each second and 2nd image is seleted
;''
## <code>sudo nano /media/xxx/rootfs1/etc/fstab</code> ''# replace UUID=xxx with PARTLABEL=MOBIAN and delete UUID=xxx from second line. Delete /boot line''
''Led blinks triple each second and 3rd image is selected
.''
## <code>sudo nano /media/xxx/rootfs1/boot/extlinux/extlinux.conf</code> ''# edit path from /bootfs to /part4/boot''
Press shortly to move to next image.

  >linux '''/boot'''/vmlinuz-6.1-rockchip
Press longer to boot the selected image.  
  >initrd '''/boot'''/initrd.img-6.1-rockchip
 
  >fdtdir '''/boot'''/dtb-6.1-rockchip/
In case you hold the power button too long, the device is forced to power off.
  APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait fbcon=rotate:0 pinephone_keyboard.disable_input
 
==== Troubleshooting ====
 
If device doesn't start, connect serial cable (https://pine64.com/product/pinebook-pinephone-pinetab-serial-console/) to headphone jack, switch off microswitch 6 and start a serial console:
 
ls /dev/ttyUSB* # check usb address from linux machine
minicom -b 1500000 -D /dev/ttyUSB0
 
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable
 
 
 
 
== Multi-distro on eMMC ==
 
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]
 
Make sure you boot from the microSD card in your PinePhone Pro as we are going to overwrite the eMMC. Note that below, Arch is booted from the microSD card and the microSD card is listed as the device '''/dev/mmcblk1'''.


== Flash rk2aw BootLoader to SPI & multi-distro eMMC ==
=== Flash rk2Aw loader to SPI ===
Make sure you boot from the SDcard in your PPP as we are going to be building the eMMC. Note that below, arch is booted from the SDcard and the SDcard shows as /dev/mmcblk1


== Flash Rk2Aw BootLoader to SPI ==
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:


Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follows:
  # ./rk2aw-spi-flasher  
  <nowiki>#</nowiki> ./rk2aw-spi-flasher  
  Machine: Pine64 PinePhonePro (pine64,pinephone-pro)
  Machine: Pine64 PinePhonePro (pine64,pinephone-pro)
  SPI NOR Flash:
  SPI NOR Flash:
Line 109: Line 335:
  - Part name: gd25lq128e
  - Part name: gd25lq128e
  - JEDEC ID: 257018
  - JEDEC ID: 257018
  Bootable images currently present in SPI NOR flash:
  Bootable images currently present in SPI NOR flash:
  Idx Header    Off 1      Size 1    Off 2      Size 2    Notes/content
  Idx Header    Off 1      Size 1    Off 2      Size 2    Notes/content
Line 115: Line 342:
  5  131072    133120    67584      200704    124928    0='U-Boot TPL' 1='U-Boot SPL'
  5  131072    133120    67584      200704    124928    0='U-Boot TPL' 1='U-Boot SPL'
  7  524288    526336    147456    673792    124928    0='ddrbin' 1='U-Boot SPL'
  7  524288    526336    147456    673792    124928    0='ddrbin' 1='U-Boot SPL'
  Auto-calculated layout for rk2aw dual bootloader scheme:
  Auto-calculated layout for rk2aw dual bootloader scheme:
  Area                Offset    Size       
  Area                Offset    Size       
Line 126: Line 354:


=== Build multi-distro eMMC ===
=== Build multi-distro eMMC ===
In this example we are going to build 2 partitions on the eMMC, the first with Arch/phosh and the second with Arch/sxmo. We have already downloaded the images from [https://github.com/dreemurrs-embedded/Pine64-Arch/releases Danct12] and decompressed them.


==== Mount the images ====  
In this example we are going to build 2 partitions on the eMMC, the first with Arch/Phosh and the second with Arch/sxmo. We have already downloaded the images from [https://github.com/dreemurrs-embedded/Pine64-Arch/releases Danct12] and decompressed them.
  [me@PPP Downloads]$ sudo su
 
  [sudo] password for me:
==== Mount the images ====
  [root@PPP Downloads]# losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img  
 
  [root@PPP Downloads]# losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img  
  cd ~/Downloads ''# enter to directory''
  [root@PPP Downloads]# ls -l /mnt/
  sudo su ''# login with your psw''
  total 0
  losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img  
[root@PPP Downloads]# mkdir /mnt/phosh
  losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img  
  [root@PPP Downloads]# mkdir /mnt/sxmo
  ls -l /mnt/
  [root@PPP Downloads]# mkdir /mnt/phosh/boot
  mkdir /mnt/phosh
  [root@PPP Downloads]# mkdir /mnt/phosh/root
  mkdir /mnt/sxmo
  [root@PPP Downloads]# mkdir /mnt/sxmo/boot
  mkdir /mnt/phosh/boot
  [root@PPP Downloads]# mkdir /mnt/sxmo/root
  mkdir /mnt/phosh/root
  [root@PPP Downloads]# mkdir /mnt/ephosh     # e for the partition on the eMMC
  mkdir /mnt/sxmo/boot
  [root@PPP Downloads]# mkdir /mnt/esxmo     # e for the partition on the eMMC
  mkdir /mnt/sxmo/root
  [root@PPP Downloads]# mount /dev/loop0p1 /mnt/phosh/boot/
  mkdir /mnt/ephosh'' # e for the partition on the eMMC''
  [root@PPP Downloads]# mount /dev/loop0p2 /mnt/phosh/root/
  mkdir /mnt/esxmo''  # e for the partition on the eMMC''
  [root@PPP Downloads]# mount /dev/loop1p1 /mnt/sxmo/boot/
  mount /dev/loop0p1 /mnt/phosh/boot/
  [root@PPP Downloads]# mount /dev/loop1p2 /mnt/sxmo/root/
  mount /dev/loop0p2 /mnt/phosh/root/
  [root@PPP Downloads]# lsblk
  mount /dev/loop1p1 /mnt/sxmo/boot/
  mount /dev/loop1p2 /mnt/sxmo/root/
 
  lsblk
  NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
  NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
  loop0          7:0    0    5G  0 loop  
  loop0          7:0    0    5G  0 loop  
Line 166: Line 396:


==== Prepare eMMC ====
==== Prepare eMMC ====
  [root@PPP Downloads]# dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress # overwrite the front to clear any bootloaders
 
985759744 bytes (986 MB, 940 MiB) copied, 3 s, 329 MB/s
  dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''
32768+0 records in
 
  32768+0 records out
  sfdisk /dev/mmcblk2 << EOF
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 8.14441 s, 132 MB/s
  label: gpt
[root@PPP Downloads]# sfdisk /dev/mmcblk2 << EOF
  first-lba: 64
  > label: gpt
  table-length: 8
  > first-lba: 64
  size=32G, name="PHOSH", attrs="RequiredPartition,LegacyBIOSBootable"
  > table-length: 8
  size=+, name="SXMO", attrs="RequiredPartition,LegacyBIOSBootable"
  > size=32G, name="PHOSH", attrs="RequiredPartition,LegacyBIOSBootable"
  EOF
  > size=+, name="SXMO", attrs="RequiredPartition,LegacyBIOSBootable"
 
  > EOF
  Checking that no-one is using this disk right now ... OK
  Checking that no-one is using this disk right now ... OK
  Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors
  Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors
Line 183: Line 412:
  Sector size (logical/physical): 512 bytes / 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
>>> Script header accepted.
>>> Script header accepted.
  >>> Script header accepted.
  >>> Script header accepted.
  >>> Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).
  >>> Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).
Line 191: Line 418:
  /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.
  /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.
  /dev/mmcblk2p3: Done.
  /dev/mmcblk2p3: Done.
  New situation:
  New situation:
  Disklabel type: gpt
  Disklabel type: gpt
Line 200: Line 428:
  Calling ioctl() to re-read partition table.
  Calling ioctl() to re-read partition table.
  Syncing disks.
  Syncing disks.
[root@PPP Downloads]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0          7:0    0    5G  0 loop
├─loop0p1    259:0    0  122M  0 part /mnt/phosh/boot
└─loop0p2    259:1    0  4.9G  0 part /mnt/phosh/root
loop1          7:1    0  3.5G  0 loop
├─loop1p1    259:2    0  122M  0 part /mnt/sxmo/boot
└─loop1p2    259:3    0  3.4G  0 part /mnt/sxmo/root
mmcblk2      179:0    0 115.2G  0 disk
├─mmcblk2p1  179:1    0    32G  0 part
└─mmcblk2p2  179:2    0  83.2G  0 part
mmcblk2boot0 179:32  0    4M  1 disk
mmcblk2boot1 179:64  0    4M  1 disk
mmcblk1      179:96  0  59.6G  0 disk
├─mmcblk1p1  179:97  0  122M  0 part /boot
└─mmcblk1p2  179:98  0  59.5G  0 part /
zram0        254:0    0  1.5G  0 disk [SWAP]


==== Build phosh partition ====  
lsblk
  NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
  loop0          7:0    0    5G  0 loop
  ├─loop0p1    259:0    0  122M  0 part /mnt/phosh/boot
  └─loop0p2    259:1    0  4.9G  0 part /mnt/phosh/root
  loop1          7:1    0  3.5G  0 loop
  ├─loop1p1    259:2    0  122M  0 part /mnt/sxmo/boot
  └─loop1p2    259:3    0  3.4G  0 part /mnt/sxmo/root
  mmcblk2      179:0    0 115.2G  0 disk
  ├─mmcblk2p1  179:1    0    32G  0 part
  └─mmcblk2p2  179:2    0  83.2G  0 part
  mmcblk2boot0 179:32  0    4M  1 disk
  mmcblk2boot1 179:64  0    4M  1 disk
  mmcblk1      179:96  0  59.6G  0 disk
  ├─mmcblk1p1  179:97  0  122M  0 part /boot
  └─mmcblk1p2  179:98  0  59.5G  0 part /
  zram0        254:0    0  1.5G  0 disk [SWAP]
 
==== Build Phosh partition ====


  [root@PPP Downloads]# dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync
  dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync
  5225054208 bytes (5.2 GB, 4.9 GiB) copied, 215 s, 24.3 MB/s5238685696 bytes (5.2 GB, 4.9 GiB) copied, 215.606 s, 24.3 MB/s
  mount /dev/mmcblk2p1 /mnt/ephosh/
4996+0 records in
  scp -r /mnt/phosh/boot/* /mnt/ephosh/boot
4996+0 records out
  mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG
5238685696 bytes (5.2 GB, 4.9 GiB) copied, 218.565 s, 24.0 MB/s
   
[root@PPP Downloads]# mount /dev/mmcblk2p1 /mnt/ephosh/
cat << EOF > /mnt/ephosh/etc/fstab
  [root@PPP Downloads]# scp -r /mnt/phosh/boot/* /mnt/ephosh/boot
  #/boot/extlinux/extlinux.conf
  [root@PPP Downloads]# mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG
  #Static information about the filesystems.
  [root@PPP Downloads]# nano /mnt/ephosh/etc/fstab             # set PARTLABEL for / and comment /boot
  #See fstab(5) for details.
[root@PPP Downloads]# cat /mnt/ephosh/etc/fstab
  #<file system> <dir> <type> <options> <dump> <pass>
# Static information about the filesystems.
  PARTLABEL=PHOSH /   ext4   rw,relatime 0 1
# See fstab(5) for details.
  # UUID=52CA-6165 /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
# <file system> <dir> <type> <options> <dump> <pass>
   
PARTLABEL=PHOSH /         ext4     rw,relatime 0 1
mkdir /mnt/ephosh/boot/extlinux
# UUID=52CA-6165     /boot     vfat      rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
   
  [root@PPP Downloads]# mkdir /mnt/ephosh/boot/extlinux
  cat << EOF > /mnt/ephosh/boot/extlinux/extlinux.conf
  [root@PPP Downloads]# nano /mnt/ephosh/boot/extlinux/extlinux.conf
  #/boot/extlinux/extlinux.conf
  [root@PPP Downloads]# cat /mnt/ephosh/boot/extlinux/extlinux.conf
  MENU TITLE Pinephone Pro Boot Menu
#/boot/extlinux/extlinux.conf
  LABEL l0
MENU TITLE Pinephone Pro Boot Menu
  MENU LABEL phosh
LABEL l0
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
MENU LABEL phosh
  KERNEL /boot/Image
FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
  INITRD /boot/initramfs-linux.img
KERNEL /boot/Image
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
INITRD /boot/initramfs-linux.img
  EOF
APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait fbcon=rotate:0 pinephone_keyboard.disable_input


==== Build sxmo partition ====
==== Build SXMO partition ====


We have unmounted all the phosh devices, so  
We have unmounted all the Phosh devices, so


  [root@PPP Downloads]# lsblk
  lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
  NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0          7:0    0    5G  0 loop  
  loop0          7:0    0    5G  0 loop  
├─loop0p1    259:0    0  122M  0 part  
  ├─loop0p1    259:0    0  122M  0 part  
└─loop0p2    259:1    0  4.9G  0 part  
  └─loop0p2    259:1    0  4.9G  0 part  
loop1          7:1    0  3.5G  0 loop  
  loop1          7:1    0  3.5G  0 loop  
├─loop1p1    259:2    0  122M  0 part /mnt/sxmo/boot
  ├─loop1p1    259:2    0  122M  0 part /mnt/sxmo/boot
└─loop1p2    259:3    0  3.4G  0 part /mnt/sxmo/root
  └─loop1p2    259:3    0  3.4G  0 part /mnt/sxmo/root
mmcblk2      179:0    0 115.2G  0 disk  
  mmcblk2      179:0    0 115.2G  0 disk  
├─mmcblk2p1  179:1    0    32G  0 part  
  ├─mmcblk2p1  179:1    0    32G  0 part  
└─mmcblk2p2  179:2    0  83.2G  0 part  
  └─mmcblk2p2  179:2    0  83.2G  0 part  
mmcblk2boot0 179:32  0    4M  1 disk  
  mmcblk2boot0 179:32  0    4M  1 disk  
mmcblk2boot1 179:64  0    4M  1 disk  
  mmcblk2boot1 179:64  0    4M  1 disk  
mmcblk1      179:96  0  59.6G  0 disk  
  mmcblk1      179:96  0  59.6G  0 disk  
├─mmcblk1p1  179:97  0  122M  0 part /boot
  ├─mmcblk1p1  179:97  0  122M  0 part /boot
└─mmcblk1p2  179:98  0  59.5G  0 part /
  └─mmcblk1p2  179:98  0  59.5G  0 part /
zram0        254:0    0  1.5G  0 disk [SWAP]
  zram0        254:0    0  1.5G  0 disk [SWAP]
  [root@PPP Downloads]# dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync
   
  3613392896 bytes (3.6 GB, 3.4 GiB) copied, 153 s, 23.6 MB/s3628072960 bytes (3.6 GB, 3.4 GiB) copied, 153.543 s, 23.6 MB/s
dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync
3460+0 records in
  mount /dev/mmcblk2p2 /mnt/esxmo/
3460+0 records out
  scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot
3628072960 bytes (3.6 GB, 3.4 GiB) copied, 156.292 s, 23.2 MB/s
  mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG
[root@PPP Downloads]# mount /dev/mmcblk2p2 /mnt/esxmo/
   
  [root@PPP Downloads]# scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot
  cat << EOF > /mnt/esxmo/etc/fstab
  [root@PPP Downloads]# mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG
  [root@PPP Downloads]# nano /mnt/esxmo/etc/fstab                  # set PARTLABEL for / and comment /boot
  [root@PPP Downloads]# cat /mnt/esxmo/etc/fstab  
  # Static information about the filesystems.
  # Static information about the filesystems.
  # See fstab(5) for details.
  # See fstab(5) for details.
  # <file system> <dir> <type> <options> <dump> <pass>
  # <file system> <dir> <type> <options> <dump> <pass>
  PARTLABEL=SXMO /         ext4      rw,relatime 0 1
  PARTLABEL=SXMO /     ext4      rw,relatime 0 1
  # UUID=841C-F9DD      /boot    vfat      rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
  # UUID=841C-F9DD      /boot    vfat      rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
  [root@PPP Downloads]# mkdir /mnt/esxmo/boot/extlinux
  EOF
  [root@PPP Downloads]# nano /mnt/esxmo/boot/extlinux/extlinux.conf
  [root@PPP Downloads]# cat /mnt/esxmo/boot/extlinux/extlinux.conf  
mkdir /mnt/esxmo/boot/extlinux
#/boot/extlinux/extlinux.conf
   
MENU TITLE Pinephone Pro Boot Menu
  cat << EOF > /mnt/esxmo/boot/extlinux/extlinux.conf
LABEL l0
  #/boot/extlinux/extlinux.conf
MENU LABEL sxmo
  MENU TITLE Pinephone Pro Boot Menu
FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
  LABEL l0
KERNEL /boot/Image
  MENU LABEL sxmo
INITRD /boot/initramfs-linux.img
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait fbcon=rotate:0 pinephone_keyboard.disable_input
  KERNEL /boot/Image
  INITRD /boot/initramfs-linux.img
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF


=== Follow-up comments ===
== Follow-up comments ==


# On first boot neither phosh nor sxmo resized their partition - sudo resize2fs sorted that.
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.
# The end result is a boot screen as follows:
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.
[[File:P1090461.JPG|200px|thumb|left|Options to boot phosh or sxmo]]
 
[[Category:PinePhone Pro]]

Latest revision as of 02:05, 11 January 2024

This article explains how to create a multi-distribution image on the PinePhone Pro using rk2aw.

Multi-distro on microSD Card

This article explains how to install megi's rk2aw loader, U-Boot to SPI and a multi-distribution image to the microSD card and/or eMMC of the PinePhone Pro. Further instructions regarding rk2aw can be found on megi's website under https://xff.cz/kernels/rk2aw/rk2aw-rk3399-pinephone-pro/INSTALL. Please note that loader and userspace utility to flash it are free, but not open-source.


Flash rk2Aw loader to SPI

Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.

ssh <user>@<phoneip>
cd ~/Downloads
curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz
tar -xvzf ppp.tar.gz -C ~/Downloads
# scp -r ~/Downloads/ppp <user>@<phoneip>:~/Downloads # copy to phone, non needed
cd ppp
sudo ./spinor-flash-initial-setup.sh

Build multi-distro on the microSD card

If necessary wipe the microSD card

sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)
sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)
sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress # 63GB SDcard (62550179840bytes/512dim=122168320volte)
sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb

Before removing partitions, if you need to remove also left signatures, use gParted and format each partition "cleared". Than remove all partitions with gParted.

sudo wipefs /dev/sdb # shows current signatures
sudo wipefs --all --force /dev/sdb # erase current signatures


Partition the microSD card

Note: A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.
sudo sfdisk /dev/sdb --wipe always <<EOF
 label: gpt
 first-lba: 64
 table-length: 8
 start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name="loader", attrs=RequiredPartition
 size=11G, name="ALARM", attrs="RequiredPartition,LegacyBIOSBootable"
 size=11G, name="MANJARO", attrs="RequiredPartition,LegacyBIOSBootable"
 size=11G, name="MOBIAN", attrs="RequiredPartition,LegacyBIOSBootable"
 size=11G, name="PMOS", attrs="RequiredPartition,LegacyBIOSBootable"
 size=11G, name="UT", attrs="RequiredPartition,LegacyBIOSBootable"
 size=+, name="extra", attrs="RequiredPartition,LegacyBIOSBootable"
EOF
Checking that no-one is using this disk right now ... OK
Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors
Disk model: SD Card Reader  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79
Old situation:
>>> Script header accepted.
>>> Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).
The maximal number of partitions is 8 (default is 128).
 /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.
 /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.
 /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.
 /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.
 /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.
 /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.
 /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.
 /dev/sdb8: Done.
New situation:
Disklabel type: gpt
Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C
Device         Start       End  Sectors  Size Type
 /dev/sdb1         64     32767    32704   16M unknown
 /dev/sdb2      32768  23101439 23068672   11G Linux filesystem
 /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem
 /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem
 /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem
 /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem
 /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


Build Arch Linux partition

Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.

cd ~/Downloads/ppp/distros
wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz
xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz && mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img
sudo losetup -P /dev/loop1 archlinux.img
sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd
sudo mount /dev/loop1p1 /mnt/archlinux/boot/ && sudo mount /dev/loop1p2 /mnt/archlinux/root/
sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync
sudo mount /dev/sdb2 /mnt/archlinuxsd/
sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot
sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG
sudo mkdir /mnt/archlinuxsd/boot/extlinux && sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux && sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab
sudo cat << EOF > /mnt/archlinuxsd/boot/extlinux/extlinux.conf
#/boot/extlinux/extlinux.conf
MENU TITLE Pinephone Pro Boot Menu
LABEL l0
MENU LABEL ALARM
FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
KERNEL /boot/Image.gz
INITRD /boot/initramfs-linux.img
APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF
sudo cat << EOF > /mnt/archlinuxsd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1
EOF


Build Manjaro partition

Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.

cd ~/Downloads/ppp/distros
wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz
xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz && mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img
sudo losetup -P /dev/loop2 manjaro.img
sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd
sudo mount /dev/loop2p1 /mnt/manjaro/boot/ && sudo mount /dev/loop2p2 /mnt/manjaro/root/
sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync
sudo mount /dev/sdb3 /mnt/manjarosd/
sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot
sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG
sudo mkdir /mnt/manjarosd/boot/extlinux && sudo chmod a=rwx /mnt/manjarosd/boot/extlinux && sudo chmod a=rwx /mnt/manjarosd/etc/fstab
sudo cat << EOF > /mnt/manjarosd/boot/extlinux/extlinux.conf
#/boot/extlinux/extlinux.conf
MENU TITLE Pinephone Pro Boot Menu
LABEL l0
MENU LABEL MANJARO
FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
KERNEL /boot/Image
INITRD /boot/initramfs-linux.img
APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF
sudo cat << EOF > /mnt/manjarosd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=MANJARO   /   ext4     defaults    0   1
EOF

Build Mobian partition

Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.

cd ~/Downloads/ppp/distros
wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz
xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz && mv mobian-pinephonepro-phosh-20240107.img mobian.img
sudo losetup -P /dev/loop3 mobian.img
sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd
sudo mount /dev/loop3p1 /mnt/mobian/boot/ && sudo mount /dev/loop3p2 /mnt/mobian/root/
sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync
sudo mount /dev/sdb4 /mnt/mobiansd/
sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot
sudo chmod a=rwx /mnt/mobiansd/boot/extlinux && sudo chmod a=rwx /mnt/mobiansd/etc/fstab
sudo cat << EOF > /mnt/mobiansd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1
EOF
sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf
 >adjust ## /boot/extlinux/extlinux.conf file
 >MENU LABEL MOBIAN
 >linux /boot/vmlinuz-6.6-rockchip
 >initrd /boot/initrd.img-6.6-rockchip
 >fdtdir /boot/dtb-6.6-rockchip/
 >APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
 ># append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial>

Ctrl+X to save, Yes, Enter.

Build PostmarketOS partition

For PostMarketOS you can use bootstrap to generate distro image or download image as for the other distros. Make sure you install pmbootstrap before building images

git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap
mkdir -p ~/.local/bin
ln -s "$PWD/pmbootstrap/pmbootstrap.py" ~/.local/bin/pmbootstrap
source ~/.profile # remember to update your environment
pmbootstrap --version # If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).
# PATH="$HOME/.local/bin:$PATH" # optional

Create 2GB empty image file, format and mount it.

sudo su
dd if=/dev/zero of=postmarketos.img bs=1 count=0 seek=2G status=progress && sync
mkfs.ext4 postmarketos.img
losetup -P /dev/loop0 postmarketos.img
exit

Build PMOS image via pmbootstrap

pmbootstrap init # follow all the setup directions
pmbootstrap status
pmbootstrap pull
pmbootstrap install --sdcard=/dev/loop0
pmbootstrap shutdown # remember to deactivare chroot after the image creation

Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.

cd ~/Downloads/ppp/distros
wget https://images.postmarketos.org/bpo/v23.12/pine64-pinephonepro/phosh/20240103-1352/20240103-1352-postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz
xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz && mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img
sudo losetup -P /dev/loop4 postmarketos.img
sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd
sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ && sudo mount /dev/loop4p2 /mnt/postmarketos/root/
sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync
sudo mount /dev/sdb5 /mnt/postmarketossd/
sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot
sudo mkdir /mnt/postmarketossd/boot/extlinux && sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux && sudo chmod a=rwx /mnt/postmarketossd/etc/fstab
sudo cat << EOF > /mnt/postmarketossd/boot/extlinux/extlinux.conf
#/boot/extlinux/extlinux.conf
default l0
menu title U-Boot menu
prompt 0
timeout 10
label l0
 menu label PMOS
 linux /boot/vmlinuz
 initrd /boot/initramfs-extra
 fdtdir /boot/dtbs-pine64-pinephonepro/
APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF
sudo cat << EOF > /mnt/postmarketossd/etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
PARTLABEL=PMOS / ext4 defaults 0 0
EOF

Build Ubuntu Touch partition

Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.

cd ~/Downloads/ppp/distros
wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz
xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz && mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw
sudo losetup -P /dev/loop5 ubuntu.raw
sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd
sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ && sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/
sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync
sudo mount /dev/sdb6 /mnt/ubuntutouchsd/
sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot
sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab
# sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux
sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf
sudo cat << EOF > /mnt/ubuntutouchsd/etc/fstab
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=UT	/	ext4	defaults	0	1
EOF
sudo nano /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf
>adjust ## /boot/extlinux/extlinux.conf file
>menu label UT
>linux /boot/vmlinuz-6.5.0-okpine-ut
>initrd /boot/initrd.img-6.5.0-okpine-ut
>fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/

>#append root=UUID=9f3cfee6-e7ed-4d4a-bfeb-e54ef502cec7 console=ttyS2,115200n8 consoleblank=0 loglevel=7 ro splash plymouth.ignore-serial-consoles vt.global_cursor_default=0
>APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait


Unmount and detach all images

sudo umount /mnt/*/* && sudo umount /mnt/* && sudo umount /media/*/*
sudo rm -r /mnt/*/* && sudo rm -r /mnt/* && sudo sudo rm -r /media/*/*
sudo losetup -D

Switching On Device

Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch

According to rk2aw loader info, to operate your PinePhonePro you can:

Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.
Press shortly power button. Graphical menu appears, than just press onto the image to boot from.
Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images.

In example:

Led blinks once each second and 1st image is selected
;
Led blinks twice each second and 2nd image is seleted
;
Led blinks triple each second and 3rd image is selected
.
Press shortly to move to next image.

Press longer to boot the selected image. 

In case you hold the power button too long, the device is forced to power off.

Troubleshooting

If device doesn't start, connect serial cable (https://pine64.com/product/pinebook-pinephone-pinetab-serial-console/) to headphone jack, switch off microswitch 6 and start a serial console:

ls /dev/ttyUSB* # check usb address from linux machine
minicom -b 1500000 -D /dev/ttyUSB0

More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable



Multi-distro on eMMC

Options to boot Phosh or sxmo

Make sure you boot from the microSD card in your PinePhone Pro as we are going to overwrite the eMMC. Note that below, Arch is booted from the microSD card and the microSD card is listed as the device /dev/mmcblk1.

Flash rk2Aw loader to SPI

Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:

# ./rk2aw-spi-flasher 
Machine: Pine64 PinePhonePro (pine64,pinephone-pro)
SPI NOR Flash:
- Total size: 16384 KiB
- Erase block size: 4 KiB
- Write size: 1
- Manufacturer: gigadevice
- Part name: gd25lq128e
- JEDEC ID: 257018
Bootable images currently present in SPI NOR flash:
Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content
-------------------------------------------------------------------------------
0   0          2048       6144       0          0          (padded) 0='rk2aw'
5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'
7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'
Auto-calculated layout for rk2aw dual bootloader scheme:
Area                 Offset     Size      
---------------------------------------------------
rk2aw primary        0          65536     
rk2aw backup         65536      65536     
spl fallback         131072     393216    
spl primary          524288     389120    
itb fallback         913408     2097152   
itb primary          3010560    2097152

Build multi-distro eMMC

In this example we are going to build 2 partitions on the eMMC, the first with Arch/Phosh and the second with Arch/sxmo. We have already downloaded the images from Danct12 and decompressed them.

Mount the images

cd ~/Downloads # enter to directory
sudo su # login with your psw
losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img 
losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img 
ls -l /mnt/
mkdir /mnt/phosh
mkdir /mnt/sxmo
mkdir /mnt/phosh/boot
mkdir /mnt/phosh/root
mkdir /mnt/sxmo/boot
mkdir /mnt/sxmo/root
mkdir /mnt/ephosh # e for the partition on the eMMC
mkdir /mnt/esxmo  # e for the partition on the eMMC
mount /dev/loop0p1 /mnt/phosh/boot/
mount /dev/loop0p2 /mnt/phosh/root/
mount /dev/loop1p1 /mnt/sxmo/boot/
mount /dev/loop1p2 /mnt/sxmo/root/
lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0          7:0    0     5G  0 loop 
├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot
└─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root
loop1          7:1    0   3.5G  0 loop 
├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot
└─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root
mmcblk2      179:0    0 115.2G  0 disk 
├─mmcblk2p1  179:1    0   122M  0 part 
└─mmcblk2p2  179:2    0 115.1G  0 part 
mmcblk2boot0 179:32   0     4M  1 disk 
mmcblk2boot1 179:64   0     4M  1 disk 
mmcblk1      179:96   0  59.6G  0 disk 
├─mmcblk1p1  179:97   0   122M  0 part /boot
└─mmcblk1p2  179:98   0  59.5G  0 part /
zram0        254:0    0   1.5G  0 disk [SWAP]

Prepare eMMC

dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress # overwrite the front to clear any bootloaders
sfdisk /dev/mmcblk2 << EOF
label: gpt
first-lba: 64
table-length: 8
size=32G, name="PHOSH", attrs="RequiredPartition,LegacyBIOSBootable"
size=+, name="SXMO", attrs="RequiredPartition,LegacyBIOSBootable"
EOF
Checking that no-one is using this disk right now ... OK
Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
>>> Script header accepted.
>>> Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).
The maximal number of partitions is 8 (default is 128).
/dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.
/dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.
/dev/mmcblk2p3: Done.
New situation:
Disklabel type: gpt
Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461
Device            Start       End   Sectors  Size Type
/dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem
/dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
lsblk
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
 loop0          7:0    0     5G  0 loop 
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root
 loop1          7:1    0   3.5G  0 loop 
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root
 mmcblk2      179:0    0 115.2G  0 disk 
 ├─mmcblk2p1  179:1    0    32G  0 part 
 └─mmcblk2p2  179:2    0  83.2G  0 part 
 mmcblk2boot0 179:32   0     4M  1 disk 
 mmcblk2boot1 179:64   0     4M  1 disk 
 mmcblk1      179:96   0  59.6G  0 disk 
 ├─mmcblk1p1  179:97   0   122M  0 part /boot
 └─mmcblk1p2  179:98   0  59.5G  0 part /
 zram0        254:0    0   1.5G  0 disk [SWAP]

Build Phosh partition

dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync
mount /dev/mmcblk2p1 /mnt/ephosh/
scp -r /mnt/phosh/boot/* /mnt/ephosh/boot
mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG

cat << EOF > /mnt/ephosh/etc/fstab
 #/boot/extlinux/extlinux.conf
 #Static information about the filesystems.
 #See fstab(5) for details.
 #<file system> <dir> <type> <options> <dump> <pass>
 PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1
 # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

mkdir /mnt/ephosh/boot/extlinux

cat << EOF > /mnt/ephosh/boot/extlinux/extlinux.conf
 #/boot/extlinux/extlinux.conf
 MENU TITLE Pinephone Pro Boot Menu
 LABEL l0
 MENU LABEL phosh
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
 KERNEL /boot/Image
 INITRD /boot/initramfs-linux.img
 APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
 EOF

Build SXMO partition

We have unmounted all the Phosh devices, so

lsblk
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
 loop0          7:0    0     5G  0 loop 
 ├─loop0p1    259:0    0   122M  0 part 
 └─loop0p2    259:1    0   4.9G  0 part 
 loop1          7:1    0   3.5G  0 loop 
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root
 mmcblk2      179:0    0 115.2G  0 disk 
 ├─mmcblk2p1  179:1    0    32G  0 part 
 └─mmcblk2p2  179:2    0  83.2G  0 part 
 mmcblk2boot0 179:32   0     4M  1 disk 
 mmcblk2boot1 179:64   0     4M  1 disk 
 mmcblk1      179:96   0  59.6G  0 disk 
 ├─mmcblk1p1  179:97   0   122M  0 part /boot
 └─mmcblk1p2  179:98   0  59.5G  0 part /
 zram0        254:0    0   1.5G  0 disk [SWAP]

dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync
mount /dev/mmcblk2p2 /mnt/esxmo/
scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot
mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG

cat << EOF > /mnt/esxmo/etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.
# <file system> <dir> <type> <options> <dump> <pass>
PARTLABEL=SXMO /     ext4      	rw,relatime	0 1
# UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2
EOF

mkdir /mnt/esxmo/boot/extlinux

cat << EOF > /mnt/esxmo/boot/extlinux/extlinux.conf
 #/boot/extlinux/extlinux.conf
 MENU TITLE Pinephone Pro Boot Menu
 LABEL l0
 MENU LABEL sxmo
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb
 KERNEL /boot/Image
 INITRD /boot/initramfs-linux.img
 APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait
EOF

Follow-up comments

  1. On first boot neither Phosh nor sxmo resized their partition - sudo resize2fs sorted that.
  2. Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.
  3. In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.