Jump to content

OnePlus 5 (oneplus-cheeseburger): Difference between revisions

From postmarketOS Wiki
Deathmist (talk | contribs)
m Mainline kernel: Update BT instructions & commit hashes for 5.6.13, mention working keypad backlight
Deathmist (talk | contribs)
m Mainline kernel: Mention sysfs control file for button-backlight
Line 292: Line 292:
* Power button ([https://github.com/JamiKettunen/linux-mainline-oneplus5/blob/wiki/arch/arm64/boot/dts/qcom/pm8998.dtsi#L41-L55 in DTS])
* 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])
* 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])
* 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
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

Revision as of 19:14, 20 May 2020

OnePlus 5
5T
Manufacturer OnePlus
Name 5
5T
Codename oneplus-cheeseburger, oneplus-dumpling
Released 2017
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
Software
Android 7.1.1 (up to Android 9) on Linux 4.4
Android 7.1.1 (up to Android 9) on Linux 4.4
no
Device package oneplus-dumpling device-oneplus-cheeseburger, oneplus-dumpling
Kernel package oneplus-dumpling linux-oneplus-cheeseburger, oneplus-dumpling
Features
Works
Works
Broken
Works
Touchscreen
Works
Multimedia
3D Acceleration
Broken
Broken
Camera
Broken
Connectivity
WiFi
Broken
Bluetooth
Broken
GPS
Untested
Modem
Calls
Broken
SMS
Broken
Mobile data
Broken
Miscellaneous
Broken
Works
Sensors
Untested

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

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

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

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

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

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


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