PINE64 PinePhone (pine64-pinephone)

From postmarketOS
Jump to: navigation, search
Work is being done to make this device ready for daily use with postmarketOS: milestone#1

Find and report PinePhone related issues here. Keep in mind, that postmarketOS is currently in alpha state. Join the chat if you have questions.

PINE64 PinePhone
A PinePhone with a case
A PinePhone with a case
Manufacturer PINE64
Name PinePhone
Codename pine64-pinephone
Released 2019
Original software postmarketOS
Hardware
Chipset Allwinner A64
CPU 4x 1152 MHz Cortex-A53
GPU Mali-400 MP2
Display 720x1440 IPS
Storage 16 GB
Memory 2 GB
Architecture aarch64
Non-Android based device
Features
USB Networking
Works
Flashing
Unavailable
Touchscreen
Works
Display
Works
WiFi
Works
Xwayland
Works
FDE
Works
Mainline
Works
Battery
Works
3D Acceleration
Works
Accelerometer
Works
Audio
Works
Bluetooth
Works
Camera
Partial
GPS
Works
Mobile data
Works
SMS
Works
Calls
Works
USB OTG
Broken



The PinePhone is a smartphone by PINE64. The postmarketOS vendor and device names are "pine64" and "pinephone" respectively. The back panel can be lifted off by pulling at the notch on the bottom-right corner of the phone. This exposes the battery, microSD and SIM slots, and dipswitches. It comes with a 3000mAh battery and uses the same form-factor as the Samsung Galaxy J7 (2015) for replacement.

Contributors

Installation

Hint: The PinePhone will boot to the microSD card first if it's bootable, or the eMMC if not.

The recommended installation procedure is installing to a microSD card by following the Installation Guide and to pass "--sdcard=/dev/(...)" to "pmbootstrap install".

Hint: Passing the additional option "--fde" to "pmbootstrap install" will create a LUKS root partition on the target device and will allow you to set a password during the installation process.
Note: The above option may throw the following error when entering a passphrase "WARNING: Locking directory /run/cryptsetup is missing!" This can be safely ignored See here.

postmarketOS can be installed onto the eMMC by flashing Jumpdrive onto a microSD, booting it with the USB connected to the PC and following the microSD install instructions above or by booting a Linux distribution on the phone first and doing the installation process via pmbootstrap on the phone directly:

  1. Install pmbootstrap and its dependencies on the phone on any Linux distribution booted via the microSD card
  2. Follow the Installation Guide until "Installation and flashing"
  3. Run "pmbootstrap install --sdcard=/dev/mmcblk2"

If this throws an error mentioning "/dev/installp2" when trying to install from postmarketOS on the microSD card over an existing installation of postmarketOS on the eMMC (including the factory test image), the partitions of the existing installation on the eMMC need to be deleted and the phone needs to be rebooted once after doing so due to a bug, see here

postmarketOS can also be installed using premade images from here. Some of these images are purely for demoing specific things and aren't usable for general use and will never be. These images can be installed by using dd, or your favorite image writer.

Note: This requires sufficient space on the microSD, partitions created from images using dd need to be resized.

Installing postmarketOS on the eMMC directly from a computer via FEL is also supported. This requires the user to enable FEL mode, the boot-tools to mount the eMMC as mass storage are currently however not compatible.

Serial console

The PinePhone has a serial port in the headphone connector, it's activated by the 6th contact on the dipswitch. If the switch is on then the headphone connector is in audio mode, if it's off then it's in UART mode.

The uart is 115200n8

The pinout for the serial connector on the headphone jack is:

  • Tip: RX
  • Ring: TX
  • Sleeve: GND

The serial connection is 3.3V

You can also buy the debug cable from PINE64 Store The store cable uses a 4 ring plug, as seen in the PDF, but a 3 ring plug works just as well.

PinePhone-main-board.jpg

Hardware switches

