<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Giorez</id>
	<title>PINE64 - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Giorez"/>
	<link rel="alternate" type="text/html" href="https://wiki.pine64.org/wiki/Special:Contributions/Giorez"/>
	<updated>2026-04-24T13:14:03Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21481</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21481"/>
		<updated>2024-06-23T15:54:25Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 $ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 $ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 $ make menuconfig&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
 $ make&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing ==&lt;br /&gt;
This page explains how to flash an Ox64 board and a microSD card to boot the system. You will need a Linux computer, a serial UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
=== Prepare images for flashing ===&lt;br /&gt;
&lt;br /&gt;
Download the Ox64 images from the latest OpenBouffalo release. You may skip this step if you built your own images as per the instructions in the link:/documentation/Ox64/Software/Building/[Building] page.&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/openbouffalo&lt;br /&gt;
 $ cd ~/ox64/openbouffalo&lt;br /&gt;
 $ wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware&lt;br /&gt;
 $ xz -v -d -k sdcard-pine64_ox64_full_defconfig.img.xz&lt;br /&gt;
 $ mv sdcard-pine64_ox64_full_defconfig.img sdcard.img&lt;br /&gt;
&lt;br /&gt;
==== Optional: create a combined SoC image ====&lt;br /&gt;
&lt;br /&gt;
Use the following commands to combine _m0_lowload_bl808_m0.bin_, _d0_lowload_bl808_d0.bin_, and _bl808-firmware.bin_ into a single image. This is mainly useful for troubleshooting (e. g. when using DevCube v1.8.4 or later).&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ fallocate -l 0x800000 bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=m0_lowload_bl808_m0.bin of=bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=d0_lowload_bl808_d0.bin of=bl808-combined.bin seek=$((0x100000))B&lt;br /&gt;
 $ cat bl808-firmware.bin &amp;gt;&amp;gt; bl808-combined.bin&lt;br /&gt;
&lt;br /&gt;
==== Check that you have the required files for flashing ====&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ ls -1 *808*.bin *.img&lt;br /&gt;
&lt;br /&gt;
Expected files:&lt;br /&gt;
&lt;br /&gt;
* `bl808-combined.bin` -- If you created the combined image.&lt;br /&gt;
* `bl808-firmware.bin` -- OpenSBI and UBoot DTB files. Runs on the D0 core.&lt;br /&gt;
* `d0_lowload_bl808_d0.bin` -- Startup code for the D0 core.&lt;br /&gt;
* `m0_lowload_bl808_m0.bin` -- Startup code for the M0 core.&lt;br /&gt;
* `sdcard.img` -- Kernel and root filesystem. Runs on the D0 core.&lt;br /&gt;
&lt;br /&gt;
=== Set up your UART adapter ===&lt;br /&gt;
&lt;br /&gt;
In this section we will configure and wire up a UART adapter in order to flash the Ox64. Choose one of the options below based on the hardware available to you; the first two are the most convenient since they minimise the number of times you will need to swap electrical connections.&lt;br /&gt;
&lt;br /&gt;
==== Option 1: Raspberry Pi Pico ====&lt;br /&gt;
&lt;br /&gt;
First, download the Raspberry Pi Pico firmware that allows it to act as a serial UART adapter:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/pico&lt;br /&gt;
 $ cd ~/ox64/pico&lt;br /&gt;
 $ wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/raw/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
Put the Raspberry Pi Pico board into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
NOTE: As an alternative to pressing the BootSel button, you can also connect the probe point `TP6` (located on the bottom of the Pico board) to any ground point (e. g. pin 28).&lt;br /&gt;
&lt;br /&gt;
The Pico will now appear as a USB mass storage device. Copy the `UF2` file to program it:&lt;br /&gt;
&lt;br /&gt;
 $ cp ~/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Pico according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | PI PICO | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_pin17&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_pin16&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_pin6&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_pin7&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| gnd_pin38/3&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| &lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Pico flashed and wired as per the instructions above, we have access to two of the Ox64's UART ports at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Reconnect the Pico to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
&lt;br /&gt;
==== Option 2: STM32 Bluepill ====&lt;br /&gt;
&lt;br /&gt;
The Bluepill is an affordable STM32 development board, based on the STM32F103C8T6 chip. We can program it to act as a USB serial adapter, just like we did with the Raspberry Pi Pico.&lt;br /&gt;
&lt;br /&gt;
[NOTE]&lt;br /&gt;
&lt;br /&gt;
The one catch is that you already need a serial adapter in order to program your Bluepill board. The good news is that you serial adapter does **not** have to be one from from the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. These programming instructions have been tested with a FT232RL adapter (which, notably, is listed as _not_ supported on that list).&lt;br /&gt;
&lt;br /&gt;
If you own an SWD-capable debugger (ST-Link, J-link, etc.) you can use that for programming the Bluepill as well, although instead of `stm32flash` console command you would be using https://openocd.org/[openocd] or other suitable software.&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Install software to flash Bluepill. For Debian-based systems just install package from repository:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install stm32flash&lt;br /&gt;
&lt;br /&gt;
For Arch Linux systems, use the AUR repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ git clone https://aur.archlinux.org/stm32flash.git&lt;br /&gt;
 $ cd ~/ox64/bluepill/stm32flash&lt;br /&gt;
 $ makepkg -si&lt;br /&gt;
&lt;br /&gt;
Download the https://github.com/r2axz/bluepill-serial-monster[Bluepill Serial Monster] firmware:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ wget https://github.com/r2axz/bluepill-serial-monster/releases/download/v2.6.4/bluepill-serial-monster.hex&lt;br /&gt;
&lt;br /&gt;
Put the Bluepill into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Set boot jumpers for booting from rom: Boot0=1, Boot1=0.&lt;br /&gt;
* Connect it to a USB-Serial adapter with A9 to Rx, A10 to Tx, GND to GND, 3v3 to Vcc.&lt;br /&gt;
* Apply power by plugging the USB cable to PC. Press the Reset button.&lt;br /&gt;
&lt;br /&gt;
Find your USB serial adapter's device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`. Upload the firmware:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ sudo stm32flash -w bluepill-serial-monster.hex /dev/tty[DEVICE]&lt;br /&gt;
 &lt;br /&gt;
After upload, set boot jumpers for boot from flash: Boot0=0, Boot1=0. Disconnect the USB serial adapter from both the PC and Bluepill board.&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Bluepill according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | Bluepill | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_A3&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_A2&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_A9&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_A10&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| GND&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| 5V&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Bluepill flashed and wired as per the instructions above, we have access to two of the Ox64's UART connections at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Connect the Bluepill to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
* `/dev/ttyACM2` (unused)&lt;br /&gt;
&lt;br /&gt;
==== Option 3: Generic UART adapter ====&lt;br /&gt;
&lt;br /&gt;
image:/documentation/Ox64/images/ox64_pinout.png[Ox64 pinout,title=&amp;quot;Ox64 pinout&amp;quot;, 300, float=&amp;quot;right&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
Check that your serial adapter is on the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. You will (most likely) only have one serial interface available to you; unlike the previous options you will be using this same serial interface for both flashing and testing the system.&lt;br /&gt;
&lt;br /&gt;
Find its device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
You will also need a way of powering your Ox64. If your serial adapter has a 5V line, you can connect it to VBUS (pin 40). Otherwise, you can connect either the micro-B or the USB-C port on the Ox64 to any 5V power supply.&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Refer to the pinout image below. Connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; UART0_TX / GPIO14 / pin 1&lt;br /&gt;
* TX -&amp;gt; UART0_RX / GPIO15 / pin 2&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 3)&lt;br /&gt;
&lt;br /&gt;
Proceed with the instructions in the sections that follow, up to and including &amp;lt;&amp;lt;flashing_the_ox64&amp;gt;&amp;gt; and &amp;lt;&amp;lt;flashing_the_microsd_card&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM1` with `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
Next, power off the Ox64 and re-connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; TXD / GPIO16 / pin 32&lt;br /&gt;
* TX -&amp;gt; RXD / GPIO17 / pin 31&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 33)&lt;br /&gt;
&lt;br /&gt;
Then, follow the instructions in &amp;lt;&amp;lt;booting_for_the_first_time&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM0` with `/dev/tty[DEVICE]`. You should then have a working Linux system.&lt;br /&gt;
&lt;br /&gt;
=== Download flashing tools ===&lt;br /&gt;
&lt;br /&gt;
You have a choice of flashing software:&lt;br /&gt;
&lt;br /&gt;
* DevCube: GUI-based closed source flashing tool&lt;br /&gt;
* CLI (`bflb-iot-tool`): command line open source flashing tool&lt;br /&gt;
&lt;br /&gt;
==== DevCube installation ====&lt;br /&gt;
&lt;br /&gt;
Download the latest DevCube flashing tool from BouffaloLab's website:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/devcube&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ unzip BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
If you did not create a link:#optional_create_a_combined_soc_image[combined image] you may need an older version of the DevCube. In that case, download v1.8.3 from one of the mirrors below:&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192[] &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify that your copy of `BouffaloLabDevCube-v1.8.3.zip` matches the hashes below:&lt;br /&gt;
&lt;br /&gt;
* SHA1: `0f2619e87d946f936f63ae97b0efd674357b1166`&lt;br /&gt;
* SHA256: `e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913`&lt;br /&gt;
&lt;br /&gt;
==== CLI packages installation ====&lt;br /&gt;
&lt;br /&gt;
Install `bflb-iot-tool` using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install pipenv # for Debian-based systems&lt;br /&gt;
  # or&lt;br /&gt;
 $ sudo pacman -S python-pipenv # for Arch Linux systems&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/&lt;br /&gt;
 $ pipenv install setuptools # install prerequisite of CLI flash tool&lt;br /&gt;
 $ pipenv install bflb-iot-tool # install CLI flash tool&lt;br /&gt;
 $ pipenv shell # activate virtual environment&lt;br /&gt;
 $ # bflb-iot-tool --help # return info about the tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: Each time you open a new terminal window you will need to `cd ~/ox64/` and re-run `pipenv shell` to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
=== Flashing the Ox64 ===&lt;br /&gt;
&lt;br /&gt;
Put the Ox64 into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
==== CLI flashing method ====&lt;br /&gt;
&lt;br /&gt;
Set up some environment variables to save typing them out later:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ PORT=/dev/ttyACM1&lt;br /&gt;
 $ BAUD=230400  # safe value for macOS, set to 2000000 for faster flashing on Linux&lt;br /&gt;
&lt;br /&gt;
Finally, flash the Ox64. If you created a link:#optional_create_a_combined_soc_image[combined image] then run the command below:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware bl808-combined.bin --single&lt;br /&gt;
&lt;br /&gt;
Otherwise, run the following commands:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running any of the commands above, run `ls -l /dev/tty[DEVICE]`, to find out which group is allowed to talk to serial ports and add your user to that group, with `sudo usermod -a -G [GROUP] $USER` (i.e. `dialout` for Debian or `uucp` for Arch Linux). Make sure you re-login. Running the commands as `root` is not recommended since this will make `bflb-iot-tool` create root-owned files in your home directory. You can now run `exit` from virtual environment.&lt;br /&gt;
&lt;br /&gt;
==== BLDevCube flashing method ====&lt;br /&gt;
&lt;br /&gt;
Open a new terminal window to run the DevCube flasher:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish, and configure BOTH the [MCU] and [IOT] tabs as follows. When you switch between tabs double check that they still match the settings below:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;~,~&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
|Interface&lt;br /&gt;
|UART&lt;br /&gt;
&lt;br /&gt;
|Port/SN&lt;br /&gt;
|`/dev/ttyACM1`&lt;br /&gt;
&lt;br /&gt;
|UART rate&lt;br /&gt;
|230400 (safe value for macOS, set to 2000000 for faster flashing on Linux)&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
If you created a link:#optional_create_a_combined_soc_image[combined image] then you only need to use the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x0], [PATH to bl808-combined.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
Otherwise, start in the [MCU] tab:&lt;br /&gt;
&lt;br /&gt;
* M0 Group[group0], Image Address [0x58000000], [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
* D0 Group[group0], Image Address [0x58100000], [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Then, switch to the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x800000], [PATH to bl808-firmware.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
=== Erasing the microSD card ===&lt;br /&gt;
&lt;br /&gt;
Make sure there are no signatures or partitions left, and overwrite the first sectors with zeroes. You can find the target device under `lsblk` command.&lt;br /&gt;
&lt;br /&gt;
 $ sudo wipefs /dev/[DEVICE]&lt;br /&gt;
 $ sudo wipefs --all --force /dev/[DEVICE]*&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=1&lt;br /&gt;
&lt;br /&gt;
Optionally you can zeroes the whole device:&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=$(expr $(lsblk -bno SIZE /dev/[DEVICE] | head -1) \/ 32768)&lt;br /&gt;
&lt;br /&gt;
=== Flashing the microSD card ===&lt;br /&gt;
&lt;br /&gt;
Insert the microSD card into your PC, locate its device under `lsblk` and write the image:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=sdcard.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the first time ===&lt;br /&gt;
&lt;br /&gt;
Power off your Ox64 and insert the microSD card.&lt;br /&gt;
&lt;br /&gt;
Open a terminal window to connect to the D0 core’s (i.e. Linux’s) serial console:&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
If you are using a Pico or Bluepill as your serial adapter, open another terminal window to to monitor the M0 core’s serial console (reminder: `/dev/ttyACM1` is the same port we previously used for flashing):&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM1&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64.&lt;br /&gt;
&lt;br /&gt;
On the main/D0 console (`/dev/ttyACM0`) you will see Linux booting up. When prompted, log in as `root` with no password. In case the SD card is missing or empty, you'll get a `Card did not respond to voltage select! : -110` error.&lt;br /&gt;
&lt;br /&gt;
On the M0 console (`/dev/ttyACM1`) you'll see following messages until the sytem is fully loaded:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[I][MBOX] Mailbox IRQ Stats:&lt;br /&gt;
[I][MBOX] Peripheral SDH (33): 0&lt;br /&gt;
[I][MBOX] Peripheral GPIO (60): 0&lt;br /&gt;
[I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Once the system is running, the &amp;quot;MBOX&amp;quot; logs will abruptly disappear and you'll be able to manage the M0 multimedia core, i.e. wifi settings, etc. When prompted, type `help` to see available commands.&lt;br /&gt;
&lt;br /&gt;
==== Connecting the Ox64 to your WiFi network ====&lt;br /&gt;
&lt;br /&gt;
The simplest way to connect is to run the following command from the Linux console (i.e. `/dev/ttyACM0`):&lt;br /&gt;
&lt;br /&gt;
 $ blctl connect_ap &amp;lt;YourSSID&amp;gt; &amp;lt;YourPassword&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait for it to connect (if you're monitoring the M0 console on `/dev/ttyACM1` it should tell you when it's done), then run the following command from the Linux console:&lt;br /&gt;
&lt;br /&gt;
 $ udhcpc -i bleth0&lt;br /&gt;
 &lt;br /&gt;
Unfortunately the WiFi range leaves something to be desired. When you are performing the procedure above for the first time, move the Ox64 right next to your router. Once you are successfully connected, you can try experimenting with the maximum range.&lt;br /&gt;
&lt;br /&gt;
For more information on using the `blctl` command, see https://github.com/bouffalolab/blwnet_xram[here].&lt;br /&gt;
&lt;br /&gt;
=== Appendix ===&lt;br /&gt;
&lt;br /&gt;
==== Adding Nuttx RTOS ====&lt;br /&gt;
&lt;br /&gt;
In this section, we will set up our Ox64 to dual-boot both Linux and the NuttX real-time operating system. For more information see the https://nuttx.apache.org/docs/latest/platforms/risc-v/bl808/boards/ox64/index.html[official documentation].&lt;br /&gt;
&lt;br /&gt;
First, write the normal Linux image to the SD card if you have not done so already. You can find the correct device under `lsblk`:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/sdcard.img of=/dev/[DEVICE] bs=1M conv=fsync status=progress&lt;br /&gt;
&lt;br /&gt;
Run the following command to re-read the partition tables. Re-inserting the SD card works too:&lt;br /&gt;
&lt;br /&gt;
 $ sudo blockdev --rereadpt /dev/[DEVICE]&lt;br /&gt;
&lt;br /&gt;
Download the NuttX image:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/nuttx&lt;br /&gt;
 $ cd ~/ox64/nuttx&lt;br /&gt;
 $ wget -O ImageNuttx https://github.com/lupyuen2/wip-pinephone-nuttx/releases/download/bl808d-1/Image&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]2 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/&lt;br /&gt;
 $ sudo tee -a /mnt/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Mount the rootfs and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]3 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/boot/&lt;br /&gt;
 $ sudo tee -a /mnt/boot/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Enjoy your new Nuttx booting option!&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21480</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21480"/>
		<updated>2024-06-23T15:51:54Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 $ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 $ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 $ make menuconfig&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
 $ make&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing ==&lt;br /&gt;
This page explains how to flash an Ox64 board and a microSD card to boot the system. You will need a Linux computer, a serial UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
== Prepare images for flashing ==&lt;br /&gt;
&lt;br /&gt;
Download the Ox64 images from the latest OpenBouffalo release. You may skip this step if you built your own images as per the instructions in the link:/documentation/Ox64/Software/Building/[Building] page.&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/openbouffalo&lt;br /&gt;
 $ cd ~/ox64/openbouffalo&lt;br /&gt;
 $ wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware&lt;br /&gt;
 $ xz -v -d -k sdcard-pine64_ox64_full_defconfig.img.xz&lt;br /&gt;
 $ mv sdcard-pine64_ox64_full_defconfig.img sdcard.img&lt;br /&gt;
&lt;br /&gt;
=== Optional: create a combined SoC image ===&lt;br /&gt;
&lt;br /&gt;
Use the following commands to combine _m0_lowload_bl808_m0.bin_, _d0_lowload_bl808_d0.bin_, and _bl808-firmware.bin_ into a single image. This is mainly useful for troubleshooting (e. g. when using DevCube v1.8.4 or later).&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ fallocate -l 0x800000 bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=m0_lowload_bl808_m0.bin of=bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=d0_lowload_bl808_d0.bin of=bl808-combined.bin seek=$((0x100000))B&lt;br /&gt;
 $ cat bl808-firmware.bin &amp;gt;&amp;gt; bl808-combined.bin&lt;br /&gt;
&lt;br /&gt;
=== Check that you have the required files for flashing ===&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ ls -1 *808*.bin *.img&lt;br /&gt;
&lt;br /&gt;
Expected files:&lt;br /&gt;
&lt;br /&gt;
* `bl808-combined.bin` -- If you created the combined image.&lt;br /&gt;
* `bl808-firmware.bin` -- OpenSBI and UBoot DTB files. Runs on the D0 core.&lt;br /&gt;
* `d0_lowload_bl808_d0.bin` -- Startup code for the D0 core.&lt;br /&gt;
* `m0_lowload_bl808_m0.bin` -- Startup code for the M0 core.&lt;br /&gt;
* `sdcard.img` -- Kernel and root filesystem. Runs on the D0 core.&lt;br /&gt;
&lt;br /&gt;
== Set up your UART adapter ==&lt;br /&gt;
&lt;br /&gt;
In this section we will configure and wire up a UART adapter in order to flash the Ox64. Choose one of the options below based on the hardware available to you; the first two are the most convenient since they minimise the number of times you will need to swap electrical connections.&lt;br /&gt;
&lt;br /&gt;
=== Option 1: Raspberry Pi Pico ===&lt;br /&gt;
&lt;br /&gt;
First, download the Raspberry Pi Pico firmware that allows it to act as a serial UART adapter:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/pico&lt;br /&gt;
 $ cd ~/ox64/pico&lt;br /&gt;
 $ wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/raw/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
Put the Raspberry Pi Pico board into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
NOTE: As an alternative to pressing the BootSel button, you can also connect the probe point `TP6` (located on the bottom of the Pico board) to any ground point (e. g. pin 28).&lt;br /&gt;
&lt;br /&gt;
The Pico will now appear as a USB mass storage device. Copy the `UF2` file to program it:&lt;br /&gt;
&lt;br /&gt;
 $ cp ~/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Pico according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | PI PICO | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_pin17&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_pin16&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_pin6&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_pin7&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| gnd_pin38/3&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| &lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Pico flashed and wired as per the instructions above, we have access to two of the Ox64's UART ports at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Reconnect the Pico to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
&lt;br /&gt;
=== Option 2: STM32 Bluepill ===&lt;br /&gt;
&lt;br /&gt;
The Bluepill is an affordable STM32 development board, based on the STM32F103C8T6 chip. We can program it to act as a USB serial adapter, just like we did with the Raspberry Pi Pico.&lt;br /&gt;
&lt;br /&gt;
[NOTE]&lt;br /&gt;
&lt;br /&gt;
The one catch is that you already need a serial adapter in order to program your Bluepill board. The good news is that you serial adapter does **not** have to be one from from the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. These programming instructions have been tested with a FT232RL adapter (which, notably, is listed as _not_ supported on that list).&lt;br /&gt;
&lt;br /&gt;
If you own an SWD-capable debugger (ST-Link, J-link, etc.) you can use that for programming the Bluepill as well, although instead of `stm32flash` console command you would be using https://openocd.org/[openocd] or other suitable software.&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Install software to flash Bluepill. For Debian-based systems just install package from repository:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install stm32flash&lt;br /&gt;
&lt;br /&gt;
For Arch Linux systems, use the AUR repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ git clone https://aur.archlinux.org/stm32flash.git&lt;br /&gt;
 $ cd ~/ox64/bluepill/stm32flash&lt;br /&gt;
 $ makepkg -si&lt;br /&gt;
&lt;br /&gt;
Download the https://github.com/r2axz/bluepill-serial-monster[Bluepill Serial Monster] firmware:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ wget https://github.com/r2axz/bluepill-serial-monster/releases/download/v2.6.4/bluepill-serial-monster.hex&lt;br /&gt;
&lt;br /&gt;
Put the Bluepill into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Set boot jumpers for booting from rom: Boot0=1, Boot1=0.&lt;br /&gt;
* Connect it to a USB-Serial adapter with A9 to Rx, A10 to Tx, GND to GND, 3v3 to Vcc.&lt;br /&gt;
* Apply power by plugging the USB cable to PC. Press the Reset button.&lt;br /&gt;
&lt;br /&gt;
Find your USB serial adapter's device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`. Upload the firmware:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ sudo stm32flash -w bluepill-serial-monster.hex /dev/tty[DEVICE]&lt;br /&gt;
 &lt;br /&gt;
