Custom bootloader for Qualcomm MSM8916/MSM8226/MSM8974/... devices
lk2nd is a custom bootloader for many different devices based on Qualcomm system-on-chips (SoCs), including smartphones, tablets, smartwatches and a few single board computers (SBCs). It simplifies booting standard operating systems by providing:
There are two different configurations:
lk2nd: "secondary" bootloader intended for devices where existing firmware cannot be replaced easily (most smartphones and tablets). In this configuration, lk2nd does not replace the stock bootloader. Instead, it is packed into an Android boot image, which is then loaded by the stock bootloader just like the original Android image. The real operating system can be placed in the boot partition with 512 KiB offset or stored in a ext2 file system. It does not have to be Android or even Linux, any kind of kernel can be packed into an Android boot image.
lk1st: primary bootloader intended for single-board computers (SBCs) and expert users. In this case, it is the "first" bootloader responsible for loading the main operating system.
This repository is a fork of the original open-source bootloader from Qualcomm (tag LA.BR.1.2.9.1-02310-8x16.0
),
which is a heavily modified version of the Little Kernel Embedded Operating System.
lk2nd-msm8916
: APQ8016, MSM8216, MSM8916, MSM8929, MSM8939lk2nd-msm8974
: MSM8974lk2nd-msm8226
: APQ8026, MSM8226, MSM8926See Chipsets page on the EFIDroid wiki for an exact mapping of LK targets to SoCs.
dts/msm8916/msm8916-mtp-smb1360.dts
)lk2nd-msm8916-appended-dtb.img
)dts/msm8916/msm8939-htc-m8qlul.dts
)dts/msm8916/msm8916-huawei-y635-l01.dts
)dts/msm8916/msm8916-samsung-r02.dts
)dts/msm8916/msm8916-samsung-r08.dts
)dts/msm8916/msm8916-samsung-r03.dts
)dts/msm8916/msm8916-samsung-r11.dts
)lk2nd-msm8974-appended-dtb.img
)dts/msm8226/msm8926-htc-memul.dts
)dts/msm8226/msm8926-huawei-g6-l11-vb.dts
)lk2nd-appended-dtb.img
)lk2nd.img
(available in Releases)lk2nd.img
using the stock flashing interface:
fastboot flash boot lk2nd.img
heimdall flash --BOOT lk2nd.img
If you get fastboot: error: Couldn't parse partition size '0x'
try one of the following workarounds:
fastboot flash:raw boot lk2nd.img
fastboot boot lk2nd.img
, then fastboot flash lk2nd lk2nd.img
lk2nd provides the standard Android fastboot protocol for flashing/booting Android boot images.
Press Volume Down
while booting to enter Fastboot mode.
Press Volume Up
while booting to boot into Recovery mode.
Note: If your stock bootloader uses the same key combinations, you need to wait a bit before pressing the volume keys. Usually, waiting until the screen turns on and/or the device vibrates should be enough to make the stock bootloader ignore the keys.
fastboot flash lk2nd lk2nd.img
can be used to update lk2nd directly from its
fastboot interface.
Note: fastboot flash boot boot.img
will flash the actual boot image with 512 KiB offset
into the boot partition. This is done to avoid replacing lk2nd (since it is also booted from
the boot partition).
Other fastboot commands work normally.
If the device shows up via fastboot you can get a log file from lk2nd using
fastboot oem lk_log && fastboot get_staged <output-file>
, where <output-file>
is either some text file to write to (e.g. output.txt
) or /dev/stdout
to
write the log to standard output.
Check Supported SoCs for the make target you should use below. (It depends on the SoC of your device.)
$ make TOOLCHAIN_PREFIX=arm-none-eabi- lk2nd-msmXXXX
Requirements:
arm-none-eabi-gcc
gcc-arm-none-eabi
gcc-arm-none-eabi
arm-none-eabi-gcc-cs
dtc
dtc
device-tree-compiler
dtc
dtc-dev
libfdt-dev
libfdt-devel
tar
Replace TOOLCHAIN_PREFIX
with the path to your tool chain.
lk2nd.img
is built and placed into build-lk2nd-msmXXXX/lk2nd.img
.
Note: Unlike lk2nd, lk1st is still experimental and therefore not described here yet.
dts/
. You just need model
and the
qcom,msm-id
/qcom,board-id
from downstream.Qualcomm maintains separate branches for various groups of SoCs. The branches can be seen on the Chipsets page on the EFIDroid wiki. This version of lk2nd is based on the LA.BR branch for MSM8916. There is a fork for MSM8953 based on the LA.UM branch.
The bootloader will work best when you use the correct branch for your device. Older platforms are usually kept around by Qualcomm but barely tested and may not work, or not even compile.
However, if make files for your SoC are present in this version or the MSM8953 fork you can try to enable it and see if it works well enough for you. Otherwise you would need to go through the Git history and pick the relevant commits to another branch from https://source.codeaurora.org/quic/la/kernel/lk/.
To enable support for a SoC that is already present in this repository:
project/lk2nd-<target>.mk
which looks like the others.Good luck!
Ask on Matrix or IRC.
#msm8916-mainline
)#lk2nd
)