Skip to content

Instantly share code, notes, and snippets.

@steadfasterX
Last active July 17, 2023 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steadfasterX/aed2a1f397e387bd6efa01990aec761f to your computer and use it in GitHub Desktop.
Save steadfasterX/aed2a1f397e387bd6efa01990aec761f to your computer and use it in GitHub Desktop.
adb_boot_debug

Here are 3 ways to allow debugging on boot by connecting to adb. This is often called "insecure adb" - while it is not as insecure as you might thing 😉

STEP 1

Prepare authorization

Since A7 you have to authorize your adb server which either requires to add your adb pub key into the ramdisk (directly on / ) or you must put it in /data/misc/adb/adb_keys, e.g when in recovery. Details here.

important is that it has to have proper label and permission set. e.g when in recovery:

FORMAT(!) DATA in recovery!
REBOOT from recovery into recovery afterwards!
then go on:

adb push ~/.android/adbkey.pub /tmp/
adb shell
mkdir -p /data/misc/adb/

mv /tmp/adbkey.pub /data/misc/adb/adb_keys 
chcon u:object_r:adb_keys_file:s0 /data/misc/adb/adb_keys
chown system:shell /data/misc/adb/adb_keys 
chmod 640 /data/misc/adb/adb_keys

STEP 2

Choose an option and follow

Option A: Modding an existing boot.img (RECOMMENDED)

depending on the device you could unpack/repack your boot.img by one of

Whatever you use try first to: unpack -> repack -> flash (so without any modifications).

if that does not boot anymore use another tool. e.g. AIK does not work for the LG G4 sometimes so I use bootimgtool (-v qcom) instead.

default.prop (on newer android this might be named build.prop):
------------------------
ro.adb.secure=0
ro.secure=0
ro.debuggable=1
persist.service.adb.enable=1
persist.service.debuggable=1
persist.sys.usb.config=adb

# if that does not work try: persist.sys.usb.config=mtp,adb

Important:
remove ANY other line which contains one of settings above!!

Option B: when on A12

when on a12 (and likely later) and you just wanna enable adb logcat during build (not truly insecure, its more like half-insecure): https://github.com/crdroidandroid/android_build/commit/a9f4cd5493ead4134aba6e17e80c81eb104cdf43

for a full insecure (i.e allowing adb root and then e.g. adb shell dmesg during boot) use one of the other options.

Option C: Enable during build

Within your android source directory (replace <ROM> with the vendor path of your ROM you building for. e.g vendor/lineage/config/common.mk)

sed -i "s/secure=./secure=0/g" build/core/main.mk
sed -i "s/secure=./secure=0/g" vendor/<ROM>/config/common.mk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment