Difference between revisions of "OnePlus 5 (oneplus-cheeseburger)"

From postmarketOS
Jump to: navigation, search
m (chipset)
m (Include separators in GitLab links)
 
(34 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Infobox device
 
{{Infobox device
| manufacturer = Oneplus
+
| manufacturer = OnePlus
| name = 5 <!-- e.g. Desire -->
+
| name = 5/5T
| codename = oneplus-cheeseburger <!-- e.g. htc-bravo -->
+
| codename = oneplus-cheeseburger, oneplus-dumpling
| image = File:cheeseburger.jpg
+
| image = File:OnePlus-5-GNOME-Mainline.jpg
 
| imagecaption =  
 
| imagecaption =  
 
| releaseyear = 2017
 
| releaseyear = 2017
| originalsoftware = Android 7.1.1 on Linux 4.4 (upgradeable to Android 9 on Linux 4.4) <!-- e.g. Android 2 -->
+
| originalsoftware = Android 7.1.1 (up to Android 9) on Linux 4.4
| chipset = Qualcomm MSM8998 Snapdragon 835 <!-- e.g. Qualcomm QSD8250 Snapdragon S1 -->
+
| chipset = Qualcomm MSM8998 Snapdragon 835
| cpu = Octa-core (4x2.45 GHz Cortex-A73 & 4x1.90 GHz Cortex-A53) <!-- e.g. 1.0 GHz Scorpion -->
+
| cpu = 4x 2.45 GHz Cortex-A73 + 4x 1.90 GHz Cortex-A53
| gpu = Adreno 540 <!-- e.g. Adreno 200 -->
+
| gpu = Adreno 540
| storage = 64GB/128GB <!-- e.g. 512 MB -->
+
| display = 1080x1920/1080x2160 Optic AMOLED (5/5T)
| display = 1080x1920 AMOLED <!-- e.g. 480x800 AMOLED -->
+
| storage = 64 or 128 GB UFS 2.1
| memory = 6GB/8GB <!-- e.g. 576 MB -->
+
| memory = 6 or 8 GB LPDDR4X RAM
| architecture = aarch64 <!-- One of these: armhf, armv7, aarch64, x86, x86_64 -->
+
| architecture = aarch64
 
<!-- the following status_* questions should be answered with Y - yes, P - partial, N - no, or left blank (for untested or unknown) -->
 
<!-- the following status_* questions should be answered with Y - yes, P - partial, N - no, or left blank (for untested or unknown) -->
| status_usbnet = N <!-- USB networking does work? then put Y here and delete this comment -->
+
| status_usbnet = Y
| status_flashing = <!-- Flashing with "pmbootstrap flasher" works? Put Y here. It works the same for everything coming below. -->
+
| status_flashing = Y
| status_touch = N <!-- Touch screen is working? You can also answer these questions with P for partially. -->
+
| status_touch = Y
| status_screen = Y <!-- The display is working? -->
+
| status_screen = Y
 
| status_wifi = N <!-- Wireless network works? -->
 
| status_wifi = N <!-- Wireless network works? -->
| status_xwayland = <!-- Showing X11 applications in a Wayland compositor (Weston, KWin, ...) works? -->
+
| status_xwayland = Y
| status_fde = <!-- When installing with full disk encryption, can you type in the password with the on screen keyboard? -->
+
| status_fde = N <!-- When installing with full disk encryption, can you type in the password with the on screen keyboard? -->
| status_mainline = N <!-- Instead of a Linux kernel fork, it is possible to run mainline. -->
+
| status_mainline = P
 
| status_battery = N <!-- Charging the battery with charging-sdl is possible -->
 
| status_battery = N <!-- Charging the battery with charging-sdl is possible -->
 
| status_3d = N <!-- Hardware accelerated 3D graphics (e.g. with freedreno) -->
 
| status_3d = N <!-- Hardware accelerated 3D graphics (e.g. with freedreno) -->
Line 32: Line 32:
 
| status_mobiledata = N <!-- Connecting to the Internet via cellular network. -->
 
| status_mobiledata = N <!-- Connecting to the Internet via cellular network. -->
 
| status_sms = N <!-- Sending and receiving short messages works as intended. -->
 
| status_sms = N <!-- Sending and receiving short messages works as intended. -->
 +
| status_otg = Y
 
| status_calls = N <!-- Talking to other people over the cellular network. -->
 
| status_calls = N <!-- Talking to other people over the cellular network. -->
| status = <!-- Text displayed in the "not booting" table on the Devices page , e.g "kernel compiles, doesn't boot" -->
+
| booting = yes
| booting = yes <!-- The device is booting at all, can be yes/no *IMPORTANT* -->
 
  
 
<!-- you can also use these lines if you need to:
 
<!-- you can also use these lines if you need to:
if the device haven't originally ran Android OS, e.g. Nokia N900
 
| n-android =  ✔
 
Version of the kernel that pmos is running
 
| pmoskernel = 4.4.153
 
 
see Unixbench page on wiki
 
see Unixbench page on wiki
 
| whet_dhry = 0.0
 
| whet_dhry = 0.0
Is OTG available, not used in wiki
 
| status_otg =
 
 
-->
 
-->
 
}}
 
}}
  
 
== Contributors ==
 
