.. SPDX-License-Identifier: GPL-2.0+
.. sectionauthor:: Dzmitry Sankouski <dsankouski@gmail.com>

Snapdragon 845
================

About this
----------
This document describes the information about Qualcomm Snapdragon 845
supported boards and it's usage steps.

SDM845 - hi-end qualcomm chip, introduced in late 2017.
Mostly used in flagship phones and tablets of 2018.

U-Boot can be used as a replacement for Qualcomm's original ABL (UEFI) bootloader.
It is loaded as an Android boot image through ABL

Installation
------------
Build
^^^^^
Setup ``CROSS_COMPILE`` for aarch64 and build U-Boot for your board::

	$ export CROSS_COMPILE=<aarch64 toolchain prefix>
	$ make <your board name here, see Boards section>_defconfig
	$ make

This will build ``u-boot.bin`` in the configured output directory.

Generate FIT image
^^^^^^^^^^^^^^^^^^
See doc/uImage.FIT for more details

Pack android boot image
^^^^^^^^^^^^^^^^^^^^^^^
We'll assemble android boot image with ``u-boot.bin`` instead of linux kernel,
and FIT image instead of ``initramfs``. Android bootloader expect gzipped kernel
with appended dtb, so let's mimic linux to satisfy stock bootloader:

- create dump dtb::

	workdir=/tmp/prepare_payload
	mkdir -p "$workdir"
	cd "$workdir"
	mock_dtb="$workdir"/payload_mock.dtb

	dtc -I dts -O dtb -o "$mock_dtb" << EOF
	/dts-v1/;
	/ {
		memory {
			/* We expect the bootloader to fill in the size */
			reg = <0 0 0 0>;
		};

		chosen { };
	};
	EOF

- gzip u-boot ``gzip u-boot.bin``
- append dtb to gzipped u-boot: ``cat u-boot.bin.gz "$mock_dtb" > u-boot.bin.gz-dtb``

Now we've got everything to build android boot image:::

	mkbootimg --base 0x0 --kernel_offset 0x00008000 \
	--ramdisk_offset 0x02000000 --tags_offset 0x01e00000 \
	--pagesize 4096 --second_offset 0x00f00000 \
	--ramdisk "$fit_image" \
	--kernel u-boot.bin.gz-dtb \
	-o boot.img

Flash image with your phone's flashing method.

Boards
------------
starqlte
^^^^^^^^^^^^

The starqltechn is a production board for Samsung S9 (SM-G9600) phone,
based on the Qualcomm SDM845 SoC.

More information can be found on the `Samsung S9 page`_.

.. _Samsung S9 page: https://en.wikipedia.org/wiki/Samsung_Galaxy_S9