There's a 6 contact dipswitch on the back of the phone underneath the back cover. The 6 switches are for enabling/disabling hardware components. The switch has tiny numbers 1-6 beneath the contacts, moving the contact up sets that contact on.

# Off On
1 Modem disabled Modem enabled
2 Wifi/BT disabled Wifi/BT enabled
3 Microphone disabled Microphone enabled
4 Rear camera disabled Rear camera enabled
5 Front camera disabled Front camera enabled
6 Headphone UART mode Headphone audio mode

Expansion port

There is a 2x3 grid of pogo pins on the back of the PinePhone for connecting a back cover with extra hardware like an extended battery case or a keyboard case. The pinout for this connector:

Interrupt I2C I2C
3v3 usb 5v gnd

the USB5v line is meant to charge the phone and the 3v3 is to power peripherals to the phone. The I2C and interrupt lines have pull-ups on the phone side.

Components

Component Model Driver
Touchscreen Goodix TOUCHSCREEN_GOODIX
Rear camera OmniVision OV5640 VIDEO_OV5640
Camera flash SGMICRO SGM3140 LEDS_SGM3140
Front camera GalaxyCore GC2145 Nope
LCD Xingbangda XBD599 CONFIG_DRM_PANEL_XINGBANGDA_XBD599
WiFi Realtek RTL8723CS RTL8723CS
Bluetooth Realtek RTL8723CS BT_HCIUART_RTL
Modem Quectel EC25-E USB_NET_QMI_WWAN
GNSS/GPS Quectel EC25-G CONFIG_USB_SERIAL_OPTION
Magnetometer ST LIS3MDL IIO_ST_MAGN_3AXIS
Ambient light / Proximity SensorTek STK3335 STK3310
Sixaxis InvenSense MPU-6050 INV_MPU6050_I2C
Vibration motor  ? INPUT_GPIO_VIBRA
Notification LED LED0603RGB LEDS_GPIO
Volume buttons Buttons connected to the KEYADC KEYBOARD_SUN4I_LRADC
Power button X-Powers AXP803 INPUT_AXP20X_PEK
Battery fuel gauge X-Powers AXP803 BATTERY_AXP20X


Cameras

The cameras both share the csi-0 bus. Currently only the rear camera (OV5640) has mainline linux support.

It's also not clear how the camera switching would work on the software side, the current issue is that the sunxi csi driver doesn't support multiple camera endpoints.

The camera hardware pipeline is controlled with /dev/media1 and media-ctl, the result is on /dev/video1

pinephone:~# media-ctl -d /dev/media1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720]'
pinephone:~# ffmpeg -s 1280x720 -f video4linux2 -i /dev/video1 -vframes 1 selfie.jpg

Pinephone-camera-demo.jpg

Camera Flash

Please note, that the driver for the sgm3140 is not yet included in the main kernel source and as such is not available for use yet without compiling the module yourself.

The camera flash consist out of a SG Micro SGM3140 "500mA Buck/Boost Charge Pump LED Driver" and a EHP-C04 LED. It supports Flash and Torch mode, the first being brighter but only for 200-300ms, when it switches to Torch mode automatically. Torch mode is lower brightness but can be turned on continuously.

Controlling the flash from user space is possible via sysfs and via v4l2:

# Torch on
$ echo 1 > /sys/class/leds/white\:flash/brightness
# Torch off
$ echo 0 > /sys/class/leds/white\:flash/brightness
# Activate flash
$ echo 1 > /sys/class/leds/white\:flash/flash_strobe
# Torch on
$ v4l2-ctl -d /dev/video1 -c led_mode=2
# Torch off
$ v4l2-ctl -d /dev/video1 -c led_mode=0
# Activate flash
$ v4l2-ctl -d /dev/video1 -c led_mode=1
$ v4l2-ctl -d /dev/video1 -c strobe=1

WiFi

The wifi uses the rtl8723cs driver and is functional. There is still an issue with the driver not reloading correctly when the SoC is put into suspend mode, this can be worked around by reloading the kernel module:

pinephone:~# sudo rmmod 8723cs
pinephone:~# sudo modprobe 8723cs

Bluetooth

Main article: Bluetooth.

The bluetooth connection is handled by the wifi chipset. It is functional but there is no integration in Plasma Mobile yet. To pair a bluetooth device start the bluetooth service and use bluetoothctl to connect.

pinephone:~# sudo service bluetooth start
pinephone:~# bluetoothctl
# scan on
[NEW] 00:11:22:33:44:55
# pair 00:11:22:33:44:55

To use bluetooth headphones with pulseaudio, the package pulseaudio-bluez is required.

Modem

Receiving and sending text messages works, The calls work but there are some issues left with the audio routing. Mobile data is functional. For information on audio routing and setting up the modem in phosh, see the specific article.

To bring up mobile data run the following commands (for plasma mobile):

pinephone:~# sudo apk add ofonoctl
pinephone:~# ofonoctl wan --connect --append-dns

In order to connect to the serial console of the modem, you need a terminal application. One option is to use minicom.

# apk add minicom

Connect to the console by issuing:

# minicom -D /dev/ttyUSB2

The command AT returns OK:

AT
OK

The command ATI returns some version information from the modem:

ATI
Quectel
EG25
Revision: EG25GGBR07A07M2G

OK

The command AT+QDAI (Digital Audio Interface Configure) is used to configure the digital audio interface. AT+QDAI? returns the current configuration:

AT+QDAI?
+QDAI: 3,0,0,4,0,0,1,1

OK


Some more details on how to configure the modem is available here. The reference for the available commands is the EC25 & EC21 AT Commands Manual.

Sensors

All sensors work and are accessible as Industrial I/O (iio) devices in Linux. To query the data you can cat the files in `/sys/bus/iio/` to make the kernel module query the sensors

pinephone:~# cat /sys/bus/iio/devices/iio\:device0/name
mpu6050
pinephone:~# cat /sys/bus/iio/devices/iio\:device0/in_accel_z_raw
-17594
pinephone:~# echo "Verified gravity still exists"

RGB Led

# Activate LED
echo 1 > /sys/class/leds/$COLOR/brightness
# Deactivate LED
echo 0 > /sys/class/leds/$COLOR/brightness

You may turn on and off the blue led by issuing:

# echo 1 > /sys/devices/platform/leds/leds/pinephone\:blue\:user/brightness
# echo 0 > /sys/devices/platform/leds/leds/pinephone\:blue\:user/brightness

Make sure you run these commands as root (sudo -i), sudo echo 1 > /sys/devices/platform/leds/leds/pinephone\:blue\:user/brightness, won't work.

Audio

Speakers

Sound output should work after unmuting AIF1 Slot 0 digital

Start by making sure alsa-utils are installed:

$ sudo apk add alsa-utils

You may use amixer, or alsamixer to unmute the required channels, and to control the volume:

Amixer:

$ amixer scontents
$ amixer sset Master unmute

Alsamixer (use terminal keyboard input to use up/down/left/right keys, to set volume and select devices):

$ alsamixer -V all

Test the sound output by issuing:

$ speaker-test -c3

Troubleshooting

Failed to create boot/xxx: No space left on device

A bug has been observed where too many initramfs's are created. To fix, run the following commands to delete and regenerate all initramfs's

postmarketos:~# sudo rm /boot/initramfs*
postmarketos:~# sudo apk fix linux-postmarketos-allwinner

Qt Based Browsers Not Loading Web Pages

Webkit sandbox is broken in the current build. In order to be able to use Qt based browsers it is necessary to create the file "/etc/profile.d/sandboxhack.sh" with the following contents:

#!/bin/sh
export QTWEBENGINE_DISABLE_SANDBOX=1

This sets an environment variable that kills the webkit sandbox because that's broken in the current build. This should be fixed already for the chromium musl build but not yet for all qtwebkit based browsers. This is being worked on here and here.

See also