== Contributors ==
* R0551
+
* deathmist
 +
* R0551 (mainlining)
  
 
== Maintainer(s) ==
 
== Maintainer(s) ==
R0551
+
deathmist
 
<!-- Only if this device doesn't run on linux-postmarketos yet! -->
 
<!-- Only if this device doesn't run on linux-postmarketos yet! -->
 
<!-- This person needs to be willing to answer questions from users of this device -->
 
<!-- This person needs to be willing to answer questions from users of this device -->
Line 58: Line 53:
 
== Users owning this device ==
 
== Users owning this device ==
 
{{Device owners}}
 
{{Device owners}}
<!-- autogenerated, use {{Owns device|devicepage|notes}} on your profile page -->
+
<!--
<!-- use _ instead of spaces in device page name, e.g. {{Owns device|Nokia_N900|broken screen}}-->
+
If you own this device, you can add the text below or something similar under your user profile:
<!-- you may need to purge page cache to see changes (more->purge cache)-->
+
== Owns Devices ==
<!-- you can use {{My devices}} on your profile page to show table with all your devices -->
+
{{Owns device|OnePlus_5_(oneplus-cheeseburger)|Additional notes by you e.g. Broken touchscreen digitizer}}
 +
{{My devices}}
 +
-->
 +
== Fastboot mode ==
 +
The OnePlus 5/5T uses <code>fastboot</code> as its flashing protocol.
 +
 
 +
To enter fastboot mode, hold {{button|Volume Up}} while powering on the device. Release the button when <code>FastBoot Mode</code> can be seen on the display.
 +
 
 +
== Installation ==
 +
 
 +
=== Unlocking the bootloader ===
 +
If your bootloader is still locked at this point, you need to unlock it to proceed.
 +
 
 +
'''WARNING: Doing this WILL delete all your data on the device as a security precaution, so backup all your data before continuing!'''
 +
 
 +
There are plenty of guides online describing how to do this, but the run-down should be as follows:
 +
# Enable <code>Developer options</code> by tapping the build number 7 times in <code>Settings</code> > <code>About</code>
 +
# Go back and enter <code>Developer options</code> to enable both <code>USB Debugging</code> and <code>OEM Unlocking</code>
 +
# Install the <code>android-tools-fastboot</code> or <code>android-tools</code> package depending on your machine's distro
 +
# Power down your OnePlus 5 & enter <code>fastboot</code> mode using the [https://wiki.postmarketos.org/wiki/OnePlus_5_(oneplus-cheeseburger)#Fastboot_mode instructions above this section]
 +
# Open a terminal window and verify your phone is displayed under <code>fastboot devices</code> to continue
 +
# Run <code>fastboot oem unlock</code> and follow the instructions on screen. Navigate menus with {{button|Volume Up/Down}} and select an option with the {{button|Power}} button.
 +
# Congrats, you should now have an unlocked bootloader on your device!
 +
 
 +
=== Setup build env & create flashables ===
 +
