Difference between revisions of "PINE64 PinePhone (pine64-pinephone)"

From postmarketOS
Jump to navigation Jump to search
(Touchscreen works great now with the 5.4 kernel)
(→‎Cameras: Changed to a more recent picture, thanks Martijn!)
 
(79 intermediate revisions by 24 users not shown)
Line 1: Line 1:
 +
{{note-device-milestone-main|1}}
 +
<div role="note" class="note" style="padding: 5px 15px 0 15px; color: #705000; border: 1px solid #fde29b; background-color: #fdf1d1; margin-top: 5px;">
 +
 +
'''Find and report PinePhone related issues [https://gitlab.com/postmarketOS/pmaports/issues?scope=all&utf8=%E2%9C%93&state=opened&search=pinephone here].''' Keep in mind that postmarketOS currently is in beta. Join the [[Matrix_and_IRC|chat]] if you have questions.
 +
</div>
 
{{Infobox device
 
{{Infobox device
 
| manufacturer = PINE64
 
| manufacturer = PINE64
Line 6: Line 11:
 
| imagecaption = A PinePhone with a case
 
| imagecaption = A PinePhone with a case
 
| releaseyear = 2019
 
| releaseyear = 2019
| originalsoftware = Linux 5.3.0
+
| category = community
 +
| originalsoftware = postmarketOS
 
| pmoskernel =  
 
| pmoskernel =  
 
| chipset = Allwinner A64
 
| chipset = Allwinner A64
 
| cpu = 4x 1152 MHz Cortex-A53
 
| cpu = 4x 1152 MHz Cortex-A53
| gpu = Mali 400
+
| gpu = Mali-400 MP2
| memory = 2 GB
+
| display = 720x1440 IPS
 +
| storage = 16 GB / 32 GB
 +
| memory = 2 GB / 3 GB
 
| architecture = aarch64
 
| architecture = aarch64
 
| n-android =  ✔
 
| n-android =  ✔
 
| whet_dhry =  
 
| whet_dhry =  
| status_usbnet =  
+
| status_usbnet = Y
 
| status_flashing = -
 
| status_flashing = -
 
| status_touch = Y
 
| status_touch = Y
 
| status_screen = Y
 
| status_screen = Y
| status_wifi = P
+
| status_wifi = Y
 
| status_xwayland = Y
 
| status_xwayland = Y
| status_fde = N
+
| status_fde = Y
 
| status_mainline = Y
 
| status_mainline = Y
 
| status_battery = Y
 
| status_battery = Y
| status_3d = P
+
| status_3d = Y
 
| status_accel = Y
 
| status_accel = Y
 
| status_audio = Y
 
| status_audio = Y
| status_bluetooth = N
+
| status_bluetooth = Y
| status_camera = Y
+
| status_camera = P
 
| status_gps = Y
 
| status_gps = Y
 
| status_mobiledata = Y
 
| status_mobiledata = Y
| status_sms = N
+
| status_sms = Y
| status_calls = N
+
| status_calls = Y
 
| status_otg = N
 
| status_otg = N
 
| status = Boots
 
| status = Boots
 
| booting = yes
 
| booting = yes
 
}}
 
}}
 +
 +