After upload, set boot jumpers for boot from flash: Boot0=0, Boot1=0. Disconnect the USB serial adapter from both the PC and Bluepill board.&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Bluepill according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | Bluepill | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_A3&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_A2&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_A9&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_A10&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| GND&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| 5V&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Bluepill flashed and wired as per the instructions above, we have access to two of the Ox64's UART connections at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Connect the Bluepill to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
* `/dev/ttyACM2` (unused)&lt;br /&gt;
&lt;br /&gt;
=== Option 3: Generic UART adapter ===&lt;br /&gt;
&lt;br /&gt;
image:/documentation/Ox64/images/ox64_pinout.png[Ox64 pinout,title=&amp;quot;Ox64 pinout&amp;quot;, 300, float=&amp;quot;right&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
Check that your serial adapter is on the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. You will (most likely) only have one serial interface available to you; unlike the previous options you will be using this same serial interface for both flashing and testing the system.&lt;br /&gt;
&lt;br /&gt;
Find its device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
You will also need a way of powering your Ox64. If your serial adapter has a 5V line, you can connect it to VBUS (pin 40). Otherwise, you can connect either the micro-B or the USB-C port on the Ox64 to any 5V power supply.&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Refer to the pinout image below. Connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; UART0_TX / GPIO14 / pin 1&lt;br /&gt;
* TX -&amp;gt; UART0_RX / GPIO15 / pin 2&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 3)&lt;br /&gt;
&lt;br /&gt;
Proceed with the instructions in the sections that follow, up to and including &amp;lt;&amp;lt;flashing_the_ox64&amp;gt;&amp;gt; and &amp;lt;&amp;lt;flashing_the_microsd_card&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM1` with `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
Next, power off the Ox64 and re-connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; TXD / GPIO16 / pin 32&lt;br /&gt;
* TX -&amp;gt; RXD / GPIO17 / pin 31&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 33)&lt;br /&gt;
&lt;br /&gt;
Then, follow the instructions in &amp;lt;&amp;lt;booting_for_the_first_time&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM0` with `/dev/tty[DEVICE]`. You should then have a working Linux system.&lt;br /&gt;
&lt;br /&gt;
== Download flashing tools ==&lt;br /&gt;
&lt;br /&gt;
You have a choice of flashing software:&lt;br /&gt;
&lt;br /&gt;
* DevCube: GUI-based closed source flashing tool&lt;br /&gt;
* CLI (`bflb-iot-tool`): command line open source flashing tool&lt;br /&gt;
&lt;br /&gt;
=== DevCube installation ===&lt;br /&gt;
&lt;br /&gt;
Download the latest DevCube flashing tool from BouffaloLab's website:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/devcube&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ unzip BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
If you did not create a link:#optional_create_a_combined_soc_image[combined image] you may need an older version of the DevCube. In that case, download v1.8.3 from one of the mirrors below:&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192[] &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify that your copy of `BouffaloLabDevCube-v1.8.3.zip` matches the hashes below:&lt;br /&gt;
&lt;br /&gt;
* SHA1: `0f2619e87d946f936f63ae97b0efd674357b1166`&lt;br /&gt;
* SHA256: `e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913`&lt;br /&gt;
&lt;br /&gt;
=== CLI packages installation ===&lt;br /&gt;
&lt;br /&gt;
Install `bflb-iot-tool` using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install pipenv # for Debian-based systems&lt;br /&gt;
  # or&lt;br /&gt;
 $ sudo pacman -S python-pipenv # for Arch Linux systems&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/&lt;br /&gt;
 $ pipenv install setuptools # install prerequisite of CLI flash tool&lt;br /&gt;
 $ pipenv install bflb-iot-tool # install CLI flash tool&lt;br /&gt;
 $ pipenv shell # activate virtual environment&lt;br /&gt;
 $ # bflb-iot-tool --help # return info about the tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: Each time you open a new terminal window you will need to `cd ~/ox64/` and re-run `pipenv shell` to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
== Flashing the Ox64 ==&lt;br /&gt;
&lt;br /&gt;
Put the Ox64 into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
=== CLI flashing method ===&lt;br /&gt;
&lt;br /&gt;
Set up some environment variables to save typing them out later:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ PORT=/dev/ttyACM1&lt;br /&gt;
 $ BAUD=230400  # safe value for macOS, set to 2000000 for faster flashing on Linux&lt;br /&gt;
&lt;br /&gt;
Finally, flash the Ox64. If you created a link:#optional_create_a_combined_soc_image[combined image] then run the command below:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware bl808-combined.bin --single&lt;br /&gt;
&lt;br /&gt;
Otherwise, run the following commands:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running any of the commands above, run `ls -l /dev/tty[DEVICE]`, to find out which group is allowed to talk to serial ports and add your user to that group, with `sudo usermod -a -G [GROUP] $USER` (i.e. `dialout` for Debian or `uucp` for Arch Linux). Make sure you re-login. Running the commands as `root` is not recommended since this will make `bflb-iot-tool` create root-owned files in your home directory. You can now run `exit` from virtual environment.&lt;br /&gt;
&lt;br /&gt;
=== BLDevCube flashing method&lt;br /&gt;
&lt;br /&gt;
Open a new terminal window to run the DevCube flasher:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish, and configure BOTH the [MCU] and [IOT] tabs as follows. When you switch between tabs double check that they still match the settings below:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;~,~&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
|Interface&lt;br /&gt;
|UART&lt;br /&gt;
&lt;br /&gt;
|Port/SN&lt;br /&gt;
|`/dev/ttyACM1`&lt;br /&gt;
&lt;br /&gt;
|UART rate&lt;br /&gt;
|230400 (safe value for macOS, set to 2000000 for faster flashing on Linux)&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
If you created a link:#optional_create_a_combined_soc_image[combined image] then you only need to use the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x0], [PATH to bl808-combined.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
Otherwise, start in the [MCU] tab:&lt;br /&gt;
&lt;br /&gt;
* M0 Group[group0], Image Address [0x58000000], [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
* D0 Group[group0], Image Address [0x58100000], [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Then, switch to the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x800000], [PATH to bl808-firmware.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
== Erasing the microSD card ==&lt;br /&gt;
&lt;br /&gt;
Make sure there are no signatures or partitions left, and overwrite the first sectors with zeroes. You can find the target device under `lsblk` command.&lt;br /&gt;
&lt;br /&gt;
 $ sudo wipefs /dev/[DEVICE]&lt;br /&gt;
 $ sudo wipefs --all --force /dev/[DEVICE]*&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=1&lt;br /&gt;
&lt;br /&gt;
Optionally you can zeroes the whole device:&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=$(expr $(lsblk -bno SIZE /dev/[DEVICE] | head -1) \/ 32768)&lt;br /&gt;
&lt;br /&gt;
== Flashing the microSD card ==&lt;br /&gt;
&lt;br /&gt;
Insert the microSD card into your PC, locate its device under `lsblk` and write the image:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=sdcard.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
== Booting for the first time ==&lt;br /&gt;
&lt;br /&gt;
Power off your Ox64 and insert the microSD card.&lt;br /&gt;
&lt;br /&gt;
Open a terminal window to connect to the D0 core’s (i.e. Linux’s) serial console:&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
If you are using a Pico or Bluepill as your serial adapter, open another terminal window to to monitor the M0 core’s serial console (reminder: `/dev/ttyACM1` is the same port we previously used for flashing):&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM1&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64.&lt;br /&gt;
&lt;br /&gt;
On the main/D0 console (`/dev/ttyACM0`) you will see Linux booting up. When prompted, log in as `root` with no password. In case the SD card is missing or empty, you'll get a `Card did not respond to voltage select! : -110` error.&lt;br /&gt;
&lt;br /&gt;
On the M0 console (`/dev/ttyACM1`) you'll see following messages until the sytem is fully loaded:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[I][MBOX] Mailbox IRQ Stats:&lt;br /&gt;
[I][MBOX] Peripheral SDH (33): 0&lt;br /&gt;
[I][MBOX] Peripheral GPIO (60): 0&lt;br /&gt;
[I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Once the system is running, the &amp;quot;MBOX&amp;quot; logs will abruptly disappear and you'll be able to manage the M0 multimedia core, i.e. wifi settings, etc. When prompted, type `help` to see available commands.&lt;br /&gt;
&lt;br /&gt;
=== Connecting the Ox64 to your WiFi network ===&lt;br /&gt;
&lt;br /&gt;
The simplest way to connect is to run the following command from the Linux console (i.e. `/dev/ttyACM0`):&lt;br /&gt;
&lt;br /&gt;
 $ blctl connect_ap &amp;lt;YourSSID&amp;gt; &amp;lt;YourPassword&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait for it to connect (if you're monitoring the M0 console on `/dev/ttyACM1` it should tell you when it's done), then run the following command from the Linux console:&lt;br /&gt;
&lt;br /&gt;
 $ udhcpc -i bleth0&lt;br /&gt;
 &lt;br /&gt;
Unfortunately the WiFi range leaves something to be desired. When you are performing the procedure above for the first time, move the Ox64 right next to your router. Once you are successfully connected, you can try experimenting with the maximum range.&lt;br /&gt;
&lt;br /&gt;
For more information on using the `blctl` command, see https://github.com/bouffalolab/blwnet_xram[here].&lt;br /&gt;
&lt;br /&gt;
== Appendix ==&lt;br /&gt;
&lt;br /&gt;
=== Adding Nuttx RTOS ===&lt;br /&gt;
&lt;br /&gt;
In this section, we will set up our Ox64 to dual-boot both Linux and the NuttX real-time operating system. For more information see the https://nuttx.apache.org/docs/latest/platforms/risc-v/bl808/boards/ox64/index.html[official documentation].&lt;br /&gt;
&lt;br /&gt;
First, write the normal Linux image to the SD card if you have not done so already. You can find the correct device under `lsblk`:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/sdcard.img of=/dev/[DEVICE] bs=1M conv=fsync status=progress&lt;br /&gt;
&lt;br /&gt;
Run the following command to re-read the partition tables. Re-inserting the SD card works too:&lt;br /&gt;
&lt;br /&gt;
 $ sudo blockdev --rereadpt /dev/[DEVICE]&lt;br /&gt;
&lt;br /&gt;
Download the NuttX image:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/nuttx&lt;br /&gt;
 $ cd ~/ox64/nuttx&lt;br /&gt;
 $ wget -O ImageNuttx https://github.com/lupyuen2/wip-pinephone-nuttx/releases/download/bl808d-1/Image&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]2 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/&lt;br /&gt;
 $ sudo tee -a /mnt/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Mount the rootfs and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]3 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/boot/&lt;br /&gt;
 $ sudo tee -a /mnt/boot/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Enjoy your new Nuttx booting option!&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21479</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21479"/>
		<updated>2024-06-23T15:46:05Z</updated>

		<summary type="html">&lt;p&gt;Giorez: /* Flashing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 $ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 $ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 $ make menuconfig&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
 $ make&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing ==&lt;br /&gt;
This page explains how to flash an Ox64 board and a microSD card to boot the system. You will need a Linux computer, a serial UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
== Prepare images for flashing&lt;br /&gt;
&lt;br /&gt;
Download the Ox64 images from the latest OpenBouffalo release. You may skip this step if you built your own images as per the instructions in the link:/documentation/Ox64/Software/Building/[Building] page.&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/openbouffalo&lt;br /&gt;
 $ cd ~/ox64/openbouffalo&lt;br /&gt;
 $ wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware&lt;br /&gt;
 $ xz -v -d -k sdcard-pine64_ox64_full_defconfig.img.xz&lt;br /&gt;
 $ mv sdcard-pine64_ox64_full_defconfig.img sdcard.img&lt;br /&gt;
&lt;br /&gt;
=== Optional: create a combined SoC image&lt;br /&gt;
&lt;br /&gt;
Use the following commands to combine _m0_lowload_bl808_m0.bin_, _d0_lowload_bl808_d0.bin_, and _bl808-firmware.bin_ into a single image. This is mainly useful for troubleshooting (e. g. when using DevCube v1.8.4 or later).&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ fallocate -l 0x800000 bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=m0_lowload_bl808_m0.bin of=bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=d0_lowload_bl808_d0.bin of=bl808-combined.bin seek=$((0x100000))B&lt;br /&gt;
 $ cat bl808-firmware.bin &amp;gt;&amp;gt; bl808-combined.bin&lt;br /&gt;
&lt;br /&gt;
=== Check that you have the required files for flashing&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ ls -1 *808*.bin *.img&lt;br /&gt;
&lt;br /&gt;
Expected files:&lt;br /&gt;
&lt;br /&gt;
* `bl808-combined.bin` -- If you created the combined image.&lt;br /&gt;
* `bl808-firmware.bin` -- OpenSBI and UBoot DTB files. Runs on the D0 core.&lt;br /&gt;
* `d0_lowload_bl808_d0.bin` -- Startup code for the D0 core.&lt;br /&gt;
* `m0_lowload_bl808_m0.bin` -- Startup code for the M0 core.&lt;br /&gt;
* `sdcard.img` -- Kernel and root filesystem. Runs on the D0 core.&lt;br /&gt;
&lt;br /&gt;
== Set up your UART adapter&lt;br /&gt;
&lt;br /&gt;
In this section we will configure and wire up a UART adapter in order to flash the Ox64. Choose one of the options below based on the hardware available to you; the first two are the most convenient since they minimise the number of times you will need to swap electrical connections.&lt;br /&gt;
&lt;br /&gt;
=== Option 1: Raspberry Pi Pico&lt;br /&gt;
&lt;br /&gt;
First, download the Raspberry Pi Pico firmware that allows it to act as a serial UART adapter:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/pico&lt;br /&gt;
 $ cd ~/ox64/pico&lt;br /&gt;
 $ wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/raw/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
Put the Raspberry Pi Pico board into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
NOTE: As an alternative to pressing the BootSel button, you can also connect the probe point `TP6` (located on the bottom of the Pico board) to any ground point (e. g. pin 28).&lt;br /&gt;
&lt;br /&gt;
The Pico will now appear as a USB mass storage device. Copy the `UF2` file to program it:&lt;br /&gt;
&lt;br /&gt;
 $ cp ~/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Pico according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | PI PICO | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_pin17&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_pin16&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_pin6&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_pin7&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| gnd_pin38/3&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| &lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Pico flashed and wired as per the instructions above, we have access to two of the Ox64's UART ports at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Reconnect the Pico to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
&lt;br /&gt;
=== Option 2: STM32 Bluepill&lt;br /&gt;
&lt;br /&gt;
The Bluepill is an affordable STM32 development board, based on the STM32F103C8T6 chip. We can program it to act as a USB serial adapter, just like we did with the Raspberry Pi Pico.&lt;br /&gt;
&lt;br /&gt;
[NOTE]&lt;br /&gt;
&lt;br /&gt;
====&lt;br /&gt;
The one catch is that you already need a serial adapter in order to program your Bluepill board. The good news is that you serial adapter does **not** have to be one from from the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. These programming instructions have been tested with a FT232RL adapter (which, notably, is listed as _not_ supported on that list).&lt;br /&gt;
&lt;br /&gt;
If you own an SWD-capable debugger (ST-Link, J-link, etc.) you can use that for programming the Bluepill as well, although instead of `stm32flash` console command you would be using https://openocd.org/[openocd] or other suitable software.&lt;br /&gt;
====&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Install software to flash Bluepill. For Debian-based systems just install package from repository:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install stm32flash&lt;br /&gt;
&lt;br /&gt;
For Arch Linux systems, use the AUR repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ git clone https://aur.archlinux.org/stm32flash.git&lt;br /&gt;
 $ cd ~/ox64/bluepill/stm32flash&lt;br /&gt;
 $ makepkg -si&lt;br /&gt;
&lt;br /&gt;
Download the https://github.com/r2axz/bluepill-serial-monster[Bluepill Serial Monster] firmware:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ wget https://github.com/r2axz/bluepill-serial-monster/releases/download/v2.6.4/bluepill-serial-monster.hex&lt;br /&gt;
&lt;br /&gt;
Put the Bluepill into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Set boot jumpers for booting from rom: Boot0=1, Boot1=0.&lt;br /&gt;
* Connect it to a USB-Serial adapter with A9 to Rx, A10 to Tx, GND to GND, 3v3 to Vcc.&lt;br /&gt;
* Apply power by plugging the USB cable to PC. Press the Reset button.&lt;br /&gt;
&lt;br /&gt;
Find your USB serial adapter's device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`. Upload the firmware:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ sudo stm32flash -w bluepill-serial-monster.hex /dev/tty[DEVICE]&lt;br /&gt;
 &lt;br /&gt;