Install <code>[https://wiki.postmarketos.org/wiki/Installing_pmbootstrap pmbootstrap]</code> on your build machine and start following the steps below:
 +
<div style="width: calc(100%-320px); overflow: auto;">
 +
pmbootstrap init
 +
pmbootstrap install
 +
</div>
 +
'''NOTICE: Both <code>phosh</code> and <code>plasma-mobile</code> are NOT working at all currently; this should be solved later by mainlining and using the <code>freedreno</code> DRM driver for graphics & <code>mesa</code> 3D acceleration.'''
 +
 
 +
=== Flashing the device ===
 +
To begin the flashing process, boot your device to <code>fastboot</code> mode (if you haven't already). The standard flashing process goes as follows:
 +
pmbootstrap flasher flash_rootfs
 +
pmbootstrap flasher flash_kernel
 +
sudo fastboot reboot
  
== How to enter flash mode ==
+
If you instead want to install the pmOS root filesystem on <code>userdata</code> partition (around 56 or 120 GB) instead of the <code>system</code> partition (3 GB), run the following instead as the flash_rootfs command:
The OnePlus 5 uses Fastboot as the flashing protocol.
+
pmbootstrap flasher flash_rootfs --partition userdata
  
To enter Fastboot mode, hold Volume Up while powering on the device. Let go of Volume Up when "Fastboot mode" displays on the screen.
+
During e.g. rapid kernel development you can simply boot the new image instead of always flashing to the device <code>boot</code> partition like so:
 +
pmbootstrap flasher boot
 +
 
 +
== LEDs ==
 +
Currently you can control a whole bunch of the LEDs present on the device via <code>sysfs</code> by writing values to their brightness control files as <code>root</code>:
 +
 
 +
Screen brightness (0-255) can be adjusted:
 +
<code>echo 255 > /sys/class/leds/lcd-backlight/brightness</code>
 +
 
 +
The backlight for physical buttons can be enabled (1) or disabled (0):
 +
<code>echo 1 > /sys/class/leds/button-backlight/brightness</code>
 +
 
 +
Notification light color & brightness (0-255) are controllable:
 +
* Red: <code>echo 255 > /sys/class/leds/red/brightness</code>
 +
* Green: <code>echo 255 > /sys/class/leds/green/brightness</code>
 +
* Blue: <code>echo 255 > /sys/class/leds/blue/brightness</code>
 +
 
 +
Control of the rear camera flashlight (<code>/sys/class/leds/torch-light*/brightness</code>) seems to be broken via sysfs anyway right now.
 +
 
 +
== Partition layout ==
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
<code>oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sda</code>
 +
<div class="mw-collapsible-content">
 +
Disk /dev/sda: 113.55 GiB, 121911640064 bytes, 29763584 sectors
 +
Disk model: KLUDG8V1EE-B0C1
 +
Units: sectors of 1 * 4096 = 4096 bytes
 +
Sector size (logical/physical): 4096 bytes / 4096 bytes
 +
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
 +
Disklabel type: gpt
 +
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20
 +
 +
Device    Start      End  Sectors  Size Name
 +
/dev/sda1      6        7        2    8K ssd
 +
/dev/sda2      8    8199    8192    32M persist
 +
/dev/sda3  8200    73735    65536  256M cache
 +
/dev/sda4  73736    73991      256    1M misc
 +
/dev/sda5  73992    74119      128  512K keystore
 +
/dev/sda6  74120    74247      128  512K frp
 +
/dev/sda7  74248    76807    2560    10M oem_dycnvbk
 +
/dev/sda8  76808    79367    2560    10M oem_stanvbk
 +
/dev/sda9  79368    79623      256    1M param
 +
/dev/sda10 79624    81647    2024  7.9M reserve1
 +
/dev/sda11 81648    85695    4048  15.8M reserve2
 +
/dev/sda12 85696    85823      128  512K config
 +
/dev/sda13 85824 29763578 29677755 113.2G userdata
 +
</div>
 +
</div>
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
<code>oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdb</code>
 +
<div class="mw-collapsible-content">
 +
Disk /dev/sdb: 4 MiB, 4194304 bytes, 1024 sectors
 +
Disk model: KLUDG8V1EE-B0C1
 +
Units: sectors of 1 * 4096 = 4096 bytes
 +
Sector size (logical/physical): 4096 bytes / 4096 bytes
 +
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
 +
Disklabel type: gpt
 +
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20
 +
 +
Device    Start  End Sectors Size Name
 +
/dev/sdb1      6  1018    1013  4M xbl
 +
</div>
 +
</div>
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
<code>oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdc</code>
 +
<div class="mw-collapsible-content">
 +
Disk /dev/sdc: 4 MiB, 4194304 bytes, 1024 sectors
 +
Disk model: KLUDG8V1EE-B0C1
 +
Units: sectors of 1 * 4096 = 4096 bytes
 +
Sector size (logical/physical): 4096 bytes / 4096 bytes
 +
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
 +
Disklabel type: gpt
 +
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20
 +
 +
Device    Start  End Sectors Size Name
 +
/dev/sdc1      6  1018    1013  4M xblbak
 +
</div>
 +
</div>
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
<code>oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdd</code>
 +
<div class="mw-collapsible-content">
 +
Disk /dev/sdd: 128 MiB, 134217728 bytes, 32768 sectors
 +
Disk model: KLUDG8V1EE-B0C1
 +
Units: sectors of 1 * 4096 = 4096 bytes
 +
Sector size (logical/physical): 4096 bytes / 4096 bytes
 +
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
 +
Disklabel type: gpt
 +
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20
 +
 +
Device    Start  End Sectors  Size Name
 +
/dev/sdd1      6    13      8    32K reserve
 +
/dev/sdd2    14    14      1    4K cdt
 +
/dev/sdd3    15  270    256    1M ddr
 +
/dev/sdd4    271 32762  32492 126.9M last_parti
 +
</div>
 +
</div>
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
<code>oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sde</code>
 +
<div class="mw-collapsible-content">
 +
Disk /dev/sde: 4 GiB, 4294967296 bytes, 1048576 sectors
 +
Disk model: KLUDG8V1EE-B0C1
 +
Units: sectors of 1 * 4096 = 4096 bytes
 +
Sector size (logical/physical): 4096 bytes / 4096 bytes
 +
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
 +
Disklabel type: gpt
 +
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20
 +
 +
Device      Start    End Sectors  Size Name
 +
/dev/sde1      6    133    128  512K rpm
 +
/dev/sde2    134    261    128  512K rpmbak
 +
/dev/sde3    262    773    512    2M tz
 +
/dev/sde4    774    1285    512    2M tzbak
 +
/dev/sde5    1286    1413    128  512K hyp
 +
/dev/sde6    1414    1541    128  512K hypbak
 +
/dev/sde7    1542    1545      4    16K sec
 +
/dev/sde8    1546    1673    128  512K pmic
 +
/dev/sde9    1674    1801    128  512K pmicbak
 +
/dev/sde10  1802  29961  28160  110M modem
 +
/dev/sde11  29962  34057    4096    16M dsp
 +
/dev/sde12  34058  35081    1024    4M mdtpsecapp
 +
/dev/sde13  35082  36105    1024    4M mdtpsecappbak
 +
/dev/sde14  36106  36361    256    1M dip
 +
/dev/sde15  36362  44553    8192    32M mdtp
 +
/dev/sde16  44554  46601    2048    8M abl
 +
/dev/sde17  46602  48649    2048    8M ablbak
 +
/dev/sde18  48650  52745    4096    16M LOGO
 +
/dev/sde19  52746  69129  16384    64M boot
 +
/dev/sde20  69130  85513  16384    64M boot_aging
 +
/dev/sde21  85514  871945  786432    3G system
 +
/dev/sde22 871946  888329  16384    64M recovery
 +
/dev/sde23 888330  888330      1    4K devinfo
 +
/dev/sde24 888331  888586    256    1M bluetooth
 +
/dev/sde25 888587  888714    128  512K keymaster
 +
/dev/sde26 888715  888842    128  512K keymasterbak
 +
/dev/sde27 888843  888970    128  512K cmnlib
 +
/dev/sde28 888971  889098    128  512K cmnlibbak
 +
/dev/sde29 889099  889226    128  512K cmnlib64
 +
/dev/sde30 889227  889354    128  512K cmnlib64bak
 +
/dev/sde31 889355  889418      64  256K apdp
 +
/dev/sde32 889419  889482      64  256K msadp
 +
/dev/sde33 889483  889483      1    4K dpo
 +
/dev/sde34 889484  897839    8356  32.7M splash
 +
/dev/sde35 897840  897840      1    4K limits
 +
/dev/sde36 897841  898096    256    1M toolsfv
 +
/dev/sde37 898097  900144    2048    8M logfs
 +
/dev/sde38 900145  900656    512    2M sti
 +
/dev/sde39 900657  900688      32  128K devcfg
 +
/dev/sde40 900689  917072  16384    64M logdump
 +
/dev/sde41 917073  917104      32  128K storsec
 +
/dev/sde42 917105  917136      32  128K storsecbak
 +
/dev/sde43 917137  917648    512    2M fw_4j1ed
 +
/dev/sde44 917649  918160    512    2M fw_8v1ee
 +
/dev/sde45 918161  918672    512    2M fw_4g9n4
 +
/dev/sde46 918673  919184    512    2M fw_4t0n8
 +
/dev/sde47 919185 1048570  129386 505.4M minidump
 +
/dev/sde48 927377  927377      0    0B last_parti
 +
</div>
 +
</div>
 +
<div class="toccolours mw-collapsible mw-collapsed" style="width: 620px; overflow: auto;">
 +
<code>oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdf</code>
 +
<div class="mw-collapsible-content">
 +
Disk /dev/sdf: 1.51 GiB, 1610612736 bytes, 393216 sectors
 +
Disk model: KLUDG8V1EE-B0C1
 +
Units: sectors of 1 * 4096 = 4096 bytes
 +
Sector size (logical/physical): 4096 bytes / 4096 bytes
 +
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
 +
Disklabel type: gpt
 +
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20
 +
 +
Device      Start    End Sectors  Size Name
 +
/dev/sdf1      6    517    512    2M modemst1
 +
/dev/sdf2    518  1029    512    2M modemst2
 +
/dev/sdf3    1030  1541    512    2M fsg
 +
/dev/sdf4    1542  1542      1    4K fsc
 +
/dev/sdf5    1543  1670    128  512K md5
 +
/dev/sdf6    1671 263814  262144    1G vendor
 +
/dev/sdf7  263815 393182  129368 505.4M reserve3
 +
/dev/sdf8  267863 267863      0    0B last_parti
 +
</div>
 +
</div>
  
== Installation ==
 
 
<!-- add more sections below as necessary, e.g. Wifi, photos, ... -->
 
<!-- add more sections below as necessary, e.g. Wifi, photos, ... -->
  
== See also ==
+
== Mainline kernel ==
<!--
+
This is heavily W.I.P currently, but it's coming along quite nicely. [https://imgur.com/a/Tb3LAK7 Here is an imgur gallery with some of the progress showcased]!
Link to related gitlab issues or merge requests like the following (replace CHANGEME with the ID, e.g. 1234):
+
 
* {{MR|CHANGEME|pmaports}} Initial merge request
+
Here's a list of stuff that is currently (Linux 5.6.13) known to be working (in at least some capacity):
* {{issue|CHANGEME|pmaports}} Some related issue
+
 
You can also add normal web links:
+
* UFS internal storage (<code>CONFIG_PHY_QCOM_UFS=y</code>)
* [https://redmine.replicant.us/projects/replicant/wiki/GalaxyS2I9100 Replicant wiki page]
+
* Display (via [https://github.com/JamiKettunen/linux-mainline-oneplus5/commit/b54a7b03cbeb115ed6b5b7c6220a790c77271506 <code>simplefb</code>] & <code>CONFIG_FB_SIMPLE=y</code>)
-->
+
* Xorg & Wayland (tested with [https://i.imgur.com/VgsaOtY.jpg MATE] & [https://i.imgur.com/dLItMIm.jpg Weston] respectively)
<!--
+
* Bluetooth (requires <code>crbtfw21.tlv</code> and <code>crnv21.bin</code> blobs from [https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/qca linux-firmware] + a <code>rc-update add bluetoothd default</code> in userspace along with the relevant <code>bluez</code> packages)
If you manage to get your device packages merged, uncomment links below and change DEVICE_CODENAME with the actual one.
+
* Touchscreen (using mainline Synaptics RMI4 I2C driver; [https://github.com/JamiKettunen/linux-mainline-oneplus5/commit/6cfe1d217457ecdf16eb8250f7a7da4acf188ad6 definition in DTS] + [https://github.com/JamiKettunen/linux-mainline-oneplus5/commit/54b1c972561d087851f3bf61dd86e203f87ec8bd relevant defconfig changes])
* [https://gitlab.com/postmarketOS/pmaports/tree/master/device/device-DEVICE_CODENAME Device package]
+
* Anbox (install <code>postmarketos-anbox</code>; [https://github.com/JamiKettunen/linux-mainline-oneplus5/commit/392d26fea261cc9b7264997d2c1df79b919bee02 defconfig changes I made for LXC stuff])
* [https://gitlab.com/postmarketOS/pmaports/tree/master/device/linux-DEVICE_CODENAME Kernel package]
+
* Power button ([https://github.com/JamiKettunen/linux-mainline-oneplus5/blob/wiki/arch/arm64/boot/dts/qcom/pm8998.dtsi#L41-L55 in DTS])
-->
+
* Volume keys ([https://github.com/JamiKettunen/linux-mainline-oneplus5/commit/51d74de3a157ee8861f5961895a3163498c15260 added under MSM8998 PMIC GPIOs])
 +
* Keypad backlight (only applicable to regular OnePlus 5; [https://github.com/JamiKettunen/linux-mainline-oneplus5/commit/518b4fa6d8874815a7652e78cc59560675829884 added under MSM8998 PMIC GPIOs] & controllable with <code>/sys/class/leds/button-backlight/brightness</code>)
 +
 
 +
And that's about it for now. Next up would be USB as I've been doing this blind and don't exactly have a great setup to debug stuff / get logs :p
 +
 
 +
Check the links below for source code.
 +
 
 +
=== Building ===
 +
It's easiest to build mainline (for pmOS anyway) with [https://wiki.postmarketos.org/wiki/Mainlining_Guide#pmbootstrap_setup pmbootstrap], so get that setup and remember the install location (in this guide <code>~/pmOS/pmbootstrap</code> is an example).
 +
 
 +
After you've run through the [https://wiki.postmarketos.org/wiki/OnePlus_5_(oneplus-cheeseburger)#Installation installation steps found on this site at least once] please <code>pmbootstrap extract</code> & save the produced downstream <code>boot.img</code> to a known location as we'll reuse the initramfs found inside later.
 +
 
 +
Next start following the instructions below:
 +
 
 +
  git clone https://github.com/JamiKettunen/linux-mainline-oneplus5
 +
  cd linux-mainline-oneplus5/
 +
  source ~/pmOS/pmbootstrap/helpers/envkernel.sh    # adjust to match where you've cloned PMB yourself
 +
  make defconfig
 +
  make -j`nproc`
 +
 
 +
=== Boot image generation ===
 +
Now that the kernel image and DTBs have been built we can assemble a bootable Android-friendly boot.img (assuming you're still in the root of the cloned kernel dir):
 +
 
 +
  pmbootstrap chroot -- apk add abootimg android-tools mkbootimg dtbtool
 +
  export DEVICE=`pmbootstrap config device | cut -d'-' -f2` WORK=`pmbootstrap config work` PMOS_BOOT_IMG_PATH="~/pmOS/downstream-boot.img"
 +
  export TEMP="$WORK/chroot_native/tmp/mainline/" DTB="$PWD/.output/arch/arm64/boot/dts/qcom/msm8998-$DEVICE.dtb"
 +
  rm -r "$TEMP"; mkdir -p "$TEMP"
 +
  cat .output/arch/arm64/boot/Image.gz "$DTB" > "$TEMP/Image.gz-dtb"
 +
  cp "$PMOS_BOOT_IMG_PATH" "$TEMP/boot.img"          # replace "$PMOS_BOOT_IMG_PATH" with the known location of a pmOS downstream boot.img
 +
  pmbootstrap chroot -- abootimg -u /tmp/mainline/boot.img -k /tmp/mainline/Image.gz-dtb -c "bootsize=67108864"
 +
 
 +
At this point you get to choose whether to <code>boot</code> the new kernel image or more "permanently" <code>flash</code> it on the device's boot partition instead ^^
 +
 
 +
Boot: <code>pmbootstrap chroot -- fastboot boot /tmp/mainline/boot.img</code>
 +
 
 +
Flash: <code>pmbootstrap chroot -- fastboot flash boot /tmp/mainline/boot.img</code>
 +
 
 +
'''NOTE: Sometimes running <code>pmbootstrap flasher list_devices</code> once is needed to get the device detected in fastboot mode!'''
 +
 
 +
== Links ==
 +
* {{MR|908|pmaports}} Initial merge request
 +
* {{MR|1110|pmaports}} OnePlus 5T merge request
 +
* [https://gitlab.com/postmarketOS/pmaports/-/tree/master/device/testing/device-oneplus-cheeseburger OnePlus 5 device package]
 +
* [https://gitlab.com/postmarketOS/pmaports/-/tree/master/device/testing/device-oneplus-dumpling OnePlus 5T device package]
 +
* [https://gitlab.com/postmarketOS/pmaports/-/tree/master/device/testing/linux-oneplus-msm8998 Shared kernel package]
 +
* [https://github.com/android-linux-stable/op5/tree/lineage-17.1 LineageOS downstream kernel fork]
 +
* [https://github.com/JamiKettunen/linux-mainline-oneplus5 Device mainline kernel W.I.P source (deathmist)]
 +
* [https://github.com/torvalds/linux Linux mainline kernel source (torvalds)]

Latest revision as of 10:24, 25 May 2020

OnePlus 5/5T
Manufacturer OnePlus
Name 5/5T
Codename oneplus-cheeseburger, oneplus-dumpling
Released 2017
Category testing
Original software Android 7.1.1 (up to Android 9) on Linux 4.4
Hardware
Chipset Qualcomm MSM8998 Snapdragon 835
CPU 4x 2.45 GHz Cortex-A73 + 4x 1.90 GHz Cortex-A53
GPU Adreno 540
Display 1080x1920/1080x2160 Optic AMOLED (5/5T)
Storage 64 or 128 GB UFS 2.1
Memory 6 or 8 GB LPDDR4X RAM
Architecture aarch64
Features
USB Networking
Works
Flashing
Works
Touchscreen
Works
Display
Works
WiFi
Broken
Xwayland
Works
FDE
Broken
Mainline
Partial
Battery
Broken
3D Acceleration
Broken
Accelerometer
Audio
Broken
Bluetooth
Broken
Camera
Broken
GPS
Mobile data
Broken
SMS
Broken
Calls
Broken
USB OTG
Works



Contributors

  • deathmist
  • R0551 (mainlining)

Maintainer(s)

deathmist

Users owning this device

Fastboot mode

The OnePlus 5/5T uses fastboot as its flashing protocol.

To enter fastboot mode, hold Volume Up while powering on the device. Release the button when FastBoot Mode can be seen on the display.

Installation

Unlocking the bootloader

If your bootloader is still locked at this point, you need to unlock it to proceed.

WARNING: Doing this WILL delete all your data on the device as a security precaution, so backup all your data before continuing!

There are plenty of guides online describing how to do this, but the run-down should be as follows:

  1. Enable Developer options by tapping the build number 7 times in Settings > About
  2. Go back and enter Developer options to enable both USB Debugging and OEM Unlocking
  3. Install the android-tools-fastboot or android-tools package depending on your machine's distro
  4. Power down your OnePlus 5 & enter fastboot mode using the instructions above this section
  5. Open a terminal window and verify your phone is displayed under fastboot devices to continue
  6. Run fastboot oem unlock and follow the instructions on screen. Navigate menus with Volume Up/Down and select an option with the Power button.
  7. Congrats, you should now have an unlocked bootloader on your device!

Setup build env & create flashables

Install pmbootstrap on your build machine and start following the steps below:

pmbootstrap init
pmbootstrap install

NOTICE: Both phosh and plasma-mobile are NOT working at all currently; this should be solved later by mainlining and using the freedreno DRM driver for graphics & mesa 3D acceleration.

Flashing the device

To begin the flashing process, boot your device to fastboot mode (if you haven't already). The standard flashing process goes as follows:

pmbootstrap flasher flash_rootfs
pmbootstrap flasher flash_kernel
sudo fastboot reboot

If you instead want to install the pmOS root filesystem on userdata partition (around 56 or 120 GB) instead of the system partition (3 GB), run the following instead as the flash_rootfs command:

pmbootstrap flasher flash_rootfs --partition userdata

During e.g. rapid kernel development you can simply boot the new image instead of always flashing to the device boot partition like so:

pmbootstrap flasher boot

LEDs

Currently you can control a whole bunch of the LEDs present on the device via sysfs by writing values to their brightness control files as root:

Screen brightness (0-255) can be adjusted: echo 255 > /sys/class/leds/lcd-backlight/brightness

The backlight for physical buttons can be enabled (1) or disabled (0): echo 1 > /sys/class/leds/button-backlight/brightness

Notification light color & brightness (0-255) are controllable:

  • Red: echo 255 > /sys/class/leds/red/brightness
  • Green: echo 255 > /sys/class/leds/green/brightness
  • Blue: echo 255 > /sys/class/leds/blue/brightness

Control of the rear camera flashlight (/sys/class/leds/torch-light*/brightness) seems to be broken via sysfs anyway right now.

Partition layout

oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sda

Disk /dev/sda: 113.55 GiB, 121911640064 bytes, 29763584 sectors
Disk model: KLUDG8V1EE-B0C1 
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: gpt
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20

Device     Start      End  Sectors   Size Name
/dev/sda1      6        7        2     8K ssd
/dev/sda2      8     8199     8192    32M persist
/dev/sda3   8200    73735    65536   256M cache
/dev/sda4  73736    73991      256     1M misc
/dev/sda5  73992    74119      128   512K keystore
/dev/sda6  74120    74247      128   512K frp
/dev/sda7  74248    76807     2560    10M oem_dycnvbk
/dev/sda8  76808    79367     2560    10M oem_stanvbk
/dev/sda9  79368    79623      256     1M param
/dev/sda10 79624    81647     2024   7.9M reserve1
/dev/sda11 81648    85695     4048  15.8M reserve2
/dev/sda12 85696    85823      128   512K config
/dev/sda13 85824 29763578 29677755 113.2G userdata

oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdb

Disk /dev/sdb: 4 MiB, 4194304 bytes, 1024 sectors
Disk model: KLUDG8V1EE-B0C1 
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: gpt
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20

Device     Start   End Sectors Size Name
/dev/sdb1      6  1018    1013   4M xbl

oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdc

Disk /dev/sdc: 4 MiB, 4194304 bytes, 1024 sectors
Disk model: KLUDG8V1EE-B0C1 
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: gpt
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20

Device     Start   End Sectors Size Name
/dev/sdc1      6  1018    1013   4M xblbak

oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdd

Disk /dev/sdd: 128 MiB, 134217728 bytes, 32768 sectors
Disk model: KLUDG8V1EE-B0C1 
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: gpt
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20

Device     Start   End Sectors   Size Name
/dev/sdd1      6    13       8    32K reserve
/dev/sdd2     14    14       1     4K cdt
/dev/sdd3     15   270     256     1M ddr
/dev/sdd4    271 32762   32492 126.9M last_parti

oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sde

Disk /dev/sde: 4 GiB, 4294967296 bytes, 1048576 sectors
Disk model: KLUDG8V1EE-B0C1 
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: gpt
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20

Device      Start     End Sectors   Size Name
/dev/sde1       6     133     128   512K rpm
/dev/sde2     134     261     128   512K rpmbak
/dev/sde3     262     773     512     2M tz
/dev/sde4     774    1285     512     2M tzbak
/dev/sde5    1286    1413     128   512K hyp
/dev/sde6    1414    1541     128   512K hypbak
/dev/sde7    1542    1545       4    16K sec
/dev/sde8    1546    1673     128   512K pmic
/dev/sde9    1674    1801     128   512K pmicbak
/dev/sde10   1802   29961   28160   110M modem
/dev/sde11  29962   34057    4096    16M dsp
/dev/sde12  34058   35081    1024     4M mdtpsecapp
/dev/sde13  35082   36105    1024     4M mdtpsecappbak
/dev/sde14  36106   36361     256     1M dip
/dev/sde15  36362   44553    8192    32M mdtp
/dev/sde16  44554   46601    2048     8M abl
/dev/sde17  46602   48649    2048     8M ablbak
/dev/sde18  48650   52745    4096    16M LOGO
/dev/sde19  52746   69129   16384    64M boot
/dev/sde20  69130   85513   16384    64M boot_aging
/dev/sde21  85514  871945  786432     3G system
/dev/sde22 871946  888329   16384    64M recovery
/dev/sde23 888330  888330       1     4K devinfo
/dev/sde24 888331  888586     256     1M bluetooth
/dev/sde25 888587  888714     128   512K keymaster
/dev/sde26 888715  888842     128   512K keymasterbak
/dev/sde27 888843  888970     128   512K cmnlib
/dev/sde28 888971  889098     128   512K cmnlibbak
/dev/sde29 889099  889226     128   512K cmnlib64
/dev/sde30 889227  889354     128   512K cmnlib64bak
/dev/sde31 889355  889418      64   256K apdp
/dev/sde32 889419  889482      64   256K msadp
/dev/sde33 889483  889483       1     4K dpo
/dev/sde34 889484  897839    8356  32.7M splash
/dev/sde35 897840  897840       1     4K limits
/dev/sde36 897841  898096     256     1M toolsfv
/dev/sde37 898097  900144    2048     8M logfs
/dev/sde38 900145  900656     512     2M sti
/dev/sde39 900657  900688      32   128K devcfg
/dev/sde40 900689  917072   16384    64M logdump
/dev/sde41 917073  917104      32   128K storsec
/dev/sde42 917105  917136      32   128K storsecbak
/dev/sde43 917137  917648     512     2M fw_4j1ed
/dev/sde44 917649  918160     512     2M fw_8v1ee
/dev/sde45 918161  918672     512     2M fw_4g9n4
/dev/sde46 918673  919184     512     2M fw_4t0n8
/dev/sde47 919185 1048570  129386 505.4M minidump
/dev/sde48 927377  927377       0     0B last_parti

oneplus5:~# fdisk -l -o Device,Start,End,Sectors,Size,Name /dev/sdf

Disk /dev/sdf: 1.51 GiB, 1610612736 bytes, 393216 sectors
Disk model: KLUDG8V1EE-B0C1 
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: gpt
Disk identifier: 98101B32-BBE2-4BF2-A06E-2BB33D000C20

Device      Start    End Sectors   Size Name
/dev/sdf1       6    517     512     2M modemst1
/dev/sdf2     518   1029     512     2M modemst2
/dev/sdf3    1030   1541     512     2M fsg
/dev/sdf4    1542   1542       1     4K fsc
/dev/sdf5    1543   1670     128   512K md5
/dev/sdf6    1671 263814  262144     1G vendor
/dev/sdf7  263815 393182  129368 505.4M reserve3
/dev/sdf8  267863 267863       0     0B last_parti


Mainline kernel

This is heavily W.I.P currently, but it's coming along quite nicely. Here is an imgur gallery with some of the progress showcased!

Here's a list of stuff that is currently (Linux 5.6.13) known to be working (in at least some capacity):

And that's about it for now. Next up would be USB as I've been doing this blind and don't exactly have a great setup to debug stuff / get logs :p

Check the links below for source code.

Building

It's easiest to build mainline (for pmOS anyway) with pmbootstrap, so get that setup and remember the install location (in this guide ~/pmOS/pmbootstrap is an example).

After you've run through the installation steps found on this site at least once please pmbootstrap extract & save the produced downstream boot.img to a known location as we'll reuse the initramfs found inside later.

Next start following the instructions below:

 git clone https://github.com/JamiKettunen/linux-mainline-oneplus5
 cd linux-mainline-oneplus5/
 source ~/pmOS/pmbootstrap/helpers/envkernel.sh     # adjust to match where you've cloned PMB yourself
 make defconfig
 make -j`nproc`

Boot image generation

Now that the kernel image and DTBs have been built we can assemble a bootable Android-friendly boot.img (assuming you're still in the root of the cloned kernel dir):

 pmbootstrap chroot -- apk add abootimg android-tools mkbootimg dtbtool
 export DEVICE=`pmbootstrap config device | cut -d'-' -f2` WORK=`pmbootstrap config work` PMOS_BOOT_IMG_PATH="~/pmOS/downstream-boot.img"
 export TEMP="$WORK/chroot_native/tmp/mainline/" DTB="$PWD/.output/arch/arm64/boot/dts/qcom/msm8998-$DEVICE.dtb"
 rm -r "$TEMP"; mkdir -p "$TEMP"
 cat .output/arch/arm64/boot/Image.gz "$DTB" > "$TEMP/Image.gz-dtb"
 cp "$PMOS_BOOT_IMG_PATH" "$TEMP/boot.img"          # replace "$PMOS_BOOT_IMG_PATH" with the known location of a pmOS downstream boot.img
 pmbootstrap chroot -- abootimg -u /tmp/mainline/boot.img -k /tmp/mainline/Image.gz-dtb -c "bootsize=67108864"

At this point you get to choose whether to boot the new kernel image or more "permanently" flash it on the device's boot partition instead ^^

Boot: pmbootstrap chroot -- fastboot boot /tmp/mainline/boot.img

Flash: pmbootstrap chroot -- fastboot flash boot /tmp/mainline/boot.img

NOTE: Sometimes running pmbootstrap flasher list_devices once is needed to get the device detected in fastboot mode!

Links