Installing a PinePhone from scratch
The PINE64 PinePhone is a smartphone running GNU/Linux (and anything else that can run on an AllWinner A64 system on a chip). In April 2020 I ordered the PinePhone. I have played with the device quite a bit since I received it in July 2020.
An upgrade program was available, in which the mainboard could be replaced with the latest revision. Improvements include more memory (3 GB instead of 2 GB), more eMMC storage (32 GB instead of 16 GB) and fixes for several hardware bugs. The program just concerns buying and shipping the new mainboard. It is the user who actually has to replace the mainboard.
Of course, I ordered the upgrade, which I received recently. After I received it I followed the instructions. Replacing the mainboard was quite easy, but after installation it failed to boot. The only activity when powering on the device was a very brief flash from the rear camera, but nothing else. Initially I suspected that the mainboard I received was dead on arrival. After a bit of tinkering, I found out that there simply was nothing installed in the onboard eMMC flash memory. This is unexpected since the PinePhone itself ships with an operating system installed, and there was no other indication on the product page that the device ships without any data at the time. The wiki does mention this, but I found this out only after I replaced the mainboard.
Fortunately, installing an operating system on a PinePhone is quite easy. In this post I briefly describe my approach, which can also be used to recover a ‘bricked’ (unbootable) PinePhone.
This post was written on a PinePhone as a finger exercise, using a Nex Nexdock 2 to utilize its ability to offer a desktop environment.
Prerequisites
The requirements are:
- A PinePhone (any revision should do, but this was only tested on revisions 1.2 and 1.2b).
- A microSD card. As long as the capacity is 64 MB (a tiny amount of space for a modern microSD card) or larger, it is usable.
- An SD card reader with a microSD adapter, or a microSD card reader.
- A PC running Linux (tested with Arch Linux) or Windows (untested, but instructions are provided).
Prepare Jumpdrive
Jumpdrive is a small Linux distribution for several Pine devices. Its sole function is to offer the microSD card reader and the onboard eMMC flash memory as USB mass storage devices. This allows direct interaction with the storage of the PinePhone from a PC.
Preparing Jumpdrive in Linux can be done with:
curl -JLO https://github.com/dreemurrs-embedded/Jumpdrive/releases/download/0.6/pine64-pinephone.img.xz
xzcat pine64-pinephone.img.xz | \
dd iflag=fullblock bs=4M | \
sudo dd iflag=fullblock oflag=direct conv=fsync \
status=progress bs=4M of=/dev/<dev>
Where <dev>
refers to the block device of the microSD card. Examples include /dev/sdb
and /dev/mmcblk0
. Verify that you have the right device by running ls -l /dev/disk/by-id
.
Preparing Jumpdrive in Windows can be done with Rufus. It might be that for Rufus, you need to have 7-Zip installed as well in order to decompress the image. Download Jumpdrive here.
Boot Jumpdrive
Put the microSD card in the PinePhone. Ensure that it has a battery installed, and connect it with a USB cable to your PC. Power on the PinepPhone. If you use Linux on your PC, monitor dmesg
, to determine the correct block device to use in the next step.
Install an operating system on the PinePhone
For this example, Arch Linux ARM will be installed on the PinePhone. On your PC with Linux, run:
curl -JLO https://github.com/dreemurrs-embedded/Pine64-Arch/releases/download/20201223/archlinux-pinephone-20201223.img.xz
xzcat archlinux-pinephone-20201204.img.xz | \
dd iflag=fullblock bs=4M | \
sudo dd iflag=fullblock oflag=direct conv=fsync \
status=progress bs=4M of=/dev/<dev>
Replace <dev>
with the relevant device, which can either be the microSD card (which will overwrite Jumpdrive!) or the PinePhone’s eMMC storage memory.
If your PC runs Windows, download the image of your preferred operating system, and use Rufus again. It will allow you to choose either the microSD card or the PinePhone’s eMMC storage memory as a target device for the image.
This step will take quite a while. Wait until the copy action is completed.
Boot the new operating system
Turn off the PinePhone by holding the power button for 10 seconds or by removing the battery. Remove the microSD card containing Jumpdrive from the PinePhone if the operating was installed to eMMC, reinstall the battery and power on the PinePhone. The operating system should boot.
Optional: flash USB-C bridge chip firmware
The PinePhone uses an ANX7688 bridge chip to combine video, USB data and power over a single USB-C connection. As noted on the wiki, firmware needs to be flashed to the chip’s EEPROM on new mainboards to fully utilize this chip. Do so on the PinePhone with:
curl -JLO https://xff.cz/git/linux-firmware/plain/anx7688-fw.bin
sudo cp anx7688-fw.bin /lib/firmware/
sudo bash -c "echo 1 > /sys/class/tpec/port0/device/flash_eeprom"
The new firmware will be active immediately after it is flashed. A reboot is not necessary.