After upload, set boot jumpers for boot from flash: Boot0=0, Boot1=0. Disconnect the USB serial adapter from both the PC and Bluepill board.&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Bluepill according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | Bluepill | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_A3&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_A2&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_A9&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_A10&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| GND&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| 5V&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Bluepill flashed and wired as per the instructions above, we have access to two of the Ox64's UART connections at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Connect the Bluepill to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
* `/dev/ttyACM2` (unused)&lt;br /&gt;
&lt;br /&gt;
=== Option 3: Generic UART adapter&lt;br /&gt;
&lt;br /&gt;
image:/documentation/Ox64/images/ox64_pinout.png[Ox64 pinout,title=&amp;quot;Ox64 pinout&amp;quot;, 300, float=&amp;quot;right&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
Check that your serial adapter is on the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. You will (most likely) only have one serial interface available to you; unlike the previous options you will be using this same serial interface for both flashing and testing the system.&lt;br /&gt;
&lt;br /&gt;
Find its device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
You will also need a way of powering your Ox64. If your serial adapter has a 5V line, you can connect it to VBUS (pin 40). Otherwise, you can connect either the micro-B or the USB-C port on the Ox64 to any 5V power supply.&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Refer to the pinout image below. Connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; UART0_TX / GPIO14 / pin 1&lt;br /&gt;
* TX -&amp;gt; UART0_RX / GPIO15 / pin 2&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 3)&lt;br /&gt;
&lt;br /&gt;
Proceed with the instructions in the sections that follow, up to and including &amp;lt;&amp;lt;flashing_the_ox64&amp;gt;&amp;gt; and &amp;lt;&amp;lt;flashing_the_microsd_card&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM1` with `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
Next, power off the Ox64 and re-connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; TXD / GPIO16 / pin 32&lt;br /&gt;
* TX -&amp;gt; RXD / GPIO17 / pin 31&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 33)&lt;br /&gt;
&lt;br /&gt;
Then, follow the instructions in &amp;lt;&amp;lt;booting_for_the_first_time&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM0` with `/dev/tty[DEVICE]`. You should then have a working Linux system.&lt;br /&gt;
&lt;br /&gt;
== Download flashing tools&lt;br /&gt;
&lt;br /&gt;
You have a choice of flashing software:&lt;br /&gt;
&lt;br /&gt;
* DevCube: GUI-based closed source flashing tool&lt;br /&gt;
* CLI (`bflb-iot-tool`): command line open source flashing tool&lt;br /&gt;
&lt;br /&gt;
=== DevCube installation&lt;br /&gt;
&lt;br /&gt;
Download the latest DevCube flashing tool from BouffaloLab's website:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/devcube&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ unzip BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
If you did not create a link:#optional_create_a_combined_soc_image[combined image] you may need an older version of the DevCube. In that case, download v1.8.3 from one of the mirrors below:&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192[] &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify that your copy of `BouffaloLabDevCube-v1.8.3.zip` matches the hashes below:&lt;br /&gt;
&lt;br /&gt;
* SHA1: `0f2619e87d946f936f63ae97b0efd674357b1166`&lt;br /&gt;
* SHA256: `e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913`&lt;br /&gt;
&lt;br /&gt;
=== CLI packages installation&lt;br /&gt;
&lt;br /&gt;
Install `bflb-iot-tool` using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install pipenv # for Debian-based systems&lt;br /&gt;
  # or&lt;br /&gt;
 $ sudo pacman -S python-pipenv # for Arch Linux systems&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/&lt;br /&gt;
 $ pipenv install setuptools # install prerequisite of CLI flash tool&lt;br /&gt;
 $ pipenv install bflb-iot-tool # install CLI flash tool&lt;br /&gt;
 $ pipenv shell # activate virtual environment&lt;br /&gt;
 $ # bflb-iot-tool --help # return info about the tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: Each time you open a new terminal window you will need to `cd ~/ox64/` and re-run `pipenv shell` to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
== Flashing the Ox64&lt;br /&gt;
&lt;br /&gt;
Put the Ox64 into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
=== CLI flashing method&lt;br /&gt;
&lt;br /&gt;
Set up some environment variables to save typing them out later:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ PORT=/dev/ttyACM1&lt;br /&gt;
 $ BAUD=230400  # safe value for macOS, set to 2000000 for faster flashing on Linux&lt;br /&gt;
&lt;br /&gt;
Finally, flash the Ox64. If you created a link:#optional_create_a_combined_soc_image[combined image] then run the command below:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware bl808-combined.bin --single&lt;br /&gt;
&lt;br /&gt;
Otherwise, run the following commands:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
&lt;br /&gt;
$ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running any of the commands above, run `ls -l /dev/tty[DEVICE]`, to find out which group is allowed to talk to serial ports and add your user to that group, with `sudo usermod -a -G [GROUP] $USER` (i.e. `dialout` for Debian or `uucp` for Arch Linux). Make sure you re-login. Running the commands as `root` is not recommended since this will make `bflb-iot-tool` create root-owned files in your home directory. You can now run `exit` from virtual environment.&lt;br /&gt;
&lt;br /&gt;
=== BLDevCube flashing method&lt;br /&gt;
&lt;br /&gt;
Open a new terminal window to run the DevCube flasher:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish, and configure BOTH the [MCU] and [IOT] tabs as follows. When you switch between tabs double check that they still match the settings below:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;~,~&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
|Interface&lt;br /&gt;
|UART&lt;br /&gt;
&lt;br /&gt;
|Port/SN&lt;br /&gt;
|`/dev/ttyACM1`&lt;br /&gt;
&lt;br /&gt;
|UART rate&lt;br /&gt;
|230400 (safe value for macOS, set to 2000000 for faster flashing on Linux)&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
If you created a link:#optional_create_a_combined_soc_image[combined image] then you only need to use the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x0], [PATH to bl808-combined.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
Otherwise, start in the [MCU] tab:&lt;br /&gt;
&lt;br /&gt;
* M0 Group[group0], Image Address [0x58000000], [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
* D0 Group[group0], Image Address [0x58100000], [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Then, switch to the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x800000], [PATH to bl808-firmware.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
== Erasing the microSD card&lt;br /&gt;
&lt;br /&gt;
Make sure there are no signatures or partitions left, and overwrite the first sectors with zeroes. You can find the target device under `lsblk` command.&lt;br /&gt;
&lt;br /&gt;
 $ sudo wipefs /dev/[DEVICE]&lt;br /&gt;
 $ sudo wipefs --all --force /dev/[DEVICE]*&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=1&lt;br /&gt;
&lt;br /&gt;
Optionally you can zeroes the whole device:&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=$(expr $(lsblk -bno SIZE /dev/[DEVICE] | head -1) \/ 32768)&lt;br /&gt;
&lt;br /&gt;
== Flashing the microSD card&lt;br /&gt;
&lt;br /&gt;
Insert the microSD card into your PC, locate its device under `lsblk` and write the image:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=sdcard.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
== Booting for the first time&lt;br /&gt;
&lt;br /&gt;
Power off your Ox64 and insert the microSD card.&lt;br /&gt;
&lt;br /&gt;
Open a terminal window to connect to the D0 core’s (i.e. Linux’s) serial console:&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
If you are using a Pico or Bluepill as your serial adapter, open another terminal window to to monitor the M0 core’s serial console (reminder: `/dev/ttyACM1` is the same port we previously used for flashing):&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM1&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64.&lt;br /&gt;
&lt;br /&gt;
On the main/D0 console (`/dev/ttyACM0`) you will see Linux booting up. When prompted, log in as `root` with no password. In case the SD card is missing or empty, you'll get a `Card did not respond to voltage select! : -110` error.&lt;br /&gt;
&lt;br /&gt;
On the M0 console (`/dev/ttyACM1`) you'll see following messages until the sytem is fully loaded:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[I][MBOX] Mailbox IRQ Stats:&lt;br /&gt;
[I][MBOX] Peripheral SDH (33): 0&lt;br /&gt;
[I][MBOX] Peripheral GPIO (60): 0&lt;br /&gt;
[I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Once the system is running, the &amp;quot;MBOX&amp;quot; logs will abruptly disappear and you'll be able to manage the M0 multimedia core, i.e. wifi settings, etc. When prompted, type `help` to see available commands.&lt;br /&gt;
&lt;br /&gt;
=== Connecting the Ox64 to your WiFi network&lt;br /&gt;
The simplest way to connect is to run the following command from the Linux console (i.e. `/dev/ttyACM0`):&lt;br /&gt;
&lt;br /&gt;
 $ blctl connect_ap &amp;lt;YourSSID&amp;gt; &amp;lt;YourPassword&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait for it to connect (if you're monitoring the M0 console on `/dev/ttyACM1` it should tell you when it's done), then run the following command from the Linux console:&lt;br /&gt;
&lt;br /&gt;
 $ udhcpc -i bleth0&lt;br /&gt;
 &lt;br /&gt;
Unfortunately the WiFi range leaves something to be desired. When you are performing the procedure above for the first time, move the Ox64 right next to your router. Once you are successfully connected, you can try experimenting with the maximum range.&lt;br /&gt;
&lt;br /&gt;
For more information on using the `blctl` command, see https://github.com/bouffalolab/blwnet_xram[here].&lt;br /&gt;
&lt;br /&gt;
== Appendix&lt;br /&gt;
&lt;br /&gt;
=== Adding Nuttx RTOS&lt;br /&gt;
&lt;br /&gt;
In this section, we will set up our Ox64 to dual-boot both Linux and the NuttX real-time operating system. For more information see the https://nuttx.apache.org/docs/latest/platforms/risc-v/bl808/boards/ox64/index.html[official documentation].&lt;br /&gt;
&lt;br /&gt;
First, write the normal Linux image to the SD card if you have not done so already. You can find the correct device under `lsblk`:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/sdcard.img of=/dev/[DEVICE] bs=1M conv=fsync status=progress&lt;br /&gt;
&lt;br /&gt;
Run the following command to re-read the partition tables. Re-inserting the SD card works too:&lt;br /&gt;
&lt;br /&gt;
 $ sudo blockdev --rereadpt /dev/[DEVICE]&lt;br /&gt;
&lt;br /&gt;
Download the NuttX image:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/nuttx&lt;br /&gt;
 $ cd ~/ox64/nuttx&lt;br /&gt;
 $ wget -O ImageNuttx https://github.com/lupyuen2/wip-pinephone-nuttx/releases/download/bl808d-1/Image&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]2 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/&lt;br /&gt;
 $ sudo tee -a /mnt/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Mount the rootfs and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]3 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/boot/&lt;br /&gt;
 $ sudo tee -a /mnt/boot/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Enjoy your new Nuttx booting option!&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21478</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21478"/>
		<updated>2024-06-23T15:45:31Z</updated>

		<summary type="html">&lt;p&gt;Giorez: /* Building */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Building ==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 $ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 $ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 $ make menuconfig&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
 $ make&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This page explains how to flash an Ox64 board and a microSD card to boot the system. You will need a Linux computer, a serial UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
== Prepare images for flashing&lt;br /&gt;
&lt;br /&gt;
Download the Ox64 images from the latest OpenBouffalo release. You may skip this step if you built your own images as per the instructions in the link:/documentation/Ox64/Software/Building/[Building] page.&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/openbouffalo&lt;br /&gt;
 $ cd ~/ox64/openbouffalo&lt;br /&gt;
 $ wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware&lt;br /&gt;
 $ xz -v -d -k sdcard-pine64_ox64_full_defconfig.img.xz&lt;br /&gt;
 $ mv sdcard-pine64_ox64_full_defconfig.img sdcard.img&lt;br /&gt;
&lt;br /&gt;
=== Optional: create a combined SoC image&lt;br /&gt;
&lt;br /&gt;
Use the following commands to combine _m0_lowload_bl808_m0.bin_, _d0_lowload_bl808_d0.bin_, and _bl808-firmware.bin_ into a single image. This is mainly useful for troubleshooting (e. g. when using DevCube v1.8.4 or later).&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ fallocate -l 0x800000 bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=m0_lowload_bl808_m0.bin of=bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=d0_lowload_bl808_d0.bin of=bl808-combined.bin seek=$((0x100000))B&lt;br /&gt;
 $ cat bl808-firmware.bin &amp;gt;&amp;gt; bl808-combined.bin&lt;br /&gt;
&lt;br /&gt;
=== Check that you have the required files for flashing&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ ls -1 *808*.bin *.img&lt;br /&gt;
&lt;br /&gt;
Expected files:&lt;br /&gt;
&lt;br /&gt;
* `bl808-combined.bin` -- If you created the combined image.&lt;br /&gt;
* `bl808-firmware.bin` -- OpenSBI and UBoot DTB files. Runs on the D0 core.&lt;br /&gt;
* `d0_lowload_bl808_d0.bin` -- Startup code for the D0 core.&lt;br /&gt;
* `m0_lowload_bl808_m0.bin` -- Startup code for the M0 core.&lt;br /&gt;
* `sdcard.img` -- Kernel and root filesystem. Runs on the D0 core.&lt;br /&gt;
&lt;br /&gt;
== Set up your UART adapter&lt;br /&gt;
&lt;br /&gt;
In this section we will configure and wire up a UART adapter in order to flash the Ox64. Choose one of the options below based on the hardware available to you; the first two are the most convenient since they minimise the number of times you will need to swap electrical connections.&lt;br /&gt;
&lt;br /&gt;
=== Option 1: Raspberry Pi Pico&lt;br /&gt;
&lt;br /&gt;
First, download the Raspberry Pi Pico firmware that allows it to act as a serial UART adapter:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/pico&lt;br /&gt;
 $ cd ~/ox64/pico&lt;br /&gt;
 $ wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/raw/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
Put the Raspberry Pi Pico board into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
NOTE: As an alternative to pressing the BootSel button, you can also connect the probe point `TP6` (located on the bottom of the Pico board) to any ground point (e. g. pin 28).&lt;br /&gt;
&lt;br /&gt;
The Pico will now appear as a USB mass storage device. Copy the `UF2` file to program it:&lt;br /&gt;
&lt;br /&gt;
 $ cp ~/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Pico according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | PI PICO | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_pin17&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_pin16&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_pin6&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_pin7&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| gnd_pin38/3&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| &lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Pico flashed and wired as per the instructions above, we have access to two of the Ox64's UART ports at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Reconnect the Pico to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
&lt;br /&gt;
=== Option 2: STM32 Bluepill&lt;br /&gt;
&lt;br /&gt;
The Bluepill is an affordable STM32 development board, based on the STM32F103C8T6 chip. We can program it to act as a USB serial adapter, just like we did with the Raspberry Pi Pico.&lt;br /&gt;
&lt;br /&gt;
[NOTE]&lt;br /&gt;
====&lt;br /&gt;
The one catch is that you already need a serial adapter in order to program your Bluepill board. The good news is that you serial adapter does **not** have to be one from from the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. These programming instructions have been tested with a FT232RL adapter (which, notably, is listed as _not_ supported on that list).&lt;br /&gt;
&lt;br /&gt;
If you own an SWD-capable debugger (ST-Link, J-link, etc.) you can use that for programming the Bluepill as well, although instead of `stm32flash` console command you would be using https://openocd.org/[openocd] or other suitable software.&lt;br /&gt;
====&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Install software to flash Bluepill. For Debian-based systems just install package from repository:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install stm32flash&lt;br /&gt;
&lt;br /&gt;
For Arch Linux systems, use the AUR repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ git clone https://aur.archlinux.org/stm32flash.git&lt;br /&gt;
 $ cd ~/ox64/bluepill/stm32flash&lt;br /&gt;
 $ makepkg -si&lt;br /&gt;
&lt;br /&gt;
Download the https://github.com/r2axz/bluepill-serial-monster[Bluepill Serial Monster] firmware:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ wget https://github.com/r2axz/bluepill-serial-monster/releases/download/v2.6.4/bluepill-serial-monster.hex&lt;br /&gt;
&lt;br /&gt;
Put the Bluepill into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Set boot jumpers for booting from rom: Boot0=1, Boot1=0.&lt;br /&gt;
* Connect it to a USB-Serial adapter with A9 to Rx, A10 to Tx, GND to GND, 3v3 to Vcc.&lt;br /&gt;
* Apply power by plugging the USB cable to PC. Press the Reset button.&lt;br /&gt;
&lt;br /&gt;
Find your USB serial adapter's device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`. Upload the firmware:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ sudo stm32flash -w bluepill-serial-monster.hex /dev/tty[DEVICE]&lt;br /&gt;
 &lt;br /&gt;