The [https://www.pine64.org/pinephone/ 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 ===
 
=== Contributors ===
Line 42: Line 52:
 
* ''[[user:Z3ntu|z3ntu]]''
 
* ''[[user:Z3ntu|z3ntu]]''
 
* ''[[user:bshah|bshah]]''
 
* ''[[user:bshah|bshah]]''
 +
 +
== Users owning this device ==
 +
{{Device owners}}
  
 
== Installation ==
 
== Installation ==
 +
The PinePhone will boot from a bootable microSD card if it is plugged, and fall back to booting from internal eMMC. You can install postmarketOS on either of them (or even on both).
  
The recommended installation procedure is installing to a microSD card by passing --sdcard=/dev/... to pmbootstrap install. The pinephone will boot to the microSD card first if it's bootable, or the eMMC if not. postmarketOS may be installed onto the eMMC by running pmbootstrap install --sdcard=/dev/mmcblk... from a Linux distribution booted via the microSD card.
+
=== microSD card ===
 +
For now, it is recommended to build your own image with [[pmbootstrap]]. Run the following commands, and consult the [[Installation guide|installation guide]] for details.
 +
 
 +
<syntaxhighlight lang="shell-session">
 +
$ pmbootstrap init # vendor: pine64, device: pinephone, select "stable" channel
 +
$ pmbootstrap install --sdcard=/dev/mmcblk...  # add --fde for full disk encryption
 +
</syntaxhighlight>
 +
 
 +
After that, unplug the microSD card from your PC, put it in your PinePhone and postmarketOS should boot up. (Note that the microSD fits in the SIM slot, but that does of course not work.)
 +
 
 +
For a quick demo, you may use a test image from [https://images.postmarketos.org/pinephone/ images.postmarketos.org] instead of building your own image with pmbootstrap.
 +
<syntaxhighlight lang="shell-session">
 +
$ wget https://images.postmarketos.org/pinephone/pine64-pinephone-20200724-phosh-v20.05-installer.img.xz
 +
$ unxz pine64-pinephone-20200724-phosh-v20.05-installer.img.xz
 +
$ sudo dd if=pine64-pinephone-20200724-phosh-v20.05-installer.img of=/dev/mmcblk... status=progress
 +
</syntaxhighlight>
 +
 
 +
=== Internal eMMC ===
 +
Create a new image with pmbootstrap (recommended, [[Installation guide|details]]) or download a pre-built image (see above).
 +
 
 +
<syntaxhighlight lang="shell-session">
 +
$ pmbootstrap init # vendor: pine64, device: pinephone, select "stable" channel
 +
$ pmbootstrap install # add --fde for full disk encryption
 +
$ pmbootstrap export
 +
$ realpath /tmp/postmarketOS-export/pine64-pinephone.img
 +
/home/user/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/pine64-pinephone.img
 +
</syntaxhighlight>
 +
 
 +
Download [https://github.com/dreemurrs-embedded/Jumpdrive Jumpdrive] and flash it to a microSD card. This is the recommended way to install postmarketOS to the internal eMMC for now (doing it from the on-device installer [https://gitlab.com/postmarketOS/postmarketos-ondev/-/issues/22 is planned]).
 +
 
 +
<syntaxhighlight lang="shell-session">
 +
$ wget https://github.com/dreemurrs-embedded/Jumpdrive/releases/download/0.5/pine64-pinephone.img.xz
 +
$ sha512sum pine64-pinephone.img.xz
 +
b8edbc1ada0a8e71da9ef8d457480967e97de508cffb57b41ad1928a013acc3772f7bb7a2b4c3436af05a8c849f2ffb816780b4f749ec17df211ec3477880d80  pine64-pinephone.img.xz
 +
$ unxz pine64-pinephone.img.xz
 +
$ sudo dd if=pine64-pinephone.img of=/dev/mmcblk... status=progress
 +
</syntaxhighlight>
 +
 
 +
Insert the microSD card into your PinePhone and boot it up. It should display the Jumpdrive splash screen.
 +
 
 +
Connect your PinePhone via USB to your PC and use <code>lsblk</code> to figure out the correct target partition. You should see two new devices in <code>lsblk</code>. One device has just one small ~40 MiB partition, this is the microSD card with JumpDrive. The other device is the eMMC. You should flash to the device itself (typically of the form /dev/sdx) and not a partition (/dev/sdxn where n is a number).
 +
<syntaxhighlight lang="shell-session">
 +
$ lsblk
 +
(now plug the USB cable)
 +
$ lsblk
 +
</syntaxhighlight>
 +
 
 +
Prepare the final <code>dd</code> command to flash postmarketOS to the eMMC and triple-check that you have put the right device as <code>of</code> argument. Then run it.
 +
<syntaxhighlight>
 +
$ sudo dd if=~/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/pine64-pinephone.img of=/dev/sd... status=progress
 +
</syntaxhighlight>
 +
 
 +
As of writing, Jumpdrive doesn't have a shutdown procedure ([https://github.com/dreemurrs-embedded/Jumpdrive/issues/2 #2]). Maybe leave it on for a few more minutes after the <code>dd</code> command is done to make sure that the data isn't still in some cache, but really written to the eMMC (the author had data corruption once, which might be related to turning it off too quickly after flashing). Then press the power button for five seconds to power it off. Remove the microSD card, turn it on again. The PinePhone should boot into postmarketOS.
  
 
== Serial console ==
 
== Serial console ==
Line 52: Line 118:
 
The uart is 115200n8
 
The uart is 115200n8
  
The pinout for the serial connector on the tablet side is:
+
The pinout for the serial connector on the headphone jack is:
  
 
* Tip: RX
 
* Tip: RX
Line 60: Line 126:
 
The serial connection is 3.3V
 
The serial connection is 3.3V
  
You can also buy the debug cable from [https://store.pine64.org PINE64 Store]
+
You can also buy the debug cable from [https://store.pine64.org PINE64 Store].
 +
The store cable uses a 4 ring plug, as seen in the [http://files.pine64.org/doc/pinebook/guide/Pinebook_Earphone_Serial_Console_Developer_Guide.pdf PDF], but a 3 ring plug works just as well.
  
 
[[File:PinePhone-main-board.jpg|frameless]]
 
[[File:PinePhone-main-board.jpg|frameless]]
Line 66: Line 133:
 
== Hardware switches ==
 
== Hardware switches ==
  
There's a 6 contact dipswitch on the back of the phone underneath the back cover. The 6 switches are for enableing/disableing hardware components. The switch has tiny numbers 1-6 beneath the contacts, moving the contact up sets that contact on.  
+
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.  
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 100: Line 167:
 
== Expansion port ==
 
== 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:
+
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:
  
 
{| class="wikitable"
 
{| class="wikitable"
 
| Interrupt
 
| Interrupt
| I2C
+
| SDA
| I2C
+
| SCL
 
|-
 
|-
| 3v3
+
| 5V / VBUS
| usb 5v
+
| VBAT
| gnd
+
| 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.
+
The VBUS pin is powered by USB and is 5V. The second power pin is VBAT, which connects to the battery voltage. The I2C and interrupt lines have pull-ups on the phone side. The I2C lines are pulled up to 3V3 by the phone.
  
 
== Components ==
 
== Components ==
Line 122: Line 189:
 
|-
 
|-
 
| Touchscreen
 
| Touchscreen
| Goodix
+
| Goodix GT917S
 
| TOUCHSCREEN_GOODIX
 
| TOUCHSCREEN_GOODIX
 
|-
 
|-
Line 150: Line 217:
 
|-
 
|-
 
| Modem
 
| Modem
| Quectel EC25-E
+
| Quectel EC25-G
 
| USB_NET_QMI_WWAN
 
| USB_NET_QMI_WWAN
 
|-
 
|-
Line 170: Line 237:
 
|-
 
|-
 
| Vibration motor
 
| Vibration motor
| ?
+
| Unknown model
 
| INPUT_GPIO_VIBRA
 
| INPUT_GPIO_VIBRA
 
|-
 
|-
Line 193: Line 260:
 
=== Cameras ===
 
=== Cameras ===
  
The camera's both share the csi-0 bus. Currently only the rear camera (OV5640) has mainline linux support.
+
The cameras both share the csi-0 bus. Currently only the rear camera (OV5640) has mainline linux support, a driver for the front camera (GC2145) is being developed in the kernel fork for the phone development.
 +
 
 +
Both camera's share the same bus for the video stream, due to this it's impossible to use both cameras at the same time, but you can switch between the cameras by keeping one of them in reset and then restarting the
 +
whole pipeline.  
 +
 
 +
<source lang="shell-session">
 +
Switching to the rear camera
 +
$ sudo media-ctl -d /dev/media1 --links "gc2145 3-003c":0->"sun6i-csi":0[0]
 +
$ sudo media-ctl -d /dev/media1 --links "ov5640 3-004c":0->"sun6i-csi":0[1]
  
It's also not clear how the camera switching would work on the software side, maybe Linux just deals with it if the device tree nodes for the second camera get added.
+
Switching to the front camera
 +
$ sudo media-ctl -d /dev/media1 --links "ov5640 3-004c":0->"sun6i-csi":0[0]
 +
$ sudo media-ctl -d /dev/media1 --links "gc2145 3-003c":0->"sun6i-csi":0[1]
 +
</source>
  
The camera hardware pipeline is controlled with <code>/dev/media0</code> and <code>media-ctl</code>, the result is on <code>/dev/video0</code>
+
The camera hardware pipeline is controlled with <code>/dev/media1</code> and <code>media-ctl</code>, the result is on <code>/dev/video1</code>
  
 
<source lang="shell-session">
 
<source lang="shell-session">
pine-dontbeevil:~# media-ctl --set-v4l2 '"ov5640 2-003c":0[fmt:UYVY8_2X8/1280x720]'
+
pinephone:~# media-ctl -d /dev/media1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720]'
pine-dontbeevil:~# ffmpeg -s 1280x720 -f video4linux2 -i /dev/video0 -vframes 1 selfie.jpg
+
pinephone:~# ffmpeg -s 1280x720 -f video4linux2 -i /dev/video1 -vframes 1 selfie.jpg
 
</source>
 
</source>
  
[[File:PinePhone-rearcam-dev.png|frameless]]
+
[[File:Rose.jpg|none|left|400px]]
  
 
=== Camera Flash ===
 
=== Camera Flash ===
  
The camera flash consist out of a SG Micro SGM3140 "500mA Buck/Boost Charge Pump LED Driver" and a EHP-C04 LED.
+
''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.
  
The driver supports Flash and Torch mode, the first being brighter but only for about 300ms, when it switches to Torch mode. Torch mode is lower brightness but can be turned on continuously.
+
Controlling the flash from user space is possible via sysfs and via v4l2:
  
 
<source lang="shell-session">
 
<source lang="shell-session">
# Turn on Flash, wait 0.3s, turn off
+
# Torch on
echo 1 > /sys/class/leds/sgm3140-flash/flash_strobe
+
$ echo 1 > /sys/class/leds/white\:flash/brightness
sleep 0.3
+
# Torch off
echo 0 > /sys/class/leds/sgm3140-flash/flash_strobe
+
$ echo 0 > /sys/class/leds/white\:flash/brightness
 +
# Activate flash
 +
$ echo 1 > /sys/class/leds/white\:flash/flash_strobe
 
</source>
 
</source>
  
 
<source lang="shell-session">
 
<source lang="shell-session">
# Turn on Torch
+
# Torch on
echo 1 > /sys/class/leds/sgm3140-flash/brightness
+
$ v4l2-ctl -d /dev/video1 -c led_mode=2
# Turn off Torch
+
# Torch off
echo 0 > /sys/class/leds/sgm3140-flash/flash_strobe
+
$ 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
 
</source>
 
</source>
  
 +
=== WiFi ===
  
=== 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:
  
?
+
<source lang="shell-session">
 +
pinephone:~# sudo rmmod 8723cs
 +
pinephone:~# sudo modprobe 8723cs
 +
</source>
  
 
=== Bluetooth ===
 
=== 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.
 +
 +
<source lang="shell-session">
 +
pinephone:~# sudo service bluetooth start
 +
pinephone:~# bluetoothctl
 +
# scan on
 +
[NEW] 00:11:22:33:44:55
 +
# pair 00:11:22:33:44:55
 +
</source>
  
There is a patch series on lkml. A v2 for this series is in progress.
+
To use bluetooth headphones with pulseaudio, the package <code>pulseaudio-bluez</code> is required.
  
 
=== Modem ===
 
=== Modem ===
  
Receiving text messages works. Calls should work too but weren't tested yet.
+
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):
 +
 
 +
<source lang="shell-session">
 +
pinephone:~# sudo apk add ofonoctl
 +
pinephone:~# ofonoctl wan --connect --append-dns
 +
</source>
 +
 
 +
Or use only modemmanager which integrates better with phosh.
 +
 
 +
<source lang="shell-session">
 +
pinephone:~# sudo mmcli -m 0 --create-bearer='apn=APN.NAME,user=USERNAME,password=PASSWORD,allowed-auth=chap,allow-roaming=no'
 +
pinephone:~# sudo nmcli c add type gsm ifname cdc-wdm0 con-name OPERATOR-NAME apn APN.NAME user USERNAME password PASSWORD
 +
 
 +
# Check your connection
 +
pinephone:~# nmcli c  # check status of the connection named OPERATOR-NAME as above
 +
pinephone:~# nmcli d    #  check status of cdc-wdm0
 +
</source>
 +
 
 +
In order to connect to the serial console of the modem, you need a terminal application. One option is to use <code>minicom</code>.
 +
 
 +
<source lang="shell-session">
 +
# apk add minicom
 +
</source>
 +
 
 +
Connect to the console by issuing:
 +
 
 +
<source lang="shell-session">
 +
# minicom -D /dev/ttyUSB2
 +
</source>
 +
 
 +
The command <code>AT</code> returns OK:
 +
 
 +
<source lang="shell-session">
 +
AT
 +
OK
 +
</source>
 +
 
 +
The command <code>ATI</code> returns some version information from the modem:
 +
 
 +
<source lang="shell-session">
 +
ATI
 +
Quectel
 +
EG25
 +
Revision: EG25GGBR07A07M2G
 +
 
 +
OK
 +
</source>
 +
 
 +
The command <code>AT+QDAI</code> (Digital Audio Interface Configure) is used to configure the digital audio interface. <code>AT+QDAI?</code> returns the current configuration:
 +
 
 +
<source lang="shell-session">
 +
AT+QDAI?
 +
+QDAI: 3,0,0,4,0,0,1,1
 +
 
 +
OK
 +
</source>
 +
 
 +
 
 +
Some more details on how to configure the modem is available [https://megous.com/dl/tmp/modem.txt here]. The reference for the available commands is the [https://itbrainpower.net/downloadables/Quectel_EC25_EC21_AT_Commands_Manual_V1.0.pdf EC25 & EC21 AT Commands Manual].
 +
 
 +
==== VoLTE ====
 +
 
 +
The EG25 modem in the PinePhone comes preloaded with VoLTE profiles for a few providers. The modem can handle VoLTE fully internally so nothing complicated is required on the postmarketOS side. PostmarketOS tries to set the VoLTE profile automatically. If that fails it can also be set manually:
 +
 
 +
<source lang="shell-session">
 +
# List of embedded VoLTE profiles
 +
$ echo 'AT+QMBNCFG="list"' | atinout - /dev/EG25.AT -
 +
+QMBNCFG: "List",0,1,1,"ROW_Generic_3GPP",0x0501081F,201901141
 +
+QMBNCFG: "List",1,0,0,"VoLTE-ATT",0x0501033C,201909271
 +
+QMBNCFG: "List",2,0,0,"hVoLTE-Verizon",0x05010141,201911251
 +
+QMBNCFG: "List",3,0,0,"Sprint-VoLTE",0x05010205,201908141
 +
+QMBNCFG: "List",4,0,0,"Commercial-TMO_VoLTE",0x05010505,201811231
 +
+QMBNCFG: "List",5,0,0,"Telus-Commercial_VoLTE",0x05800C43,201912031
 +
+QMBNCFG: "List",6,0,0,"Commercial-SBM",0x05011C18,201904021
 +
+QMBNCFG: "List",7,0,0,"Commercial-DT",0x05011F1C,201905311
 +
+QMBNCFG: "List",8,0,0,"Reliance_OpnMkt",0x05011B38,201910161
 +
+QMBNCFG: "List",9,0,0,"TF_Germany_VoLTE",0x05010C1B,201909201
 +
+QMBNCFG: "List",10,0,0,"TF_Spain_VoLTE",0x05010CFA,201909261
 +
+QMBNCFG: "List",11,0,0,"Volte_OpenMkt-Commercial-CMCC",0x05012071,201904281
 +
+QMBNCFG: "List",12,0,0,"OpenMkt-Commercial-CT",0x05011322,201911081
 +
+QMBNCFG: "List",13,0,0,"OpenMkt-Commercial-CU",0x05011505,201807052
 +
 
 +
OK
 +
 
 +
# Select the profile most applicable to your provider, or use the Generic one if nothing matches
 +
$ echo 'AT+QMBNCFG="select","ROW_Generic_3GPP"' | atinout - /dev/EG25.AT -
 +
 
 +
OK
 +
# Enable calling over ip (VoLTE)
 +
$ echo 'AT+QCFG="ims",1' | atinout - /dev/EG25.AT -
 +
 
 +
OK
 +
# Reboot the modem to apply the settings
 +
$ echo 'AT+CFUN=1,1' | atinout - /dev/EG25.AT -
 +
</source>
 +
 
 +
After this process VoLTE should be used when available. To check the status while in a call you can run the CLCC command:
 +
 
 +
<source lang="shell-session">
 +
$ echo 'AT+CLCC' | atinout - /dev/EG25.AT -
 +
 
 +
+CLCC: 1,1,0,1,0,"",128
 +
+CLCC: 2,1,0,1,0,"",128
 +
 
 +
OK
 +
</source>
 +
 
 +
The "1" in the 4th column on the second CLCC row means it's currently calling with VoLTE, when it's "0" it's calling over the legacy phone network.
  
 
=== Sensors ===
 
=== 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
+
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
  
 
<source lang="shell-session">
 
<source lang="shell-session">
dontbeevil:~# cat /sys/bus/iio/devices/iio\:device0/name
+
pinephone:~# cat /sys/bus/iio/devices/iio\:device0/name
 
mpu6050
 
mpu6050
dontbeevil:~# cat /sys/bus/iio/devices/iio\:device0/in_accel_z_raw
+
pinephone:~# cat /sys/bus/iio/devices/iio\:device0/in_accel_z_raw
 
-17594
 
-17594
dontbeevil:~# echo "Verified gravity still exists"
+
pinephone:~# echo "Verified gravity still exists"
 
</source>
 
</source>
  
Line 259: Line 469:
 
echo 0 > /sys/class/leds/$COLOR/brightness
 
echo 0 > /sys/class/leds/$COLOR/brightness
 
</source>
 
</source>
 +
 +
You may turn on and off the blue led by issuing:
 +
 +
<source lang="shell-session">
 +
# echo 1 > /sys/devices/platform/leds/leds/pinephone\:blue\:user/brightness
 +
# echo 0 > /sys/devices/platform/leds/leds/pinephone\:blue\:user/brightness
 +
</source>
 +
 +
Make sure you run these commands as root (<code>sudo -i</code>), <code>sudo echo 1 > /sys/devices/platform/leds/leds/pinephone\:blue\:user/brightness</code>, won't work.
  
 
=== Audio ===
 
=== Audio ===
Line 266: Line 485:
 
Sound output should work after unmuting <code>AIF1 Slot 0 digital</code>
 
Sound output should work after unmuting <code>AIF1 Slot 0 digital</code>
  
 +
Start by making sure alsa-utils are installed:
 +
<source lang="shell-session">
 +
$ sudo apk add alsa-utils
 +
</source>
 +
 +
You may use amixer, or alsamixer to unmute the required channels, and to control the volume:
 +
 +
Amixer:
 +
<source lang="shell-session">
 +
$ amixer scontents
 +
$ amixer sset Master unmute
 +
</source>
 +
 +
Alsamixer (use terminal keyboard input to use up/down/left/right keys, to set volume and select devices):
 +
<source lang="shell-session">
 +
$ alsamixer -V all
 +
</source>
 +
 +
Test the sound output by issuing:
 +
 +
<source lang="shell-session">
 +
$ speaker-test -c3
 +
</source>
 +
 +
== 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
 +
<source lang="shell-session">
 +
postmarketos:~# sudo rm /boot/initramfs*
 +
postmarketos:~# sudo apk fix linux-postmarketos-allwinner
 +
</source>
 +
=== 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:
 +
<source lang="shell-session">
 +
#!/bin/sh
 +
export QTWEBENGINE_DISABLE_SANDBOX=1
 +
</source>
 +
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 [https://gitlab.com/postmarketOS/pmaports/issues/435 here] and [https://gitlab.com/postmarketOS/pmaports/issues/32 here].
  
 
== See also ==
 
== See also ==
* {{MR|308|pmaports}} Initial merge request
+
* {{MR|308|pmaports}} Initial merge request (Don't be evil devkit)
 +
* {{MR|583|pmaports}} Initial merge request (PinePhone)
 +
* [https://wiki.pine64.org/index.php/PinePhone_v1.1_-_Braveheart PinePhone v1.1 - Braveheart] - schematics, changes and known issues on the PINE64 wiki

Latest revision as of 21:53, 20 October 2020

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 currently is in beta. 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
Category community
Original software postmarketOS
Hardware
Chipset Allwinner A64
CPU 4x 1152 MHz Cortex-A53
GPU Mali-400 MP2
Display 720x1440 IPS
Storage 16 GB / 32 GB
Memory 2 GB / 3 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

Users owning this device


Installation

The PinePhone will boot from a bootable microSD card if it is plugged, and fall back to booting from internal eMMC. You can install postmarketOS on either of them (or even on both).

microSD card

For now, it is recommended to build your own image with pmbootstrap. Run the following commands, and consult the installation guide for details.

$ pmbootstrap init # vendor: pine64, device: pinephone, select "stable" channel
$ pmbootstrap install --sdcard=/dev/mmcblk...  # add --fde for full disk encryption

After that, unplug the microSD card from your PC, put it in your PinePhone and postmarketOS should boot up. (Note that the microSD fits in the SIM slot, but that does of course not work.)

For a quick demo, you may use a test image from images.postmarketos.org instead of building your own image with pmbootstrap.

$ wget https://images.postmarketos.org/pinephone/pine64-pinephone-20200724-phosh-v20.05-installer.img.xz
$ unxz pine64-pinephone-20200724-phosh-v20.05-installer.img.xz
$ sudo dd if=pine64-pinephone-20200724-phosh-v20.05-installer.img of=/dev/mmcblk... status=progress

Internal eMMC

Create a new image with pmbootstrap (recommended, details) or download a pre-built image (see above).

$ pmbootstrap init # vendor: pine64, device: pinephone, select "stable" channel
$ pmbootstrap install # add --fde for full disk encryption
$ pmbootstrap export
$ realpath /tmp/postmarketOS-export/pine64-pinephone.img 
/home/user/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/pine64-pinephone.img

Download Jumpdrive and flash it to a microSD card. This is the recommended way to install postmarketOS to the internal eMMC for now (doing it from the on-device installer is planned).

$ wget https://github.com/dreemurrs-embedded/Jumpdrive/releases/download/0.5/pine64-pinephone.img.xz
$ sha512sum pine64-pinephone.img.xz 
b8edbc1ada0a8e71da9ef8d457480967e97de508cffb57b41ad1928a013acc3772f7bb7a2b4c3436af05a8c849f2ffb816780b4f749ec17df211ec3477880d80  pine64-pinephone.img.xz
$ unxz pine64-pinephone.img.xz
$ sudo dd if=pine64-pinephone.img of=/dev/mmcblk... status=progress

Insert the microSD card into your PinePhone and boot it up. It should display the Jumpdrive splash screen.

Connect your PinePhone via USB to your PC and use lsblk to figure out the correct target partition. You should see two new devices in lsblk. One device has just one small ~40 MiB partition, this is the microSD card with JumpDrive. The other device is the eMMC. You should flash to the device itself (typically of the form /dev/sdx) and not a partition (/dev/sdxn where n is a number).

$ lsblk
(now plug the USB cable)
$ lsblk

Prepare the final dd command to flash postmarketOS to the eMMC and triple-check that you have put the right device as of argument. Then run it.

$ sudo dd if=~/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/pine64-pinephone.img of=/dev/sd... status=progress

As of writing, Jumpdrive doesn't have a shutdown procedure (#2). Maybe leave it on for a few more minutes after the dd command is done to make sure that the data isn't still in some cache, but really written to the eMMC (the author had data corruption once, which might be related to turning it off too quickly after flashing). Then press the power button for five seconds to power it off. Remove the microSD card, turn it on again. The PinePhone should boot into postmarketOS.

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 SDA SCL
5V / VBUS VBAT GND

The VBUS pin is powered by USB and is 5V. The second power pin is VBAT, which connects to the battery voltage. The I2C and interrupt lines have pull-ups on the phone side. The I2C lines are pulled up to 3V3 by the phone.

Components

Component Model Driver
Touchscreen Goodix GT917S 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-G 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 Unknown model 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, a driver for the front camera (GC2145) is being developed in the kernel fork for the phone development.

Both camera's share the same bus for the video stream, due to this it's impossible to use both cameras at the same time, but you can switch between the cameras by keeping one of them in reset and then restarting the whole pipeline.

Switching to the rear camera
$ sudo media-ctl -d /dev/media1 --links "gc2145 3-003c":0->"sun6i-csi":0[0]
$ sudo media-ctl -d /dev/media1 --links "ov5640 3-004c":0->"sun6i-csi":0[1]

Switching to the front camera
$ sudo media-ctl -d /dev/media1 --links "ov5640 3-004c":0->"sun6i-csi":0[0]
$ sudo media-ctl -d /dev/media1 --links "gc2145 3-003c":0->"sun6i-csi":0[1]

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
Rose.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

Or use only modemmanager which integrates better with phosh.

pinephone:~# sudo mmcli -m 0 --create-bearer='apn=APN.NAME,user=USERNAME,password=PASSWORD,allowed-auth=chap,allow-roaming=no'
pinephone:~# sudo nmcli c add type gsm ifname cdc-wdm0 con-name OPERATOR-NAME apn APN.NAME user USERNAME password PASSWORD

# Check your connection
pinephone:~# nmcli c   # check status of the connection named OPERATOR-NAME as above
pinephone:~# nmcli d    #  check status of cdc-wdm0

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.

VoLTE

The EG25 modem in the PinePhone comes preloaded with VoLTE profiles for a few providers. The modem can handle VoLTE fully internally so nothing complicated is required on the postmarketOS side. PostmarketOS tries to set the VoLTE profile automatically. If that fails it can also be set manually:

# List of embedded VoLTE profiles
$ echo 'AT+QMBNCFG="list"' | atinout - /dev/EG25.AT -
+QMBNCFG: "List",0,1,1,"ROW_Generic_3GPP",0x0501081F,201901141
+QMBNCFG: "List",1,0,0,"VoLTE-ATT",0x0501033C,201909271
+QMBNCFG: "List",2,0,0,"hVoLTE-Verizon",0x05010141,201911251
+QMBNCFG: "List",3,0,0,"Sprint-VoLTE",0x05010205,201908141
+QMBNCFG: "List",4,0,0,"Commercial-TMO_VoLTE",0x05010505,201811231
+QMBNCFG: "List",5,0,0,"Telus-Commercial_VoLTE",0x05800C43,201912031
+QMBNCFG: "List",6,0,0,"Commercial-SBM",0x05011C18,201904021
+QMBNCFG: "List",7,0,0,"Commercial-DT",0x05011F1C,201905311
+QMBNCFG: "List",8,0,0,"Reliance_OpnMkt",0x05011B38,201910161
+QMBNCFG: "List",9,0,0,"TF_Germany_VoLTE",0x05010C1B,201909201
+QMBNCFG: "List",10,0,0,"TF_Spain_VoLTE",0x05010CFA,201909261
+QMBNCFG: "List",11,0,0,"Volte_OpenMkt-Commercial-CMCC",0x05012071,201904281
+QMBNCFG: "List",12,0,0,"OpenMkt-Commercial-CT",0x05011322,201911081
+QMBNCFG: "List",13,0,0,"OpenMkt-Commercial-CU",0x05011505,201807052

OK

# Select the profile most applicable to your provider, or use the Generic one if nothing matches
$ echo 'AT+QMBNCFG="select","ROW_Generic_3GPP"' | atinout - /dev/EG25.AT -

OK
# Enable calling over ip (VoLTE)
$ echo 'AT+QCFG="ims",1' | atinout - /dev/EG25.AT -

OK
# Reboot the modem to apply the settings
$ echo 'AT+CFUN=1,1' | atinout - /dev/EG25.AT -

After this process VoLTE should be used when available. To check the status while in a call you can run the CLCC command:

$ echo 'AT+CLCC' | atinout - /dev/EG25.AT -

+CLCC: 1,1,0,1,0,"",128
+CLCC: 2,1,0,1,0,"",128

OK

The "1" in the 4th column on the second CLCC row means it's currently calling with VoLTE, when it's "0" it's calling over the legacy phone network.

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