Jump to content

Qualcomm SDM845 (qualcomm-sdm845)

From postmarketOS Wiki
Revision as of 16:45, 5 December 2023 by Caleb (talk | contribs) (Initial installation guide)
Qualcomm Snapdragon 845
Manufacturer Qualcomm
Name Snapdragon 845
Codename generic-sdm845
Released 2020
Type generic
Hardware
Chipset Qualcomm Snapdragon 845 (SDM845)
CPU Octa-core (4x 2.8 GHz Kryo 385 Gold & 4x 1.7 GHz Kryo 385 Silver)
GPU Adreno 630
Display 1080 x 2280 AMOLED
Storage 64/128/256 GB
Memory 4/6/8 GB
Architecture aarch64
Software
Original software Android
Original version 8.0
Extended version 13 on Linux 4.9
postmarketOS
Category testing
Pre-built images no
Mainline yes
postmarketOS kernel Mainline
Unixbench Whet/Dhry score 6029.9


Warning WARNING: Support for booting these devices using U-Boot and UEFI is still a work in progress and implementation details are subject to change, be careful if you plan on tinkering with this.

Some SDM845 devices in the Community category are supported by a new generic device target where U-Boot is used as an intermediary bootloader to provide a standard UEFI environment and allow for bootloaders like systemd-boot to be used. This allows for nicer multi-booting, the potential to revert to previous kernels if an upgrade causes regressions, and a whole myriad of other benefits.

Supported Devices

Device Codename Category
OnePlus 6 oneplus-enchilada community
OnePlus 6T oneplus-fajita community
SHIFT SHIFT6mq shift-axolotl community
Xiaomi Pocophone F1 / POCO F1 xiaomi-beryllium community

Installing

Follow the standard installation guide, choose generic-sdm845 as the device codename. You MUST add --split as an argument when invoking pmbootstrap install!

Flashing

Follow the instructions on the wiki page for you device to enter fastboot mode.

The rootfs should be flashed to userdata, this can be done with

pmbootstrap flasher flash_rootfs --partition userdata

Where to flash the boot partition (the ESP which U-Boot must access) depends on the device. We ideally need a partition of at least 128MiB, although 96MiB might be enough. The simplest option is to use one of the system partitions, on devices like the SHIFT6mq which don't have one, the recovery partition is a safe bet. On the OnePlus 6 there is a partition called "op2" which seems to contain some firstboot logs, it's plenty big so a good option as well.

No matter which partition you choose, U-Boot will find it automatically on boot, just ensure that it's big enough!

Pmbootstrap doesn't integrate super nicely with split images, so we have to flash the ESP manually for now (replace "system" with your partition of choice)

fastboot flash system ~/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/generic-sdm845-boot.img

Installing U-Boot

U-Boot is flashed to the boot partition, tricking ABL into thinking that it's running a Linux kernel, as well as letting ABL populate some useful properties in the devicetree.

TODO TODO: Detect beryllium variant from cmdline and adjust DTB selection

Initial U-Boot binaries can be found here, you may want to check for a newer release. Download the one corresponding to your device (see the table at the top of this page), for PocoPhone F1 users, see the device wiki page to determine which display variant you have. How to handle upgrading U-Boot is still undecided.

Having flashed postmarketOS, you can now flash U-Boot and reboot into your new installation as follows (replacing $CODENAME) with your device codename.

fastboot erase dtbo flash boot u-boot-$CODENAME.img reboot

Background info

There is a major difference between this generic support compared to how these devices run mainline currently. By running U-Boot, we get rid of almost all of the Android specific quirks. We run a normal UEFI bootloader (systemd-boot), and really the only odd part is the lack of a keyboard.

The requirements for a nice UEFI experience are pretty simple, we need a UEFI capable bootloader like U-Boot, and an EFI System Partition (ESP) on the device. The ESP is a special partition which the bootloader can read, systemd-boot is installed as /EFI/BOOT/BOOTAA64.efi, this well-known path is checked by U-Boot which will then run the EFI binary. The ESP also contains the kernel, initramfs, DTBs, and any bootloader configuration.

Migrating an existing installation

On postmarketOS, the pmOS_boot partition (mounted to /boot) doubles as the ESP. The current installation method for sdm845 devices involves shoving the boot and root partitions into a single disk image and then flashing that entire disk image to the userdata partition on the device. We refer to this as "subpartitioning".

U-Boot doesn't know how to access the boot partition in this nested form, hence, it is non-trivial to migrate an existing postmarketOS installation (although possible with some caveats).