After upload, set boot jumpers for boot from flash: Boot0=0, Boot1=0. Disconnect the USB serial adapter from both the PC and Bluepill board.&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Bluepill according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | Bluepill | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_A3&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_A2&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_A9&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_A10&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| GND&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| 5V&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Bluepill flashed and wired as per the instructions above, we have access to two of the Ox64's UART connections at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Connect the Bluepill to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
* `/dev/ttyACM2` (unused)&lt;br /&gt;
&lt;br /&gt;
=== Option 3: Generic UART adapter&lt;br /&gt;
&lt;br /&gt;
image:/documentation/Ox64/images/ox64_pinout.png[Ox64 pinout,title=&amp;quot;Ox64 pinout&amp;quot;, 300, float=&amp;quot;right&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
Check that your serial adapter is on the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. You will (most likely) only have one serial interface available to you; unlike the previous options you will be using this same serial interface for both flashing and testing the system.&lt;br /&gt;
&lt;br /&gt;
Find its device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
You will also need a way of powering your Ox64. If your serial adapter has a 5V line, you can connect it to VBUS (pin 40). Otherwise, you can connect either the micro-B or the USB-C port on the Ox64 to any 5V power supply.&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Refer to the pinout image below. Connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; UART0_TX / GPIO14 / pin 1&lt;br /&gt;
* TX -&amp;gt; UART0_RX / GPIO15 / pin 2&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 3)&lt;br /&gt;
&lt;br /&gt;
Proceed with the instructions in the sections that follow, up to and including &amp;lt;&amp;lt;flashing_the_ox64&amp;gt;&amp;gt; and &amp;lt;&amp;lt;flashing_the_microsd_card&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM1` with `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
Next, power off the Ox64 and re-connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; TXD / GPIO16 / pin 32&lt;br /&gt;
* TX -&amp;gt; RXD / GPIO17 / pin 31&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 33)&lt;br /&gt;
&lt;br /&gt;
Then, follow the instructions in &amp;lt;&amp;lt;booting_for_the_first_time&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM0` with `/dev/tty[DEVICE]`. You should then have a working Linux system.&lt;br /&gt;
&lt;br /&gt;
== Download flashing tools&lt;br /&gt;
&lt;br /&gt;
You have a choice of flashing software:&lt;br /&gt;
&lt;br /&gt;
* DevCube: GUI-based closed source flashing tool&lt;br /&gt;
* CLI (`bflb-iot-tool`): command line open source flashing tool&lt;br /&gt;
&lt;br /&gt;
=== DevCube installation&lt;br /&gt;
&lt;br /&gt;
Download the latest DevCube flashing tool from BouffaloLab's website:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/devcube&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ unzip BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
If you did not create a link:#optional_create_a_combined_soc_image[combined image] you may need an older version of the DevCube. In that case, download v1.8.3 from one of the mirrors below:&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192[] &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify that your copy of `BouffaloLabDevCube-v1.8.3.zip` matches the hashes below:&lt;br /&gt;
&lt;br /&gt;
* SHA1: `0f2619e87d946f936f63ae97b0efd674357b1166`&lt;br /&gt;
* SHA256: `e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913`&lt;br /&gt;
&lt;br /&gt;
=== CLI packages installation&lt;br /&gt;
&lt;br /&gt;
Install `bflb-iot-tool` using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install pipenv # for Debian-based systems&lt;br /&gt;
  # or&lt;br /&gt;
 $ sudo pacman -S python-pipenv # for Arch Linux systems&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/&lt;br /&gt;
 $ pipenv install setuptools # install prerequisite of CLI flash tool&lt;br /&gt;
 $ pipenv install bflb-iot-tool # install CLI flash tool&lt;br /&gt;
 $ pipenv shell # activate virtual environment&lt;br /&gt;
 $ # bflb-iot-tool --help # return info about the tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: Each time you open a new terminal window you will need to `cd ~/ox64/` and re-run `pipenv shell` to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
== Flashing the Ox64&lt;br /&gt;
&lt;br /&gt;
Put the Ox64 into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
=== CLI flashing method&lt;br /&gt;
&lt;br /&gt;
Set up some environment variables to save typing them out later:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ PORT=/dev/ttyACM1&lt;br /&gt;
 $ BAUD=230400  # safe value for macOS, set to 2000000 for faster flashing on Linux&lt;br /&gt;
&lt;br /&gt;
Finally, flash the Ox64. If you created a link:#optional_create_a_combined_soc_image[combined image] then run the command below:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware bl808-combined.bin --single&lt;br /&gt;
&lt;br /&gt;
Otherwise, run the following commands:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
&lt;br /&gt;
$ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running any of the commands above, run `ls -l /dev/tty[DEVICE]`, to find out which group is allowed to talk to serial ports and add your user to that group, with `sudo usermod -a -G [GROUP] $USER` (i.e. `dialout` for Debian or `uucp` for Arch Linux). Make sure you re-login. Running the commands as `root` is not recommended since this will make `bflb-iot-tool` create root-owned files in your home directory. You can now run `exit` from virtual environment.&lt;br /&gt;
&lt;br /&gt;
=== BLDevCube flashing method&lt;br /&gt;
&lt;br /&gt;
Open a new terminal window to run the DevCube flasher:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish, and configure BOTH the [MCU] and [IOT] tabs as follows. When you switch between tabs double check that they still match the settings below:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;~,~&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
|Interface&lt;br /&gt;
|UART&lt;br /&gt;
&lt;br /&gt;
|Port/SN&lt;br /&gt;
|`/dev/ttyACM1`&lt;br /&gt;
&lt;br /&gt;
|UART rate&lt;br /&gt;
|230400 (safe value for macOS, set to 2000000 for faster flashing on Linux)&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
If you created a link:#optional_create_a_combined_soc_image[combined image] then you only need to use the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x0], [PATH to bl808-combined.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
Otherwise, start in the [MCU] tab:&lt;br /&gt;
&lt;br /&gt;
* M0 Group[group0], Image Address [0x58000000], [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
* D0 Group[group0], Image Address [0x58100000], [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Then, switch to the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x800000], [PATH to bl808-firmware.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
== Erasing the microSD card&lt;br /&gt;
&lt;br /&gt;
Make sure there are no signatures or partitions left, and overwrite the first sectors with zeroes. You can find the target device under `lsblk` command.&lt;br /&gt;
&lt;br /&gt;
 $ sudo wipefs /dev/[DEVICE]&lt;br /&gt;
 $ sudo wipefs --all --force /dev/[DEVICE]*&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=1&lt;br /&gt;
&lt;br /&gt;
Optionally you can zeroes the whole device:&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=$(expr $(lsblk -bno SIZE /dev/[DEVICE] | head -1) \/ 32768)&lt;br /&gt;
&lt;br /&gt;
== Flashing the microSD card&lt;br /&gt;
&lt;br /&gt;
Insert the microSD card into your PC, locate its device under `lsblk` and write the image:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=sdcard.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
== Booting for the first time&lt;br /&gt;
&lt;br /&gt;
Power off your Ox64 and insert the microSD card.&lt;br /&gt;
&lt;br /&gt;
Open a terminal window to connect to the D0 core’s (i.e. Linux’s) serial console:&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
If you are using a Pico or Bluepill as your serial adapter, open another terminal window to to monitor the M0 core’s serial console (reminder: `/dev/ttyACM1` is the same port we previously used for flashing):&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM1&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64.&lt;br /&gt;
&lt;br /&gt;
On the main/D0 console (`/dev/ttyACM0`) you will see Linux booting up. When prompted, log in as `root` with no password. In case the SD card is missing or empty, you'll get a `Card did not respond to voltage select! : -110` error.&lt;br /&gt;
&lt;br /&gt;
On the M0 console (`/dev/ttyACM1`) you'll see following messages until the sytem is fully loaded:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[I][MBOX] Mailbox IRQ Stats:&lt;br /&gt;
[I][MBOX] Peripheral SDH (33): 0&lt;br /&gt;
[I][MBOX] Peripheral GPIO (60): 0&lt;br /&gt;
[I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Once the system is running, the &amp;quot;MBOX&amp;quot; logs will abruptly disappear and you'll be able to manage the M0 multimedia core, i.e. wifi settings, etc. When prompted, type `help` to see available commands.&lt;br /&gt;
&lt;br /&gt;
=== Connecting the Ox64 to your WiFi network&lt;br /&gt;
The simplest way to connect is to run the following command from the Linux console (i.e. `/dev/ttyACM0`):&lt;br /&gt;
&lt;br /&gt;
 $ blctl connect_ap &amp;lt;YourSSID&amp;gt; &amp;lt;YourPassword&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait for it to connect (if you're monitoring the M0 console on `/dev/ttyACM1` it should tell you when it's done), then run the following command from the Linux console:&lt;br /&gt;
&lt;br /&gt;
 $ udhcpc -i bleth0&lt;br /&gt;
 &lt;br /&gt;
Unfortunately the WiFi range leaves something to be desired. When you are performing the procedure above for the first time, move the Ox64 right next to your router. Once you are successfully connected, you can try experimenting with the maximum range.&lt;br /&gt;
&lt;br /&gt;
For more information on using the `blctl` command, see https://github.com/bouffalolab/blwnet_xram[here].&lt;br /&gt;
&lt;br /&gt;
== Appendix&lt;br /&gt;
&lt;br /&gt;
=== Adding Nuttx RTOS&lt;br /&gt;
&lt;br /&gt;
In this section, we will set up our Ox64 to dual-boot both Linux and the NuttX real-time operating system. For more information see the https://nuttx.apache.org/docs/latest/platforms/risc-v/bl808/boards/ox64/index.html[official documentation].&lt;br /&gt;
&lt;br /&gt;
First, write the normal Linux image to the SD card if you have not done so already. You can find the correct device under `lsblk`:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/sdcard.img of=/dev/[DEVICE] bs=1M conv=fsync status=progress&lt;br /&gt;
&lt;br /&gt;
Run the following command to re-read the partition tables. Re-inserting the SD card works too:&lt;br /&gt;
&lt;br /&gt;
 $ sudo blockdev --rereadpt /dev/[DEVICE]&lt;br /&gt;
&lt;br /&gt;
Download the NuttX image:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/nuttx&lt;br /&gt;
 $ cd ~/ox64/nuttx&lt;br /&gt;
 $ wget -O ImageNuttx https://github.com/lupyuen2/wip-pinephone-nuttx/releases/download/bl808d-1/Image&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]2 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/&lt;br /&gt;
 $ sudo tee -a /mnt/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Mount the rootfs and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]3 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/boot/&lt;br /&gt;
 $ sudo tee -a /mnt/boot/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Enjoy your new Nuttx booting option!&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21477</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21477"/>
		<updated>2024-06-23T15:44:23Z</updated>

		<summary type="html">&lt;p&gt;Giorez: /* Flashing Ox64 SBC and microSD Card */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 $ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 $ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 $ make menuconfig&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
 $ make&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This page explains how to flash an Ox64 board and a microSD card to boot the system. You will need a Linux computer, a serial UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
== Prepare images for flashing&lt;br /&gt;
&lt;br /&gt;
Download the Ox64 images from the latest OpenBouffalo release. You may skip this step if you built your own images as per the instructions in the link:/documentation/Ox64/Software/Building/[Building] page.&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/openbouffalo&lt;br /&gt;
 $ cd ~/ox64/openbouffalo&lt;br /&gt;
 $ wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware&lt;br /&gt;
 $ xz -v -d -k sdcard-pine64_ox64_full_defconfig.img.xz&lt;br /&gt;
 $ mv sdcard-pine64_ox64_full_defconfig.img sdcard.img&lt;br /&gt;
&lt;br /&gt;
=== Optional: create a combined SoC image&lt;br /&gt;
&lt;br /&gt;
Use the following commands to combine _m0_lowload_bl808_m0.bin_, _d0_lowload_bl808_d0.bin_, and _bl808-firmware.bin_ into a single image. This is mainly useful for troubleshooting (e. g. when using DevCube v1.8.4 or later).&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ fallocate -l 0x800000 bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=m0_lowload_bl808_m0.bin of=bl808-combined.bin&lt;br /&gt;
 $ dd conv=notrunc if=d0_lowload_bl808_d0.bin of=bl808-combined.bin seek=$((0x100000))B&lt;br /&gt;
 $ cat bl808-firmware.bin &amp;gt;&amp;gt; bl808-combined.bin&lt;br /&gt;
&lt;br /&gt;
=== Check that you have the required files for flashing&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ ls -1 *808*.bin *.img&lt;br /&gt;
&lt;br /&gt;
Expected files:&lt;br /&gt;
&lt;br /&gt;
* `bl808-combined.bin` -- If you created the combined image.&lt;br /&gt;
* `bl808-firmware.bin` -- OpenSBI and UBoot DTB files. Runs on the D0 core.&lt;br /&gt;
* `d0_lowload_bl808_d0.bin` -- Startup code for the D0 core.&lt;br /&gt;
* `m0_lowload_bl808_m0.bin` -- Startup code for the M0 core.&lt;br /&gt;
* `sdcard.img` -- Kernel and root filesystem. Runs on the D0 core.&lt;br /&gt;
&lt;br /&gt;
== Set up your UART adapter&lt;br /&gt;
&lt;br /&gt;
In this section we will configure and wire up a UART adapter in order to flash the Ox64. Choose one of the options below based on the hardware available to you; the first two are the most convenient since they minimise the number of times you will need to swap electrical connections.&lt;br /&gt;
&lt;br /&gt;
=== Option 1: Raspberry Pi Pico&lt;br /&gt;
&lt;br /&gt;
First, download the Raspberry Pi Pico firmware that allows it to act as a serial UART adapter:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/pico&lt;br /&gt;
 $ cd ~/ox64/pico&lt;br /&gt;
 $ wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/raw/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
Put the Raspberry Pi Pico board into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
NOTE: As an alternative to pressing the BootSel button, you can also connect the probe point `TP6` (located on the bottom of the Pico board) to any ground point (e. g. pin 28).&lt;br /&gt;
&lt;br /&gt;
The Pico will now appear as a USB mass storage device. Copy the `UF2` file to program it:&lt;br /&gt;
&lt;br /&gt;
 $ cp ~/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Pico according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | PI PICO | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_pin17&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_pin16&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_pin6&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_pin7&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| gnd_pin38/3&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| &lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Pico flashed and wired as per the instructions above, we have access to two of the Ox64's UART ports at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Reconnect the Pico to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
&lt;br /&gt;
=== Option 2: STM32 Bluepill&lt;br /&gt;
&lt;br /&gt;
The Bluepill is an affordable STM32 development board, based on the STM32F103C8T6 chip. We can program it to act as a USB serial adapter, just like we did with the Raspberry Pi Pico.&lt;br /&gt;
&lt;br /&gt;
[NOTE]&lt;br /&gt;
====&lt;br /&gt;
The one catch is that you already need a serial adapter in order to program your Bluepill board. The good news is that you serial adapter does **not** have to be one from from the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. These programming instructions have been tested with a FT232RL adapter (which, notably, is listed as _not_ supported on that list).&lt;br /&gt;
&lt;br /&gt;
If you own an SWD-capable debugger (ST-Link, J-link, etc.) you can use that for programming the Bluepill as well, although instead of `stm32flash` console command you would be using https://openocd.org/[openocd] or other suitable software.&lt;br /&gt;
====&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Install software to flash Bluepill. For Debian-based systems just install package from repository:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install stm32flash&lt;br /&gt;
&lt;br /&gt;
For Arch Linux systems, use the AUR repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ git clone https://aur.archlinux.org/stm32flash.git&lt;br /&gt;
 $ cd ~/ox64/bluepill/stm32flash&lt;br /&gt;
 $ makepkg -si&lt;br /&gt;
&lt;br /&gt;
Download the https://github.com/r2axz/bluepill-serial-monster[Bluepill Serial Monster] firmware:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/bluepill&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ wget https://github.com/r2axz/bluepill-serial-monster/releases/download/v2.6.4/bluepill-serial-monster.hex&lt;br /&gt;
&lt;br /&gt;
Put the Bluepill into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Set boot jumpers for booting from rom: Boot0=1, Boot1=0.&lt;br /&gt;
* Connect it to a USB-Serial adapter with A9 to Rx, A10 to Tx, GND to GND, 3v3 to Vcc.&lt;br /&gt;
* Apply power by plugging the USB cable to PC. Press the Reset button.&lt;br /&gt;
&lt;br /&gt;
Find your USB serial adapter's device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`. Upload the firmware:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/bluepill&lt;br /&gt;
 $ sudo stm32flash -w bluepill-serial-monster.hex /dev/tty[DEVICE]&lt;br /&gt;
 &lt;br /&gt;
After upload, set boot jumpers for boot from flash: Boot0=0, Boot1=0. Disconnect the USB serial adapter from both the PC and Bluepill board.&lt;br /&gt;
&lt;br /&gt;
Next, connect the Ox64 board to the Bluepill according to the following wiring diagram:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;1,1,1&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
| Ox64 | Bluepill | /dev/tty&lt;br /&gt;
&lt;br /&gt;
| uart0_Tx_GPIO14_pin1&lt;br /&gt;
| uart0_Rx_A3&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| uart0_Rx_GPIO15_pin2&lt;br /&gt;
| uart0_Tx_A2&lt;br /&gt;
| ACM1 for flashing&lt;br /&gt;
&lt;br /&gt;
| Rxd_GPIO17_pin31&lt;br /&gt;
| uart1_Tx_A9&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| Txd_GPIO16_pin32&lt;br /&gt;
| uart1_Rx_A10&lt;br /&gt;
| ACM0 for serial console&lt;br /&gt;
&lt;br /&gt;
| gnd_pin38&lt;br /&gt;
| GND&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
| vbus5v_pin40&lt;br /&gt;
| 5V&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
With the Bluepill flashed and wired as per the instructions above, we have access to two of the Ox64's UART connections at the same time. This configuration eliminates the need to switch the physical connections for flashing or testing the system.&lt;br /&gt;
&lt;br /&gt;
Connect the Bluepill to your computer's USB port and verify that we have access to all the serial ports we need:&lt;br /&gt;
&lt;br /&gt;
 $ ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Expected result:&lt;br /&gt;
