Qualcomm SDM845 (qualcomm-sdm845)

From postmarketOS
Qualcomm Snapdragon 845
Manufacturer Qualcomm
Name Snapdragon 845
Codename qualcomm-sdm845
Released 2020
Category testing
Pre-built images no
Original software Android
Original version 8.0
Extended version 13 on Linux 4.9
postmarketOS kernel Mainline
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
Type generic
Unixbench Whet/Dhry score 6029.9

This device is based on the Snapdragon 845.
See the SoC page for common tips, guides and troubleshooting steps
Icon 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


Where we 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 is probably 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.

The another option for 6/6T is custom partitioning (See OnePlus 6 (oneplus-enchilada)/Dual Booting and Custom Partitioning).

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

If the partition you chose is smaller than 256M, adjust the boot_size config option in pmbootstrap to ensure that the image pmbootstrap generates will fit, e.g. for a 96M ESP do pmbootstrap config boot_size 92.

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


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

The rootfs should be flashed to userdata, pmbootstrap doesn't integrate super nicely with split images, so we have to flash with fastboot manually:

fastboot flash userdata ~/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/qualcomm-sdm845-root.img

Then flash the boot image, run (replacing "system" with your partition of choice):

fastboot flash system ~/.local/var/pmbootstrap/chroot_native/home/pmos/rootfs/qualcomm-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.

Icon 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

Interacting with U-Boot

The U-Boot build includes some nice-to-haves for mobile users, by default it will boot the first EFI binary it can find (which will be our systemd-boot usually), however by pressing the power button at the autoboot prompt you can access a boot menu with some additional utilities.

Boot first available device

This will boot into postmarketOS

Enable USB mass storage

This will expose the entirety of the devices internal storage to your PC via USB. Be EXTREMELY careful not to overwrite the partition table as it's extremely easy to brick your device this way (although usually it's possible to recovery using EDL mode tools).

This is also super useful to retrieve logs from a device that won't boot, to fix booting by editing some config file, or whatever else you might want to do. Note that U-Boot upstream doesn't support the 4K block size used by UFS storage, support for this was added by Caleb and hasn't been reviewed or extensively tested. While they haven't hit any corruption, it's certainly within the realm of possibility.

Enable fastboot mode

The fastboot implementation in U-Boot doesn't currently support SCSI/UFS storage, and many other features aren't working properly. There isn't much useful stuff to do here for now.

Enable serial console gadget

The console gadget will expose a serial port to your PC from which you can access the U-Boot console, this is helpful for poking around U-Boot if you don't have access to the real serial port on your device.

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

Icon WARNING: The below rough guide depends on changes to the initramfs from the pmaports MR, specifically the initramfs changes, ensure that you install these packages if attempting before the MR has been merged.

Format the partition (delete and re-create) you want to use as your ESP (see above on how to pick) as fat32 and give it the pmOS_boot label. You should also set the type to EFI system partition. Then copy the old boot partition contents to it and re-format the old boot partition with a label like old_boot to avoid it getting picked up by mistake.

sudo apk add gptfdisk
sudo cgdisk /dev/sda # OnePlus 6 example using op2 partition (/dev/sda7)
# Delete op2 and re-create it, set the partition type to ef00
# then write and quit

# Format the new partition
sudo mkfs.vfat -n pmOS_boot /dev/sda7

Now adjust /etc/fstab with the new UUID.

~ # blkid | grep ESP
/dev/sda7: SEC_TYPE="msdos" LABEL_FATBOOT="pmOS_boot" LABEL="pmOS_boot" UUID="13A4-6D99" BLOCK_SIZE="4096" TYPE="vfat" PARTLABEL="ESP" PARTUUID="9d2028c9-09b6-451a-b5e7-d3151a3916e2"

We care about the UUID UUID="13A4-6D99", also be sure to check the partition type in /etc/fstab, it should be fat32.

Now get things ready to switch over the device package

mount /dev/sda7 /mnt
cp -r /boot/* /mnt/
rm /mnt/boot.img
rm /mnt/vmlinuz-dtb
umount /boot
mount --move /mnt /boot

Install the new device package, it will replace your existing one and pull in all the necessary dependencies

apk add device-qualcomm-sdm845

You can then fetch U-Boot and flash it using DD, or flash via fastboot as explained above. With that done, reboot into your device (now with UEFI!).

Validated by Caleb on a OnePlus 6 with FDE.

The only downside to this approach is the old and defunct boot partition, and having the rootfs be a loop-mounted subpartition.

See also