&lt;br /&gt;
* `/dev/ttyACM0` connects to the D0 core's (i.e. Linux's) serial console&lt;br /&gt;
* `/dev/ttyACM1` is used for flashing (but also connects to the M0 core's serial console)&lt;br /&gt;
* `/dev/ttyACM2` (unused)&lt;br /&gt;
&lt;br /&gt;
=== Option 3: Generic UART adapter&lt;br /&gt;
&lt;br /&gt;
image:/documentation/Ox64/images/ox64_pinout.png[Ox64 pinout,title=&amp;quot;Ox64 pinout&amp;quot;, 300, float=&amp;quot;right&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
Check that your serial adapter is on the link:/documentation/Ox64/Further_information/Compatible_UARTs/[Compatible UARTs] list. You will (most likely) only have one serial interface available to you; unlike the previous options you will be using this same serial interface for both flashing and testing the system.&lt;br /&gt;
&lt;br /&gt;
Find its device path with `ls /dev/ttyUSB* /dev/ttyACM*` (or similar); for the rest of this section we will refer to it as `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
You will also need a way of powering your Ox64. If your serial adapter has a 5V line, you can connect it to VBUS (pin 40). Otherwise, you can connect either the micro-B or the USB-C port on the Ox64 to any 5V power supply.&lt;br /&gt;
&lt;br /&gt;
WARNING: Your serial adapter must use 3.3V logic levels.&lt;br /&gt;
&lt;br /&gt;
Refer to the pinout image below. Connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; UART0_TX / GPIO14 / pin 1&lt;br /&gt;
* TX -&amp;gt; UART0_RX / GPIO15 / pin 2&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 3)&lt;br /&gt;
&lt;br /&gt;
Proceed with the instructions in the sections that follow, up to and including &amp;lt;&amp;lt;flashing_the_ox64&amp;gt;&amp;gt; and &amp;lt;&amp;lt;flashing_the_microsd_card&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM1` with `/dev/tty[DEVICE]`.&lt;br /&gt;
&lt;br /&gt;
Next, power off the Ox64 and re-connect your UART adapter as follows:&lt;br /&gt;
&lt;br /&gt;
* RX -&amp;gt; TXD / GPIO16 / pin 32&lt;br /&gt;
* TX -&amp;gt; RXD / GPIO17 / pin 31&lt;br /&gt;
* GND -&amp;gt; any ground (e. g. pin 33)&lt;br /&gt;
&lt;br /&gt;
Then, follow the instructions in &amp;lt;&amp;lt;booting_for_the_first_time&amp;gt;&amp;gt;, but replace all occurrences of `/dev/ttyACM0` with `/dev/tty[DEVICE]`. You should then have a working Linux system.&lt;br /&gt;
&lt;br /&gt;
== Download flashing tools&lt;br /&gt;
&lt;br /&gt;
You have a choice of flashing software:&lt;br /&gt;
&lt;br /&gt;
* DevCube: GUI-based closed source flashing tool&lt;br /&gt;
* CLI (`bflb-iot-tool`): command line open source flashing tool&lt;br /&gt;
&lt;br /&gt;
=== DevCube installation&lt;br /&gt;
&lt;br /&gt;
Download the latest DevCube flashing tool from BouffaloLab's website:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/devcube&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ unzip BouffaloLabDevCube-v1.8.9.zip&lt;br /&gt;
 $ chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
If you did not create a link:#optional_create_a_combined_soc_image[combined image] you may need an older version of the DevCube. In that case, download v1.8.3 from one of the mirrors below:&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192[] &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify that your copy of `BouffaloLabDevCube-v1.8.3.zip` matches the hashes below:&lt;br /&gt;
&lt;br /&gt;
* SHA1: `0f2619e87d946f936f63ae97b0efd674357b1166`&lt;br /&gt;
* SHA256: `e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913`&lt;br /&gt;
&lt;br /&gt;
=== CLI packages installation&lt;br /&gt;
&lt;br /&gt;
Install `bflb-iot-tool` using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows:&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt install pipenv # for Debian-based systems&lt;br /&gt;
  # or&lt;br /&gt;
 $ sudo pacman -S python-pipenv # for Arch Linux systems&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/&lt;br /&gt;
 $ pipenv install setuptools # install prerequisite of CLI flash tool&lt;br /&gt;
 $ pipenv install bflb-iot-tool # install CLI flash tool&lt;br /&gt;
 $ pipenv shell # activate virtual environment&lt;br /&gt;
 $ # bflb-iot-tool --help # return info about the tool&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTE: Each time you open a new terminal window you will need to `cd ~/ox64/` and re-run `pipenv shell` to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
== Flashing the Ox64&lt;br /&gt;
&lt;br /&gt;
Put the Ox64 into programming mode:&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
=== CLI flashing method&lt;br /&gt;
&lt;br /&gt;
Set up some environment variables to save typing them out later:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ PORT=/dev/ttyACM1&lt;br /&gt;
 $ BAUD=230400  # safe value for macOS, set to 2000000 for faster flashing on Linux&lt;br /&gt;
&lt;br /&gt;
Finally, flash the Ox64. If you created a link:#optional_create_a_combined_soc_image[combined image] then run the command below:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware bl808-combined.bin --single&lt;br /&gt;
&lt;br /&gt;
Otherwise, run the following commands:&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x0 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
&lt;br /&gt;
 $ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
&lt;br /&gt;
$ bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running any of the commands above, run `ls -l /dev/tty[DEVICE]`, to find out which group is allowed to talk to serial ports and add your user to that group, with `sudo usermod -a -G [GROUP] $USER` (i.e. `dialout` for Debian or `uucp` for Arch Linux). Make sure you re-login. Running the commands as `root` is not recommended since this will make `bflb-iot-tool` create root-owned files in your home directory. You can now run `exit` from virtual environment.&lt;br /&gt;
&lt;br /&gt;
=== BLDevCube flashing method&lt;br /&gt;
&lt;br /&gt;
Open a new terminal window to run the DevCube flasher:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/devcube&lt;br /&gt;
 $ ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish, and configure BOTH the [MCU] and [IOT] tabs as follows. When you switch between tabs double check that they still match the settings below:&lt;br /&gt;
&lt;br /&gt;
[cols=&amp;quot;~,~&amp;quot;]&lt;br /&gt;
|===&lt;br /&gt;
|Interface&lt;br /&gt;
|UART&lt;br /&gt;
&lt;br /&gt;
|Port/SN&lt;br /&gt;
|`/dev/ttyACM1`&lt;br /&gt;
&lt;br /&gt;
|UART rate&lt;br /&gt;
|230400 (safe value for macOS, set to 2000000 for faster flashing on Linux)&lt;br /&gt;
|===&lt;br /&gt;
&lt;br /&gt;
If you created a link:#optional_create_a_combined_soc_image[combined image] then you only need to use the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x0], [PATH to bl808-combined.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
Otherwise, start in the [MCU] tab:&lt;br /&gt;
&lt;br /&gt;
* M0 Group[group0], Image Address [0x58000000], [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
* D0 Group[group0], Image Address [0x58100000], [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Then, switch to the [IOT] tab:&lt;br /&gt;
&lt;br /&gt;
* Enable 'Single Download'&lt;br /&gt;
* Image Address [0x800000], [PATH to bl808-firmware.bin]&lt;br /&gt;
* Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
* Close DevCube&lt;br /&gt;
&lt;br /&gt;
== Erasing the microSD card&lt;br /&gt;
&lt;br /&gt;
Make sure there are no signatures or partitions left, and overwrite the first sectors with zeroes. You can find the target device under `lsblk` command.&lt;br /&gt;
&lt;br /&gt;
 $ sudo wipefs /dev/[DEVICE]&lt;br /&gt;
 $ sudo wipefs --all --force /dev/[DEVICE]*&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=1&lt;br /&gt;
&lt;br /&gt;
Optionally you can zeroes the whole device:&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/dev/zero of=/dev/[DEVICE] status=progress bs=32768 count=$(expr $(lsblk -bno SIZE /dev/[DEVICE] | head -1) \/ 32768)&lt;br /&gt;
&lt;br /&gt;
== Flashing the microSD card&lt;br /&gt;
&lt;br /&gt;
Insert the microSD card into your PC, locate its device under `lsblk` and write the image:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=sdcard.img of=/dev/[DEVICE] bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
== Booting for the first time&lt;br /&gt;
&lt;br /&gt;
Power off your Ox64 and insert the microSD card.&lt;br /&gt;
&lt;br /&gt;
Open a terminal window to connect to the D0 core’s (i.e. Linux’s) serial console:&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
If you are using a Pico or Bluepill as your serial adapter, open another terminal window to to monitor the M0 core’s serial console (reminder: `/dev/ttyACM1` is the same port we previously used for flashing):&lt;br /&gt;
&lt;br /&gt;
 $ minicom -b 2000000 -D /dev/ttyACM1&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64.&lt;br /&gt;
&lt;br /&gt;
On the main/D0 console (`/dev/ttyACM0`) you will see Linux booting up. When prompted, log in as `root` with no password. In case the SD card is missing or empty, you'll get a `Card did not respond to voltage select! : -110` error.&lt;br /&gt;
&lt;br /&gt;
On the M0 console (`/dev/ttyACM1`) you'll see following messages until the sytem is fully loaded:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[I][MBOX] Mailbox IRQ Stats:&lt;br /&gt;
[I][MBOX] Peripheral SDH (33): 0&lt;br /&gt;
[I][MBOX] Peripheral GPIO (60): 0&lt;br /&gt;
[I][MBOX] Unhandled Interupts: 0 Unhandled Signals 0&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Once the system is running, the &amp;quot;MBOX&amp;quot; logs will abruptly disappear and you'll be able to manage the M0 multimedia core, i.e. wifi settings, etc. When prompted, type `help` to see available commands.&lt;br /&gt;
&lt;br /&gt;
=== Connecting the Ox64 to your WiFi network&lt;br /&gt;
The simplest way to connect is to run the following command from the Linux console (i.e. `/dev/ttyACM0`):&lt;br /&gt;
&lt;br /&gt;
 $ blctl connect_ap &amp;lt;YourSSID&amp;gt; &amp;lt;YourPassword&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait for it to connect (if you're monitoring the M0 console on `/dev/ttyACM1` it should tell you when it's done), then run the following command from the Linux console:&lt;br /&gt;
&lt;br /&gt;
 $ udhcpc -i bleth0&lt;br /&gt;
 &lt;br /&gt;
Unfortunately the WiFi range leaves something to be desired. When you are performing the procedure above for the first time, move the Ox64 right next to your router. Once you are successfully connected, you can try experimenting with the maximum range.&lt;br /&gt;
&lt;br /&gt;
For more information on using the `blctl` command, see https://github.com/bouffalolab/blwnet_xram[here].&lt;br /&gt;
&lt;br /&gt;
== Appendix&lt;br /&gt;
&lt;br /&gt;
=== Adding Nuttx RTOS&lt;br /&gt;
&lt;br /&gt;
In this section, we will set up our Ox64 to dual-boot both Linux and the NuttX real-time operating system. For more information see the https://nuttx.apache.org/docs/latest/platforms/risc-v/bl808/boards/ox64/index.html[official documentation].&lt;br /&gt;
&lt;br /&gt;
First, write the normal Linux image to the SD card if you have not done so already. You can find the correct device under `lsblk`:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/openbouffalo/firmware # if you downloaded pre-built images&lt;br /&gt;
  # or&lt;br /&gt;
 $ cd ~/ox64/buildroot/output/images # if you built your own images&lt;br /&gt;
&lt;br /&gt;
 $ sudo dd if=/sdcard.img of=/dev/[DEVICE] bs=1M conv=fsync status=progress&lt;br /&gt;
&lt;br /&gt;
Run the following command to re-read the partition tables. Re-inserting the SD card works too:&lt;br /&gt;
&lt;br /&gt;
 $ sudo blockdev --rereadpt /dev/[DEVICE]&lt;br /&gt;
&lt;br /&gt;
Download the NuttX image:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64/nuttx&lt;br /&gt;
 $ cd ~/ox64/nuttx&lt;br /&gt;
 $ wget -O ImageNuttx https://github.com/lupyuen2/wip-pinephone-nuttx/releases/download/bl808d-1/Image&lt;br /&gt;
&lt;br /&gt;
Mount the boot partition and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]2 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/&lt;br /&gt;
 $ sudo tee -a /mnt/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Mount the rootfs and make the required modifications:&lt;br /&gt;
&lt;br /&gt;
 $ sudo mount /dev/[DEVICE]3 /mnt&lt;br /&gt;
 $ sudo cp ImageNuttx /mnt/boot/&lt;br /&gt;
 $ sudo tee -a /mnt/boot/extlinux/extlinux.conf &amp;lt;&amp;lt;EOF&lt;br /&gt;
 LABEL PINE64 OX64 Nuttx&lt;br /&gt;
        KERNEL ../ImageNuttx&lt;br /&gt;
        FDT ../bl808-pine64-ox64.dtb&lt;br /&gt;
 EOF&lt;br /&gt;
 $ sudo umount /mnt&lt;br /&gt;
&lt;br /&gt;
Enjoy your new Nuttx booting option!&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21476</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21476"/>
		<updated>2024-06-23T15:37:04Z</updated>

		<summary type="html">&lt;p&gt;Giorez: /* Build */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 $ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 $ cd ~/ox64/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 $ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 $ make menuconfig&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
 $ make&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.8 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21475</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21475"/>
		<updated>2024-06-23T15:34:45Z</updated>

		<summary type="html">&lt;p&gt;Giorez: /* Build */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
$ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
$ cd ~/ox64/buildroot&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
$ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
$ make menuconfig&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
$ make&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.8 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21474</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21474"/>
		<updated>2024-06-23T15:34:02Z</updated>

		<summary type="html">&lt;p&gt;Giorez: /* Build */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Start the building process cloning both the upstream Buildroot repository and the Buildroot Bouffalo overlay repository:&lt;br /&gt;
&lt;br /&gt;
[source,console]&lt;br /&gt;
----&lt;br /&gt;
 $ mkdir -p ~/ox64&lt;br /&gt;
 $ cd ~/ox64&lt;br /&gt;
 $ git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 $ git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
[source,console]&lt;br /&gt;
----&lt;br /&gt;
$ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
[source,console]&lt;br /&gt;
----&lt;br /&gt;
$ cd ~/ox64/buildroot&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
[source,console]&lt;br /&gt;
----&lt;br /&gt;
$ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Use the `menuconfig` tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
[source,console]&lt;br /&gt;
----&lt;br /&gt;
$ make menuconfig&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Within `menuconfig`, configure the following:&lt;br /&gt;
&lt;br /&gt;
* Select `Target Options`&lt;br /&gt;
* Enable `Integer Multiplication and Division (M)`&lt;br /&gt;
* Enable `Atomic Instructions (A)` using space key&lt;br /&gt;
* Enable `Single-precision Floating-point (F)`&lt;br /&gt;
* Enable `Double-precision Floating-point (D)`&lt;br /&gt;
* Select `Target ABI`, set it to `lp64d` and `press Exit`&lt;br /&gt;
* Select `Toolchain`, enable `Fortran support`, enable `OpenMP support`, and Save &amp;amp; Exit&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but first make sure that your `PATH` variable contains no spaces. For Arch Linux distrubution you may also need to install extra-packages with `sudo pacman -S cpio rsync bc`.&lt;br /&gt;
&lt;br /&gt;
[source,console]&lt;br /&gt;
----&lt;br /&gt;
$ make&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Buildroot will output the needed files to the `~/ox64/buildroot/output/images` directory in about 1 hour, according to your computer processing resources and internet connection speed.&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.8 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21394</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21394"/>
		<updated>2024-01-19T02:17:23Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
 # make clean # deletes all the already compiled object files&lt;br /&gt;
 # make new # and it will recompile everything again&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.8 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x200000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x800000     0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21393</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21393"/>
		<updated>2024-01-19T01:33:03Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
 # make clean # deletes all the already compiled object files&lt;br /&gt;
 # make new # and it will recompile everything again&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.8 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21392</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21392"/>
		<updated>2024-01-19T01:32:24Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
 # make clean # deletes all the already compiled object files&lt;br /&gt;
 # make new # and it will recompile everything again&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.8 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21391</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21391"/>
		<updated>2024-01-19T00:52:56Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
 # make clean # deletes all the already compiled object files&lt;br /&gt;
 # make new # and it will recompile everything again&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* TESTING https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21390</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21390"/>
		<updated>2024-01-19T00:52:03Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
 # make clean # deletes all the already compiled object files&lt;br /&gt;
 # make new # and it will recompile everything again&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
# * https://dev.bouffalolab.com/media/upload/download/BouffaloLabDevCube-v1.8.8.zip&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21389</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21389"/>
		<updated>2024-01-19T00:17:48Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
 # make clean # deletes all the already compiled object files&lt;br /&gt;
 # make new # and it will recompile everything again&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv python3.11-venv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21388</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21388"/>
		<updated>2024-01-18T23:18:25Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
 # make clean # deletes all the already compiled object files&lt;br /&gt;
 # make new # and it will recompile everything again&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21387</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21387"/>
		<updated>2024-01-18T22:49:14Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21386</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21386"/>
		<updated>2024-01-18T22:40:34Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 sudo make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 sudo make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Options &amp;gt; Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 sudo make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21385</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21385"/>
		<updated>2024-01-18T22:29:45Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 sudo make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 sudo make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 sudo make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21384</id>
		<title>Ox64</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Ox64&amp;diff=21384"/>
		<updated>2024-01-18T22:23:52Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Ox64_board.jpg|thumb|right|The Ox64]]&lt;br /&gt;
[[File:Ox64 pinout.png|thumb|Pinout of the production version]]&lt;br /&gt;
[[File:RISC-V.png|thumb|right|Powered by RISC-V]]&lt;br /&gt;
&lt;br /&gt;
The '''Ox64''' is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.&lt;br /&gt;
&lt;br /&gt;
== Software Releases ==&lt;br /&gt;
&lt;br /&gt;
=== Quick Links to the Source of OS Images Build ===&lt;br /&gt;
&lt;br /&gt;
There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/openbouffalo/buildroot_bouffalo buildroot] bringing all the work below together with a bootable kernel and updated filesystem images for SD cards &lt;br /&gt;
* [https://github.com/smaeul/u-boot/tree/bl808 U-Boot] and [https://github.com/smaeul/opensbi/tree/bl808 OpenSBI] work by Smauel&lt;br /&gt;
* [https://github.com/arm000/linux-bl808/tree/linux-next/mboxic Kernel] IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others&lt;br /&gt;
* [https://github.com/openbouffalo/OBLFR OpenBouffalo Firmware] low_load drivers by Fishwaldo and others&lt;br /&gt;
&lt;br /&gt;
Original Linux Images provided by Bouffalo - Very basic '''alpha build''' which are only fit for board bring up and testing purposes. &lt;br /&gt;
&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux Linux for BL808]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808.pdf Installation Instructions for Linux on BL808 (Chinese)]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Linux_BL808_en.pdf Installation Instructions for Linux on BL808 (machine translated to English)]&lt;br /&gt;
&lt;br /&gt;
Toolchain:&lt;br /&gt;
&lt;br /&gt;
* elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0&lt;br /&gt;
* linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0&lt;br /&gt;
* cmake version 3.19.3&lt;br /&gt;
&lt;br /&gt;
=== Software Development Kits ===&lt;br /&gt;
* [https://github.com/bouffalolab/bl_mcu_sdk BL808 MCU SDK]&lt;br /&gt;
* [https://dev.bouffalolab.com/download BLDevCube Flashing Tool for Windows, macOS and Ubuntu x64]&lt;br /&gt;
* [https://wiki.pine64.org/wiki/File:Ox64_BL808UART_connect.pdf Ox64 UART Flashing Guide], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/bl808_demo_event.bin BL808 Demo Firmware: bl808_demo_event.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/whole_flash_data.bin BL808 UART Log Firmware: whole_flash_data.bin], see the [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff notes]&lt;br /&gt;
* [https://github.com/lupyuen/lupyuen.github.io/releases/download/ox64/BL808.DVK.Quick.Start.pdf BL808 DVK Quick Start]&lt;br /&gt;
* [https://github.com/bouffalolab/bl808_linux/tree/main/opensbi-0.6-808 OpenSBI for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/tree/main/bl808 Rust Peripheral Access Crate (PAC) for BL808]&lt;br /&gt;
* [https://github.com/bouffalolab/bl-pac/blob/main/bl808/bl808.svd System View Description (SVD) for BL808]&lt;br /&gt;
&lt;br /&gt;
== SoC and Memory Specification ==&lt;br /&gt;
&lt;br /&gt;
[[File:Bouffalo_Lab_icon.png|right]]&lt;br /&gt;
&lt;br /&gt;
Based on the [https://en.bouffalolab.com/product/ Bouffalo Lab BL808]&lt;br /&gt;
&lt;br /&gt;
[[File:BL808_Block_Diagram.jpg|500px]]&lt;br /&gt;
&lt;br /&gt;
=== CPU Architecture ===&lt;br /&gt;
&lt;br /&gt;
[[File:T-Head.png|right|200px]]&lt;br /&gt;
&lt;br /&gt;
T-Head C906 480 MHz 64-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV64IMAFCV instruction architecture&lt;br /&gt;
* Five-stage single-issue sequentially executed pipeline&lt;br /&gt;
* Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B&lt;br /&gt;
* Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management&lt;br /&gt;
* jTLB that supports 128 entries&lt;br /&gt;
* Supports AXI 4.0 128-bit master interface&lt;br /&gt;
* Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)&lt;br /&gt;
* With 80 external interrupt sources, 3 bits for configuring interrupt priority&lt;br /&gt;
* Supports BHT (8K) and BTB&lt;br /&gt;
* Compatible with RISC-V PMP, 8 configurable areas&lt;br /&gt;
* Supports hardware performance monitor (HPM) units&lt;br /&gt;
* See [https://www.t-head.cn/product/c906?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E907 320 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* Supports RISC-V RV32IMAFCP instruction set&lt;br /&gt;
* Supports RISC-V 32-bit/16-bit mixed instruction set&lt;br /&gt;
* Supports RISC-V machine mode and user mode&lt;br /&gt;
* Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs&lt;br /&gt;
* Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline&lt;br /&gt;
* Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface&lt;br /&gt;
* 32K instruction cache, two-way set associative structure&lt;br /&gt;
* 16K data cache, two-way set associative structure&lt;br /&gt;
* See [https://www.t-head.cn/product/e907?lang=en here]&lt;br /&gt;
&lt;br /&gt;
T-Head E902 150 MHz 32-bit RISC-V CPU:&lt;br /&gt;
&lt;br /&gt;
* See [https://www.t-head.cn/product/e902?lang=en here]&lt;br /&gt;
&lt;br /&gt;
=== System Memory ===&lt;br /&gt;
* Embedded 64MB PSRAM&lt;br /&gt;
&lt;br /&gt;
== Board Features ==&lt;br /&gt;
&lt;br /&gt;
=== Network ===&lt;br /&gt;
* 2.4 GHz 1T1R WiFi 802.11 b/g/n&lt;br /&gt;
* Bluetooth 5.2&lt;br /&gt;
* Zigbee&lt;br /&gt;
* 10/100 Mbit/s Ethernet (optional, on expansion board)&lt;br /&gt;
&lt;br /&gt;
=== Storage ===&lt;br /&gt;
* On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory&lt;br /&gt;
* MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)&lt;br /&gt;
&lt;br /&gt;
=== Expansion Ports ===&lt;br /&gt;
* USB 2.0 OTG port&lt;br /&gt;
* 26 GPIO pins, including SPI, I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;C and UART functionality, possible I&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;S and GMII expansion&lt;br /&gt;
* Dual-lane MiPi CSI port, located at USB-C port, for camera module&lt;br /&gt;
&lt;br /&gt;
=== Audio ===&lt;br /&gt;
* Microphone (optional, on the camera module)&lt;br /&gt;
* Speaker (optional, on the camera module)&lt;br /&gt;
&lt;br /&gt;
== Board Information, Schematics and Certifications ==&lt;br /&gt;
[[File:Ox64 ethphy.png|thumb|Pinout for wiring ethernet PHY to EMAC]]&lt;br /&gt;
&lt;br /&gt;
* Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)&lt;br /&gt;
* Input power: 5 V, 0.5 A through the microUSB or USB-C ports&lt;br /&gt;
&lt;br /&gt;
Production version schematic:&lt;br /&gt;
&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221018.pdf Ox64 Schematic 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221018.pdf Ox64 PCB Component placement(ToP) 20221018 v1.1]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221018.pdf Ox64 PCB Component placement(Bottom) 20221018 v1.1]&lt;br /&gt;
&lt;br /&gt;
Prototype (dispatched to developers) schematic:&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64-Schematic-202221007.pdf Ox64 Schematic 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Top-20221007.pdf Ox64 PCB Component placement(ToP) 20221007 v1.0]&lt;br /&gt;
* [https://files.pine64.org/doc/ox64/PINE64_Ox64_PCB_Placement-Bottom-20221007.pdf Ox64 PCB Component placement(Bottom) 20221007 v1.0]&lt;br /&gt;
&lt;br /&gt;
Certifications:&lt;br /&gt;
* Disclaimer: Please note that PINE64 SBC is not a &amp;quot;final&amp;quot; product and in general certification is not necessary.&lt;br /&gt;
* Not yet available&lt;br /&gt;
&lt;br /&gt;
== Datasheets for Components and Peripherals ==&lt;br /&gt;
&lt;br /&gt;
Bouffalo BL808 SoC information:&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_DS/en/BL808_DS_1.2_en.pdf Bouffalo Lab BL808 SoC Datasheet]&lt;br /&gt;
* [https://raw.githubusercontent.com/bouffalolab/bl_docs/main/BL808_RM/en/BL808_RM_en_1.3.pdf Bouffalo Lab BL808 SoC Reference Manual]&lt;br /&gt;
&lt;br /&gt;
SPI NOR Flash information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/gd25lq16e_rev1.2_20210108.pdf GigaDevice 16Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/star64/gd25lq128e_rev1.0_20210513.pdf GigaDevice 128Mb XSPI-Flash Datasheet]&lt;br /&gt;
* [https://wiki.pine64.org/images/5/5d/W25Q128JW_RevB_11042019-1761358.pdf Winbond 128Mb QSPI-Flash Datasheet] (W25Q128JWSQ)&lt;br /&gt;
&lt;br /&gt;
Power Regulator information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/IA2014-03.pdf Innovation Analog Tech IA2014 Step_down Converter Datasheet]&lt;br /&gt;
&lt;br /&gt;
MicroSD socket information:&lt;br /&gt;
* [https://files.pine64.org/doc/datasheet/ox64/TF%20PUSH%20type%20socket%20specification.pdf Push type microSD socket specification]&lt;br /&gt;
&lt;br /&gt;
== Compatible UARTs when in bootloader mode ==&lt;br /&gt;
&lt;br /&gt;
When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see &amp;quot;Shake hand fail&amp;quot; and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.&lt;br /&gt;
&lt;br /&gt;
The below devices have been tested and verified as working:&lt;br /&gt;
* Raspberry Pi Pico - running the following [https://github.com/sanjay900/ox64-uart/releases/tag/v1.1 UART firmware] (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)&lt;br /&gt;
* Compiled binary for Pi Pico and connectivity diagram is [https://github.com/Kris-Sekula/Pine64_Ox64_SBC/tree/main/uart here] &lt;br /&gt;
* ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)&lt;br /&gt;
* Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.&lt;br /&gt;
* STM32F401 BlackPill - running the [https://github.com/blackmagic-debug/blackmagic/tree/main/src/platforms/blackpillv2 Black Magic Debug] firmware&lt;br /&gt;
* STM32F103C8T6 BluePill - running Black Magic Debug.&lt;br /&gt;
* Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)&lt;br /&gt;
* Some CH340G based adapters work and some don't.&lt;br /&gt;
&lt;br /&gt;
== Resources and Articles ==&lt;br /&gt;
* [https://youtube.com/watch?v=czRtF-UNiEY A short video] on how to connect to the Ox64, flash and boot&lt;br /&gt;
* [https://youtu.be/vPAk5sq_Ilc Another video] that covers soldering pins, connecting via Pi Pico and flashing Linux and U-Boot&lt;br /&gt;
* [https://wiki.pine64.org/images/5/59/How_to_Run_Ox64.pdf Step-by-step tutorial] for how to build, flash and run Ox64&lt;br /&gt;
* [https://gist.github.com/lupyuen/7a0c697b89abccda8e38b33dfe5ebaff First batch of Ox64 won't appear as USB serial port]&lt;br /&gt;
* [https://gist.github.com/lupyuen/2087e9b3fb40aab5e0795bb02a265a3b First batch of Ox64 tested OK with CH340C/G]&lt;br /&gt;
* [https://www.robertlipe.com/bl808-not-symmetric/ First thoughts on the (a)symmetry of Bouffalo Labs BL808 as in Pine64 Ox64]&lt;br /&gt;
* [https://thelittleengineerthatcould.blogspot.com/2022/12/the-8-linux-computer-part-2.html The $8 linux computer (with picoprobe-rp2040 programming instructions)]&lt;br /&gt;
* [https://github.com/p4ddy1/pine_ox64/blob/main/build_toolchain_macos.md Building the Xuantie GNU Toolchain for Ox64 on macOS and Apple Silicon]&lt;br /&gt;
&lt;br /&gt;
Ox64 BL808 RISC-V SBC articles by [https://lupyuen.codeberg.page/ Lup Yuen LEE]:&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox64.html Booting Linux and (maybe) Apache NuttX RTOS]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/ox2.html Starting Apache NuttX real-time operating system]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/mmu.html Sv39 Memory Management Unit]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/app.html NuttX Apps and Initial RAM Disk]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic2.html UART Interrupt and Platform-Level Interrupt Controller (PLIC)]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/plic3.html Fixing the UART Interrupt and Platform-Level Interrupt Controller]&lt;br /&gt;
* [https://www.hackster.io/lupyuen/8-risc-v-sbc-on-a-real-time-operating-system-ox64-nuttx-474358 $8 RISC-V SBC on a Real-Time Operating System: Ox64 + NuttX]&lt;br /&gt;
* [https://lupyuen.codeberg.page/articles/nim.html Nim on a Real-Time Operating System: Apache NuttX RTOS + Ox64 BL808 SBC]&lt;br /&gt;
&lt;br /&gt;
Git repositories:&lt;br /&gt;
* [https://github.com/sfranzyshen/arduino-bl808 Community made Arduino Core specifically for the Bouffalo Labs BL808 RISC-V MCU] (initial development has been postponed until further notice)&lt;br /&gt;
&lt;br /&gt;
== Development Efforts ==&lt;br /&gt;
* [https://twitter.com/gamelaster/status/1583916501400068096 Ox64 boots Linux successfully]&lt;br /&gt;
* [https://twitter.com/btashton/status/1586381334439923713?t=w5xRRUR74HGK2O1Zg_aFyw&amp;amp;s=19 Brennan Ashton is porting Apache NuttX RTOS and OpenAMP (Asymmetric Multiprocessing) to BL808]&lt;br /&gt;
* [https://twitter.com/thanos_engine/status/1585153938092761093 Phone Concept for BL808]&lt;br /&gt;
&lt;br /&gt;
== Build==&lt;br /&gt;
Open the terminal and create a new directory for the build:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir buildroot_bouffalo &amp;amp;&amp;amp; cd buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/buildroot/buildroot&lt;br /&gt;
 git clone https://github.com/openbouffalo/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Define an environment variable for the Buildroot Bouffalo overlay path:&lt;br /&gt;
&lt;br /&gt;
 export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo&lt;br /&gt;
&lt;br /&gt;
Change directory into the cloned Buildroot folder:&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot&lt;br /&gt;
&lt;br /&gt;
Apply the default configuration for Pine64 Ox64:&lt;br /&gt;
&lt;br /&gt;
 make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt; tool to adjust the build settings:&lt;br /&gt;
&lt;br /&gt;
 make menuconfig&lt;br /&gt;
&lt;br /&gt;
[[File:target ABI setting.png|thumb|right|200px|target ABI setting]]&lt;br /&gt;
[[File:toolchain setting.png|thumb|right|200px|toolchain setting]]&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;menuconfig&amp;lt;/code&amp;gt;, configure the following:&lt;br /&gt;
* Navigate to &amp;lt;code&amp;gt;Target Architecture&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Integer Multiplication and Division (M)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Atomic Instructions (A)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Single-precision Floating-point (F)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Enable &amp;lt;code&amp;gt;Double-precision Floating-point (D)&amp;lt;/code&amp;gt;&lt;br /&gt;
* Set &amp;lt;code&amp;gt;Target ABI&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;lp64d&amp;lt;/code&amp;gt;&lt;br /&gt;
* Under &amp;lt;code&amp;gt;Toolchain&amp;lt;/code&amp;gt;, enable &amp;lt;code&amp;gt;Fortran support&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;OpenMP support&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initiate the build process, but make sure first that your &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; variable contains no spaces:&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
You will get the image files required for flashing in the &amp;lt;code&amp;gt;output/images&amp;lt;/code&amp;gt; directory&lt;br /&gt;
&lt;br /&gt;
== Flashing Ox64 SBC and microSD Card ==&lt;br /&gt;
This section explains how to flash an Ox64 board and a microSD card to boot the system.&lt;br /&gt;
&lt;br /&gt;
=== Prepare the Environment === &lt;br /&gt;
You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.&lt;br /&gt;
&lt;br /&gt;
Start a terminal session and set the working directory to download some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 mkdir ox64 ox64/pico&lt;br /&gt;
 cd ~/Downloads/ox64/pico&lt;br /&gt;
 wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir ox64/devcube183&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
&lt;br /&gt;
Get the DevCube 1.8.3 flasher from one of mirror servers listed below.&lt;br /&gt;
&lt;br /&gt;
* https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://hachyderm.io/@mkroman/110787218805897192 &amp;gt; https://pub.rwx.im/~mk/bouffalolab/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
* https://we.tl/t-eJWShQJ4iF&lt;br /&gt;
* https://cdn.discordapp.com/attachments/771032441971802142/1145565853962735639/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
&lt;br /&gt;
Verify the file hashes listed below.&lt;br /&gt;
&lt;br /&gt;
* SHA1: &amp;lt;code&amp;gt;0f2619e87d946f936f63ae97b0efd674357b1166&amp;lt;/code&amp;gt;&lt;br /&gt;
* SHA256: &amp;lt;code&amp;gt;e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, uncompress the downloaded archive; for example:&lt;br /&gt;
&lt;br /&gt;
 wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 sha256sum BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 unzip BouffaloLabDevCube-v1.8.3.zip&lt;br /&gt;
 chmod u+x BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.&lt;br /&gt;
&lt;br /&gt;
(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64&lt;br /&gt;
 mkdir openbouffalo &amp;amp;&amp;amp; cd openbouffalo&lt;br /&gt;
 wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
 tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz&lt;br /&gt;
&lt;br /&gt;
You'll need the following files for the flashing process.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;m0_lowload_bl808_m0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;d0_lowload_bl808_d0.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;bl808-firmware.bin&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;sdcard.img&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Establish Serial Communication from PC to Ox64 using Pi Pico ===&lt;br /&gt;
Open a terminal and check the connected USB serial devices.&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyACM*&lt;br /&gt;
&lt;br /&gt;
Set the Raspberry Pi Pico board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BootSel button&lt;br /&gt;
* Apply power by plugging the USB cable to PC&lt;br /&gt;
* Release the BootSel button&lt;br /&gt;
&lt;br /&gt;
''Note: you could also ground pin28 to TP6 while powering.''&lt;br /&gt;
&lt;br /&gt;
Copy &amp;lt;code&amp;gt;picoprobe.uf2&amp;lt;/code&amp;gt; file into the new device &amp;lt;code&amp;gt;/media/&amp;lt;user&amp;gt;/RPI-RP2&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/&amp;lt;user&amp;gt;/RPI-RP2&lt;br /&gt;
&lt;br /&gt;
After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.&lt;br /&gt;
&lt;br /&gt;
[[File:Pine Serial v2.png|thumb|right|Wiring Raspberry Pi Pico to Pine64 Ox64 SBC]]&lt;br /&gt;
&lt;br /&gt;
 OX64                      PI PICO&lt;br /&gt;
 uart0_Tx_GPIO14_pin1 &amp;lt;-&amp;gt;  uart0_Rx_pin17&lt;br /&gt;
 uart0_Rx_GPIO15_pin2 &amp;lt;-&amp;gt;  uart0_Tx_pin16&lt;br /&gt;
 Rxd_GPIO17_pin31     &amp;lt;-&amp;gt;  uart1_Tx_pin6&lt;br /&gt;
 Txd_GPIO16_pin32     &amp;lt;-&amp;gt;  uart1_Rx_pin7 &lt;br /&gt;
 gnd_pin38            &amp;lt;-&amp;gt;  gnd_pin38/3    &lt;br /&gt;
 vbus5v_pin40         &amp;lt;-&amp;gt;  vbus5v_pin40&lt;br /&gt;
&lt;br /&gt;
=== Flash Your Ox64 === &lt;br /&gt;
There are two new ports to choose from, &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; for serial console and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt; for DevCube flashing.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Set the Ox64 board into programming mode.&lt;br /&gt;
&lt;br /&gt;
* Press the BOOT button&lt;br /&gt;
* Apply power or re-plug the USB cable&lt;br /&gt;
* Release the BOOT button&lt;br /&gt;
&lt;br /&gt;
Close &amp;lt;code&amp;gt;minicom&amp;lt;/code&amp;gt;. Open a new terminal window to run the DevCube flasher.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/devcube183&lt;br /&gt;
 ./BLDevCube-ubuntu&lt;br /&gt;
&lt;br /&gt;
Select chip [BL808], press Finish and switch to [MCU] tab.&lt;br /&gt;
&lt;br /&gt;
 M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]&lt;br /&gt;
 D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]&lt;br /&gt;
 Interface: UART&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use /dev/ttyACM0, it's used by the minicom console)&lt;br /&gt;
 Uart rate 2000000&lt;br /&gt;
 UART TX is physical pin 1/GPIO 14.&lt;br /&gt;
 UART RX is physical pin 2/GPIO 15.&lt;br /&gt;
 Click 'Create &amp;amp; Download' and wait until it's done&lt;br /&gt;
&lt;br /&gt;
Switch to the [IOT] tab.&lt;br /&gt;
&lt;br /&gt;
 Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]&lt;br /&gt;
 Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)&lt;br /&gt;
 Click 'Create &amp;amp; Download' again and wait until it's done&lt;br /&gt;
 Close DevCube&lt;br /&gt;
&lt;br /&gt;
==== Open-Source Flashing Using CLI ====&lt;br /&gt;
For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bflb-mcu-tool&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
''Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.''&lt;br /&gt;
&lt;br /&gt;
First, install &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; using your preferred method of managing PIP packages. One option is to set up a Python virtual environment as follows.&lt;br /&gt;
&lt;br /&gt;
 sudo apt install virtualenv python3-virtualenv&lt;br /&gt;
 python3 -m venv ~/ox64_venv&lt;br /&gt;
 . ~/ox64_venv/bin/activate&lt;br /&gt;
 pip install bflb-iot-tool ''# we are *not* using bflb-mcu-tool''&lt;br /&gt;
&lt;br /&gt;
Note that each time you open a new terminal window you will need to re-run &amp;lt;code&amp;gt;. ~/ox64_venv/bin/activate&amp;lt;/code&amp;gt; to reactivate the virtual environment.&lt;br /&gt;
&lt;br /&gt;
Next, put Ox64 in programming mode (press the BOOT button when first applying power) and flash the BL808.&lt;br /&gt;
&lt;br /&gt;
 PORT=/dev/ttyACM1 ''# this will depend on which serial adapter you use''&lt;br /&gt;
 BAUD=115200       ''# safe value for macOS, if using Linux set to 2000000 for faster flashing''&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 &lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x000000 --firmware m0_lowload_bl808_m0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x100000 --firmware d0_lowload_bl808_d0.bin --single&lt;br /&gt;
 bflb-iot-tool --chipname bl808 --interface uart --port $PORT --baudrate $BAUD --addr 0x800000 --firmware bl808-firmware.bin --single&lt;br /&gt;
&lt;br /&gt;
If you get permission errors when running the commands above, you may need to add your user to the &amp;lt;code&amp;gt;dialout&amp;lt;/code&amp;gt; group. Running the commands as &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt; is not recommended since this will make &amp;lt;code&amp;gt;bflb-iot-tool&amp;lt;/code&amp;gt; create &amp;lt;code&amp;gt;root&amp;lt;/code&amp;gt;-owned files in your home directory.&lt;br /&gt;
&lt;br /&gt;
==== BL808 Address Details ====&lt;br /&gt;
Note that the addresses are different according to the flashing method, DevCube or CLI.&lt;br /&gt;
&lt;br /&gt;
              DevCube      CLI   &lt;br /&gt;
 M0 address   0x58000000   0x000000&lt;br /&gt;
 D0 address   0x58100000   0x100000&lt;br /&gt;
 LP address   0x58200000   0x200000&lt;br /&gt;
&lt;br /&gt;
=== Flash Your microSD Card ===&lt;br /&gt;
Insert microSD card into PC, locate its device file (&amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt;, for example), erase the start of the card and proceed to flashing.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ox64/buildroot_bouffalo/buildroot/output/images&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 &lt;br /&gt;
 sudo dd if=sdcard.img of=/dev/sdb bs=1M status=progress conv=fsync&lt;br /&gt;
&lt;br /&gt;
=== Booting for the First Time ===&lt;br /&gt;
Insert microSD card into Ox64 and set a UART connection to the Ox64 board, using the following parameters.&lt;br /&gt;
&lt;br /&gt;
* UART TX is physical pin 32/GPIO 16&lt;br /&gt;
* UART RX is physical pin 31/GPIO 17&lt;br /&gt;
* Baud rate is 2000000&lt;br /&gt;
&lt;br /&gt;
Choose from serial devices &amp;lt;code&amp;gt;/dev/ttyACM0&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/ttyACM1&amp;lt;/code&amp;gt;, using the lower number.&lt;br /&gt;
&lt;br /&gt;
 minicom -b 2000000 -D /dev/ttyACM0&lt;br /&gt;
&lt;br /&gt;
Re-apply power to the Ox64 and enjoy the booting!&lt;br /&gt;
&lt;br /&gt;
[[Category:Ox64]]&lt;br /&gt;
[[Category:Bouffalo BL808]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21372</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21372"/>
		<updated>2024-01-11T02:05:21Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
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&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 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&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21371</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21371"/>
		<updated>2024-01-11T01:52:56Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
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&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 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&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21370</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21370"/>
		<updated>2024-01-11T00:55:29Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
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&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 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&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21369</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21369"/>
		<updated>2024-01-10T23:03:53Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
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&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 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&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21368</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21368"/>
		<updated>2024-01-10T22:55:36Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
If you don't build image via bootatrap (as for other distros), download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 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&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21367</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21367"/>
		<updated>2024-01-10T22:53:21Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
If you don't build image via bootatrap (as for other distros), download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 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&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21366</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21366"/>
		<updated>2024-01-10T22:48:04Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
---&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 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&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Download, decompress, mount the image. Copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21365</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21365"/>
		<updated>2024-01-10T22:32:11Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21364</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21364"/>
		<updated>2024-01-10T22:07:36Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21363</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21363"/>
		<updated>2024-01-10T21:27:56Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21362</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21362"/>
		<updated>2024-01-10T19:32:18Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *rchlinux*.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *anjaro*.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *obian*.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *ostmarket*.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *buntu*.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21361</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21361"/>
		<updated>2024-01-10T19:31:35Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *rchlinux*.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *anjaro*.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *obian*.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *ostmarket*.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *buntu*.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/ubuntusd/boot/extlinux/extlinux.conf&lt;br /&gt;
 &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
 &amp;gt;menu label UT&lt;br /&gt;
 &amp;gt;linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
 &amp;gt;fdtdir /boot/dtb-6.5.0-okpine-ut//rockchip/&lt;br /&gt;
 &lt;br /&gt;
 &amp;gt;#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&lt;br /&gt;
 &amp;gt;APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21360</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21360"/>
		<updated>2024-01-10T19:12:11Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *rchlinux*.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *anjaro*.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *obian*.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *ostmarket*.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *buntu*.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21359</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21359"/>
		<updated>2024-01-10T19:07:14Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *rchlinux*.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *anjaro*.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *obian*.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *ostmarket*.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *buntu*.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21358</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21358"/>
		<updated>2024-01-10T18:56:40Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *rchlinux*.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *anjaro*.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *obian*.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *ostmarket*.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *buntu*.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/rockchip/&lt;br /&gt;
&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21357</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21357"/>
		<updated>2024-01-10T13:08:28Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *rchlinux*.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *anjaro*.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *obian*.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *ostmarket*.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *buntu*.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21356</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21356"/>
		<updated>2024-01-09T20:36:15Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21355</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21355"/>
		<updated>2024-01-09T20:33:37Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 sudo scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/ubuntutouchsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21354</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21354"/>
		<updated>2024-01-09T20:16:38Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketos-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21353</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21353"/>
		<updated>2024-01-09T20:11:59Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.6-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.6-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.6-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  &amp;gt;# append root=UUID=b282b619-c9b7-4c15-9c3d-2005b35d5999 consoleblank=0 loglevel=7 ro quiet splash plymouth.ignore-serial&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Ctrl+X to save, Yes, Enter.&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21352</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21352"/>
		<updated>2024-01-09T20:07:45Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
 sudo chmod a=rwx /mnt/mobiansd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/mobiansd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21351</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21351"/>
		<updated>2024-01-09T19:57:48Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21350</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21350"/>
		<updated>2024-01-09T19:55:02Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 sudo mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 sudo mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 sudo scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 sudo mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 sudo mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 sudo scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 sudo mkdir /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/postmarketossd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 sudo mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 sudo mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21349</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21349"/>
		<updated>2024-01-09T19:33:45Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21348</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21348"/>
		<updated>2024-01-09T19:32:05Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 sudo mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 sudo mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 sudo scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 sudo mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/manjarosd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21347</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21347"/>
		<updated>2024-01-09T19:27:43Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu-touch-pinephone-pro-img-arm64.raw ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 chmod -R a=rwx /mnt/*&lt;br /&gt;
 scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 mkdir /mnt/manjarosd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21346</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21346"/>
		<updated>2024-01-09T19:21:43Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 chmod -R a=rwx /mnt/*&lt;br /&gt;
 scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 mkdir /mnt/manjarosd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /mnt/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 rm -r /mnt/*/* &amp;amp;&amp;amp; sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21345</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21345"/>
		<updated>2024-01-09T19:17:09Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 chmod -R a=rwx /mnt/*&lt;br /&gt;
 scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 mkdir /mnt/manjarosd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21344</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21344"/>
		<updated>2024-01-09T19:15:09Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux &amp;amp;&amp;amp; sudo chmod a=rwx /mnt/archlinuxsd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 chmod -R a=rwx /mnt/*&lt;br /&gt;
 scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 mkdir /mnt/manjarosd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21343</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21343"/>
		<updated>2024-01-09T19:11:29Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 sudo cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 chmod -R a=rwx /mnt/*&lt;br /&gt;
 scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 mkdir /mnt/manjarosd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21342</id>
		<title>PinePhone Pro/Create a multi-distribution image using rk2aw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=PinePhone_Pro/Create_a_multi-distribution_image_using_rk2aw&amp;diff=21342"/>
		<updated>2024-01-09T19:10:45Z</updated>

		<summary type="html">&lt;p&gt;Giorez: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article explains how to create a multi-distribution image on the [[PinePhone Pro]] using ''rk2aw''.&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on microSD Card ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Connect PinePhone Pro to a Linux machine, start a ssh connection and download installer to flash pre-loader to the phone's SPI.&lt;br /&gt;
&lt;br /&gt;
 ssh &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;&lt;br /&gt;
 cd ~/Downloads&lt;br /&gt;
 curl -O https://xff.cz/kernels/bootloaders/ppp.tar.gz&lt;br /&gt;
 tar -xvzf ppp.tar.gz -C ~/Downloads&lt;br /&gt;
 # scp -r ~/Downloads/ppp &amp;lt;user&amp;gt;@&amp;lt;phoneip&amp;gt;:~/Downloads'' # copy to phone, non needed''&lt;br /&gt;
 cd ppp&lt;br /&gt;
 sudo ./spinor-flash-initial-setup.sh&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro on the microSD card ===&lt;br /&gt;
&lt;br /&gt;
If necessary wipe the microSD card &lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 status=progress'' # quick way i.e. # 32GB SDcard (30989615104bytes/32768dim=1volta)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=945728 bs=32768 status=progress'' # slow way i.e. # 32GB SDcard (30989615104bytes/32768dim=945728volte)''&lt;br /&gt;
 sudo dd if=/dev/zero of=/dev/sdb count=15271040 bs=4096 status=progress'' # 63GB SDcard (62550179840bytes/512dim=122168320volte)''&lt;br /&gt;
 sudo shred -n 5 -vz /dev/sdb # 6 scritture 12h x 64gb&lt;br /&gt;
&lt;br /&gt;
Before removing partitions, if you need to remove also left signatures, use gParted and format each partition &amp;quot;cleared&amp;quot;. Than remove all partitions with gParted.&lt;br /&gt;
&lt;br /&gt;
 sudo wipefs /dev/sdb # shows current signatures&lt;br /&gt;
 sudo wipefs --all --force /dev/sdb # erase current signatures&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Partition the microSD card ====&lt;br /&gt;
&lt;br /&gt;
{{Info|A minimum capacity of 64 GB for the microSD card is recommended for 5 distributions.}}&lt;br /&gt;
&lt;br /&gt;
 sudo sfdisk /dev/sdb --wipe always &amp;lt;&amp;lt;EOF&lt;br /&gt;
  label: gpt&lt;br /&gt;
  first-lba: 64&lt;br /&gt;
  table-length: 8&lt;br /&gt;
  start=64, size=32704, type=D7B1F817-AA75-2F4F-830D-84818A145370, name=&amp;quot;loader&amp;quot;, attrs=RequiredPartition&lt;br /&gt;
  size=11G, name=&amp;quot;ALARM&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MANJARO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;MOBIAN&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;PMOS&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=11G, name=&amp;quot;UT&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
  size=+, name=&amp;quot;extra&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/sdb: 58.25 GiB, 62550179840 bytes, 122168320 sectors&lt;br /&gt;
 Disk model: SD Card Reader  &lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: C44BE2FC-34D6-4DD8-99FC-7FFB75602A79&lt;br /&gt;
 Old situation:&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: F71BFBA6-D2C3-4C20-8079-1401B10C724C).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
  /dev/sdb1: Created a new partition 1 of type 'unknown' and of size 16 MiB.&lt;br /&gt;
  /dev/sdb2: Created a new partition 2 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb3: Created a new partition 3 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb6: Created a new partition 6 of type 'Linux filesystem' and of size 11 GiB.&lt;br /&gt;
  /dev/sdb7: Created a new partition 7 of type 'Linux filesystem' and of size 3.2 GiB.&lt;br /&gt;
  /dev/sdb8: Done.&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: F71BFBA6-D2C3-4C20-8079-1401B10C724C&lt;br /&gt;
 Device         Start       End  Sectors  Size Type&lt;br /&gt;
  /dev/sdb1         64     32767    32704   16M unknown&lt;br /&gt;
  /dev/sdb2      32768  23101439 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb3   23101440  46170111 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb4   46170112  69238783 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb5   69238784  92307455 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb6   92307456 115376127 23068672   11G Linux filesystem&lt;br /&gt;
  /dev/sdb7  115376128 122167295  6791168  3.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
==== Get image files of the distributions ====&lt;br /&gt;
Get the compressed distribution images from [[PinePhone Pro Software Releases]], decompress them and mount both partitions &amp;quot;/boot&amp;quot;, &amp;quot;/root&amp;quot; from each distro.&lt;br /&gt;
&lt;br /&gt;
Change the directory to the ''Downloads'' folder.&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
&lt;br /&gt;
Get images.'' Example releases (update the syntax to newer releases).''&lt;br /&gt;
&lt;br /&gt;
 wget https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20230925/archlinux-pinephone-pro-phosh-20230925.img.xz&lt;br /&gt;
 wget https://github.com/manjaro-pinephone/phosh/releases/download/beta37/Manjaro-ARM-phosh-pinephonepro-beta37.img.xz&lt;br /&gt;
 wget https://images.mobian.org/pinephonepro/weekly/mobian-pinephonepro-phosh-20240107.img.xz&lt;br /&gt;
 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&lt;br /&gt;
 wget https://ci.ubports.com/job/focal-hybris-rootfs-arm64/job/master/lastSuccessfulBuild/artifact/ubuntu-touch-pinephone-pro-img-arm64.raw.xz&lt;br /&gt;
&lt;br /&gt;
Extract the compressed files:&lt;br /&gt;
&lt;br /&gt;
 xz -v -d -k archlinux-pinephone-pro-phosh-20230925.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv archlinux-pinephone-pro-phosh-20230925.img archlinux.img&lt;br /&gt;
 xz -v -d -k Manjaro-ARM-phosh-pinephonepro-beta37.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv Manjaro-ARM-phosh-pinephonepro-beta37.img manjaro.img&lt;br /&gt;
 xz -v -d -k mobian-pinephonepro-phosh-20240107.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv mobian-pinephonepro-phosh-20240107.img mobian.img&lt;br /&gt;
 xz -v -d -k postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv postmarketOS-v23.12-phosh-22.3-pine64-pinephonepro.img postmarketos.img&lt;br /&gt;
 xz -v -d -k ubuntu-touch-pinephone-pro-img-arm64.raw.xz &amp;amp;&amp;amp; rm *.xz &amp;amp;&amp;amp; mv ubuntu.raw&lt;br /&gt;
&lt;br /&gt;
For PostMarketOS you can also use bootstrap to generate distro image. Make sure you install pmbootstrap before building images&lt;br /&gt;
&lt;br /&gt;
 git clone --depth=1 https://git.sr.ht/~postmarketos/pmbootstrap&lt;br /&gt;
 mkdir -p ~/.local/bin&lt;br /&gt;
 ln -s &amp;quot;$PWD/pmbootstrap/pmbootstrap.py&amp;quot; ~/.local/bin/pmbootstrap&lt;br /&gt;
 source ~/.profile ''# remember to update your environment''&lt;br /&gt;
 pmbootstrap --version ''# If this returns error, put ~/.local/bin in your PATH, adding the following to your ~/.profile (zsh: ~/.zprofile).''&lt;br /&gt;
 ''# PATH=&amp;quot;$HOME/.local/bin:$PATH&amp;quot; # optional''&lt;br /&gt;
&lt;br /&gt;
Create 2GB empty image file, format and mount it.&lt;br /&gt;
&lt;br /&gt;
 sudo su&lt;br /&gt;
 dd if=/dev/zero of=postmarketos-edge.img bs=1 count=0 seek=2G status=progress &amp;amp;&amp;amp; sync&lt;br /&gt;
 mkfs.ext4 postmarketOS-edge.img&lt;br /&gt;
 losetup -P /dev/loop0 postmarketos-edge.img&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
Build PMOS image via pmbootstrap&lt;br /&gt;
 pmbootstrap init ''# follow all the setup directions''&lt;br /&gt;
 pmbootstrap status&lt;br /&gt;
 pmbootstrap pull&lt;br /&gt;
 pmbootstrap install --sdcard=/dev/loop0&lt;br /&gt;
 pmbootstrap shutdown ''# remember to deactivare chroot after the image creation''&lt;br /&gt;
&lt;br /&gt;
==== Build Arch Linux partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo losetup -P /dev/loop1 archlinux.img&lt;br /&gt;
 sudo mkdir /mnt/archlinux /mnt/archlinux/boot /mnt/archlinux/root /mnt/archlinuxsd&lt;br /&gt;
 sudo mount /dev/loop1p1 /mnt/archlinux/boot/ &amp;amp;&amp;amp; sudo mount /dev/loop1p2 /mnt/archlinux/root/&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/loop1p2 of=/dev/sdb2 bs=1M status=progress conv=fsync&lt;br /&gt;
 sudo mount /dev/sdb2 /mnt/archlinuxsd/&lt;br /&gt;
 sudo scp -r /mnt/archlinux/boot/* /mnt/archlinuxsd/boot&lt;br /&gt;
 sudo mv /mnt/archlinuxsd/boot/boot.scr /mnt/archlinuxsd/boot/boot.scrORIG&lt;br /&gt;
 sudo mkdir /mnt/archlinuxsd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL ALARM&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image.gz&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=ALARM console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/archlinuxsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=ALARM	/         	ext4      	rw,relatime	0 1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Build Manjaro partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop2 manjaro.img&lt;br /&gt;
 mkdir /mnt/manjaro /mnt/manjaro/boot /mnt/manjaro/root /mnt/manjarosd&lt;br /&gt;
 mount /dev/loop2p1 /mnt/manjaro/boot/ &amp;amp;&amp;amp; mount /dev/loop2p2 /mnt/manjaro/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop2p2 of=/dev/sdb3 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb3 /mnt/manjarosd/&lt;br /&gt;
 chmod -R a=rwx /mnt/*&lt;br /&gt;
 scp -r /mnt/manjaro/boot/* /mnt/manjarosd/boot&lt;br /&gt;
 mv /mnt/manjarosd/boot/boot.scr /mnt/manjarosd/boot/boot.scrORIG&lt;br /&gt;
 mkdir /mnt/manjarosd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
 LABEL l0&lt;br /&gt;
 MENU LABEL MANJARO&lt;br /&gt;
 FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
 KERNEL /boot/Image&lt;br /&gt;
 INITRD /boot/initramfs-linux.img&lt;br /&gt;
 APPEND root=PARTLABEL=MANJARO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/manjarosd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MANJARO   /   ext4     defaults    0   1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Mobian partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop3 mobian.img&lt;br /&gt;
 mkdir /mnt/mobian /mnt/mobian/boot /mnt/mobian/root /mnt/mobiansd&lt;br /&gt;
 mount /dev/loop3p1 /mnt/mobian/boot/ &amp;amp;&amp;amp; mount /dev/loop3p2 /mnt/mobian/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop3p2 of=/dev/sdb4 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb4 /mnt/mobiansd/&lt;br /&gt;
 scp -r /mnt/mobian/boot/* /mnt/mobiansd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/mobiansd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=MOBIAN	/	ext4	defaults,x-systemd.growfs	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 nano /mnt/mobiansd/boot/extlinux/extlinux.conf&lt;br /&gt;
  &amp;gt;adjust ## /boot/extlinux/extlinux.conf file&lt;br /&gt;
  &amp;gt;MENU LABEL MOBIAN&lt;br /&gt;
  &amp;gt;linux /boot/vmlinuz-6.1-rockchip&lt;br /&gt;
  &amp;gt;initrd /boot/initrd.img-6.1-rockchip&lt;br /&gt;
  &amp;gt;fdtdir /boot/dtb-6.1-rockchip/&lt;br /&gt;
  &amp;gt;APPEND root=PARTLABEL=MOBIAN console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
&lt;br /&gt;
==== Build PostmarketOS partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop4 postmarketos-edge.img&lt;br /&gt;
 mkdir /mnt/postmarketos /mnt/postmarketos/boot /mnt/postmarketos/root /mnt/postmarketossd&lt;br /&gt;
 mount /dev/loop4p1 /mnt/postmarketos/boot/ &amp;amp;&amp;amp; mount /dev/loop4p2 /mnt/postmarketos/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop4p2 of=/dev/sdb5 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb5 /mnt/postmarketossd/&lt;br /&gt;
 scp -r /mnt/postmarketos/boot/* /mnt/postmarketossd/boot&lt;br /&gt;
 mkdir /mnt/postmarketossd/boot/extlinux&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 10&lt;br /&gt;
 label l0&lt;br /&gt;
  menu label PMOS&lt;br /&gt;
  linux /boot/vmlinuz&lt;br /&gt;
  initrd /boot/initramfs-extra&lt;br /&gt;
  fdtdir /boot/dtbs-pine64-pinephonepro/&lt;br /&gt;
 APPEND root=PARTLABEL=PMOS console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/postmarketossd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;mount point&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=PMOS / ext4 defaults 0 0&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Build Ubuntu Touch partition ====&lt;br /&gt;
&lt;br /&gt;
Login as root, mount the image, copy rootfs and bootfs to the partition. You need also to make some changes on some files.&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads/ppp/distros&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop5 ubuntu.raw&lt;br /&gt;
 mkdir /mnt/ubuntutouch /mnt/ubuntutouch/boot /mnt/ubuntutouch/root /mnt/ubuntutouchsd&lt;br /&gt;
 mount /dev/loop5p2 /mnt/ubuntutouch/boot/ &amp;amp;&amp;amp; mount /dev/loop5p3 /mnt/ubuntutouch/root/&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop5p3 of=/dev/sdb6 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/sdb6 /mnt/ubuntutouchsd/&lt;br /&gt;
 scp -r /mnt/ubuntutouch/boot/* /mnt/ubuntutouchsd/boot&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/etc/fstab&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=UT	/	ext4	defaults	0	1&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ubuntutouchsd/boot/extlinux/extlinux.conf&lt;br /&gt;
 #/boot/extlinux/extlinux.conf&lt;br /&gt;
 default l0&lt;br /&gt;
 menu title U-Boot menu&lt;br /&gt;
 prompt 0&lt;br /&gt;
 timeout 50&lt;br /&gt;
 label l0&lt;br /&gt;
        menu label UT&lt;br /&gt;
        linux /boot/vmlinuz-6.5.0-okpine-ut&lt;br /&gt;
        initrd /boot/initrd.img-6.5.0-okpine-ut&lt;br /&gt;
        fdtdir /boot/dtb-6.5.0-okpine-ut/&lt;br /&gt;
 APPEND root=PARTLABEL=UT console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
==== Unmount and detach all images ====&lt;br /&gt;
&lt;br /&gt;
 sudo losetup -D&lt;br /&gt;
 sudo umount /mnt/*/* &amp;amp;&amp;amp; sudo umount /media/*/*&lt;br /&gt;
 sudo rm -r /mnt/* &amp;amp;&amp;amp; sudo rm -r /media/*/*&lt;br /&gt;
&lt;br /&gt;
==== Switching On Device ====&lt;br /&gt;
&lt;br /&gt;
[[File:Rk2awTutorialGioWiki.jpg|thumb|right|200px|Options to boot Arch Linux ARM, Manjaro, Mobian, PostmarketOS and Ubuntu Touch]]&lt;br /&gt;
&lt;br /&gt;
According to [https://xnux.eu/rk2aw/ rk2aw loader] info, to operate your PinePhonePro you can:&lt;br /&gt;
&lt;br /&gt;
 Plug in USB power cord. Led blinks: 0.5s on, 0.5s off. Battery is charging.&lt;br /&gt;
&lt;br /&gt;
 Press shortly power button. Graphical menu appears, than just press onto the image to boot from.&lt;br /&gt;
&lt;br /&gt;
 Press power button longer, led starts to blinks rapidly. Release power button, led blinks N times each second according to the flashed images. &lt;br /&gt;
 ''In example: ''&lt;br /&gt;
 ''Led blinks once each second and 1st image is selected ;''&lt;br /&gt;
 ''Led blinks twice each second and 2nd image is seleted ;''&lt;br /&gt;
 ''Led blinks triple each second and 3rd image is selected .''&lt;br /&gt;
 Press shortly to move to next image. &lt;br /&gt;
 Press longer to boot the selected image. &lt;br /&gt;
&lt;br /&gt;
In case you hold the power button too long, the device is forced to power off.&lt;br /&gt;
&lt;br /&gt;
==== Troubleshooting ====&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
 ls /dev/ttyUSB* # check usb address from linux machine&lt;br /&gt;
 minicom -b 1500000 -D /dev/ttyUSB0&lt;br /&gt;
&lt;br /&gt;
More info about erasing eMMC on https://wiki.pine64.org/wiki/PinePhone_Pro_Developer_Edition#Method_2:_Via_serial_cable&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Multi-distro on eMMC ==&lt;br /&gt;
&lt;br /&gt;
[[File:P1090461.JPG|thumb|right|200px|Options to boot Phosh or sxmo]]&lt;br /&gt;
&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
=== Flash rk2Aw loader to SPI ===&lt;br /&gt;
&lt;br /&gt;
Same as above. Note this installs rk2aw and a bootloader to SPI NOR flash. Resulting SPI status is as follow:&lt;br /&gt;
&lt;br /&gt;
 # ./rk2aw-spi-flasher &lt;br /&gt;
 Machine: Pine64 PinePhonePro (pine64,pinephone-pro)&lt;br /&gt;
 SPI NOR Flash:&lt;br /&gt;
 - Total size: 16384 KiB&lt;br /&gt;
 - Erase block size: 4 KiB&lt;br /&gt;
 - Write size: 1&lt;br /&gt;
 - Manufacturer: gigadevice&lt;br /&gt;
 - Part name: gd25lq128e&lt;br /&gt;
 - JEDEC ID: 257018&lt;br /&gt;
&lt;br /&gt;
 Bootable images currently present in SPI NOR flash:&lt;br /&gt;
 Idx Header     Off 1      Size 1     Off 2      Size 2     Notes/content&lt;br /&gt;
 -------------------------------------------------------------------------------&lt;br /&gt;
 0   0          2048       6144       0          0          (padded) 0='rk2aw'&lt;br /&gt;
 5   131072     133120     67584      200704     124928     0='U-Boot TPL' 1='U-Boot SPL'&lt;br /&gt;
 7   524288     526336     147456     673792     124928     0='ddrbin' 1='U-Boot SPL'&lt;br /&gt;
&lt;br /&gt;
 Auto-calculated layout for rk2aw dual bootloader scheme:&lt;br /&gt;
 Area                 Offset     Size      &lt;br /&gt;
 ---------------------------------------------------&lt;br /&gt;
 rk2aw primary        0          65536     &lt;br /&gt;
 rk2aw backup         65536      65536     &lt;br /&gt;
 spl fallback         131072     393216    &lt;br /&gt;
 spl primary          524288     389120    &lt;br /&gt;
 itb fallback         913408     2097152   &lt;br /&gt;
 itb primary          3010560    2097152&lt;br /&gt;
&lt;br /&gt;
=== Build multi-distro eMMC ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==== Mount the images ====&lt;br /&gt;
&lt;br /&gt;
 cd ~/Downloads ''# enter to directory''&lt;br /&gt;
 sudo su ''# login with your psw''&lt;br /&gt;
 losetup -P /dev/loop0 archlinux-pinephone-pro-phosh-20230203.img &lt;br /&gt;
 losetup -P /dev/loop1 archlinux-pinephone-pro-sxmo-20230203.img &lt;br /&gt;
 ls -l /mnt/&lt;br /&gt;
 mkdir /mnt/phosh&lt;br /&gt;
 mkdir /mnt/sxmo&lt;br /&gt;
 mkdir /mnt/phosh/boot&lt;br /&gt;
 mkdir /mnt/phosh/root&lt;br /&gt;
 mkdir /mnt/sxmo/boot&lt;br /&gt;
 mkdir /mnt/sxmo/root&lt;br /&gt;
 mkdir /mnt/ephosh'' # e for the partition on the eMMC''&lt;br /&gt;
 mkdir /mnt/esxmo''  # e for the partition on the eMMC''&lt;br /&gt;
 mount /dev/loop0p1 /mnt/phosh/boot/&lt;br /&gt;
 mount /dev/loop0p2 /mnt/phosh/root/&lt;br /&gt;
 mount /dev/loop1p1 /mnt/sxmo/boot/&lt;br /&gt;
 mount /dev/loop1p2 /mnt/sxmo/root/&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
 NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
 loop0          7:0    0     5G  0 loop &lt;br /&gt;
 ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
 └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
 loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
 ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
 └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
 mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
 ├─mmcblk2p1  179:1    0   122M  0 part &lt;br /&gt;
 └─mmcblk2p2  179:2    0 115.1G  0 part &lt;br /&gt;
 mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
 mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
 mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
 ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
 └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
 zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Prepare eMMC ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/zero of=/dev/mmcblk2 count=32768 bs=32768 status=progress'' # overwrite the front to clear any bootloaders''&lt;br /&gt;
&lt;br /&gt;
 sfdisk /dev/mmcblk2 &amp;lt;&amp;lt; EOF&lt;br /&gt;
 label: gpt&lt;br /&gt;
 first-lba: 64&lt;br /&gt;
 table-length: 8&lt;br /&gt;
 size=32G, name=&amp;quot;PHOSH&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 size=+, name=&amp;quot;SXMO&amp;quot;, attrs=&amp;quot;RequiredPartition,LegacyBIOSBootable&amp;quot;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 Checking that no-one is using this disk right now ... OK&lt;br /&gt;
 Disk /dev/mmcblk2: 115.23 GiB, 123731968000 bytes, 241664000 sectors&lt;br /&gt;
 Units: sectors of 1 * 512 = 512 bytes&lt;br /&gt;
 Sector size (logical/physical): 512 bytes / 512 bytes&lt;br /&gt;
 I/O size (minimum/optimal): 512 bytes / 512 bytes&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Script header accepted.&lt;br /&gt;
 &amp;gt;&amp;gt;&amp;gt; Created a new GPT disklabel (GUID: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461).&lt;br /&gt;
 The maximal number of partitions is 8 (default is 128).&lt;br /&gt;
 /dev/mmcblk2p1: Created a new partition 1 of type 'Linux filesystem' and of size 32 GiB.&lt;br /&gt;
 /dev/mmcblk2p2: Created a new partition 2 of type 'Linux filesystem' and of size 83.2 GiB.&lt;br /&gt;
 /dev/mmcblk2p3: Done.&lt;br /&gt;
&lt;br /&gt;
 New situation:&lt;br /&gt;
 Disklabel type: gpt&lt;br /&gt;
 Disk identifier: 7EB4B1E0-5F49-4F30-9F1E-E9E1F305D461&lt;br /&gt;
 Device            Start       End   Sectors  Size Type&lt;br /&gt;
 /dev/mmcblk2p1     2048  67110911  67108864   32G Linux filesystem&lt;br /&gt;
 /dev/mmcblk2p2 67110912 241661951 174551040 83.2G Linux filesystem&lt;br /&gt;
 The partition table has been altered.&lt;br /&gt;
 Calling ioctl() to re-read partition table.&lt;br /&gt;
 Syncing disks.&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part /mnt/phosh/boot&lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part /mnt/phosh/root&lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
&lt;br /&gt;
==== Build Phosh partition ====&lt;br /&gt;
&lt;br /&gt;
 dd if=/dev/loop0p2 of=/dev/mmcblk2p1 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p1 /mnt/ephosh/&lt;br /&gt;
 scp -r /mnt/phosh/boot/* /mnt/ephosh/boot&lt;br /&gt;
 mv /mnt/ephosh/boot/boot.scr /mnt/ephosh/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/etc/fstab&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  #Static information about the filesystems.&lt;br /&gt;
  #See fstab(5) for details.&lt;br /&gt;
  #&amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
  PARTLABEL=PHOSH 	/   ext4   rw,relatime	0 1&lt;br /&gt;
  # UUID=52CA-6165  /boot vf rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/ephosh/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/ephosh/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL phosh&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=PHOSH console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
  EOF&lt;br /&gt;
&lt;br /&gt;
==== Build SXMO partition ====&lt;br /&gt;
&lt;br /&gt;
We have unmounted all the Phosh devices, so&lt;br /&gt;
&lt;br /&gt;
 lsblk&lt;br /&gt;
  NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS&lt;br /&gt;
  loop0          7:0    0     5G  0 loop &lt;br /&gt;
  ├─loop0p1    259:0    0   122M  0 part &lt;br /&gt;
  └─loop0p2    259:1    0   4.9G  0 part &lt;br /&gt;
  loop1          7:1    0   3.5G  0 loop &lt;br /&gt;
  ├─loop1p1    259:2    0   122M  0 part /mnt/sxmo/boot&lt;br /&gt;
  └─loop1p2    259:3    0   3.4G  0 part /mnt/sxmo/root&lt;br /&gt;
  mmcblk2      179:0    0 115.2G  0 disk &lt;br /&gt;
  ├─mmcblk2p1  179:1    0    32G  0 part &lt;br /&gt;
  └─mmcblk2p2  179:2    0  83.2G  0 part &lt;br /&gt;
  mmcblk2boot0 179:32   0     4M  1 disk &lt;br /&gt;
  mmcblk2boot1 179:64   0     4M  1 disk &lt;br /&gt;
  mmcblk1      179:96   0  59.6G  0 disk &lt;br /&gt;
  ├─mmcblk1p1  179:97   0   122M  0 part /boot&lt;br /&gt;
  └─mmcblk1p2  179:98   0  59.5G  0 part /&lt;br /&gt;
  zram0        254:0    0   1.5G  0 disk [SWAP]&lt;br /&gt;
 &lt;br /&gt;
 dd if=/dev/loop1p2 of=/dev/mmcblk2p2 bs=1M status=progress conv=fsync&lt;br /&gt;
 mount /dev/mmcblk2p2 /mnt/esxmo/&lt;br /&gt;
 scp -r /mnt/sxmo/boot/* /mnt/esxmo/boot&lt;br /&gt;
 mv /mnt/esxmo/boot/boot.scr /mnt/esxmo/boot/boot.scrORIG&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/etc/fstab&lt;br /&gt;
 # Static information about the filesystems.&lt;br /&gt;
 # See fstab(5) for details.&lt;br /&gt;
 # &amp;lt;file system&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;pass&amp;gt;&lt;br /&gt;
 PARTLABEL=SXMO /     ext4      	rw,relatime	0 1&lt;br /&gt;
 # UUID=841C-F9DD      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2&lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 mkdir /mnt/esxmo/boot/extlinux&lt;br /&gt;
 &lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt; /mnt/esxmo/boot/extlinux/extlinux.conf&lt;br /&gt;
  #/boot/extlinux/extlinux.conf&lt;br /&gt;
  MENU TITLE Pinephone Pro Boot Menu&lt;br /&gt;
  LABEL l0&lt;br /&gt;
  MENU LABEL sxmo&lt;br /&gt;
  FDT /boot/dtbs/rockchip/rk3399-pinephone-pro.dtb&lt;br /&gt;
  KERNEL /boot/Image&lt;br /&gt;
  INITRD /boot/initramfs-linux.img&lt;br /&gt;
  APPEND root=PARTLABEL=SXMO console=ttyS2,115200 console=tty0 loglevel=4 rw rootwait&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
== Follow-up comments ==&lt;br /&gt;
&lt;br /&gt;
# On first boot neither Phosh nor sxmo resized their partition - ''sudo resize2fs'' sorted that.&lt;br /&gt;
# Any time an update rebuilds the initramfs it is necessary to delete /boot/boot.scr again to keep the rk2aw menu clean.&lt;br /&gt;
# In case you want to reinstall just a single distribution, the easy way is to delete an recreate partition using gParted GUI.&lt;br /&gt;
&lt;br /&gt;
[[Category:PinePhone Pro]]&lt;/div&gt;</summary>
		<author><name>Giorez</name></author>
	</entry>
</feed>