Android启用串口控制台和Recovery中启用adb

Platform: RK3368

OS: Android 6.0

Kernel: 3.10.0


1. console

debug模式下默认就开启了控制台,所以可以直接在串口中使用,而user模式编译的系统ro.debuggable=0,即控制台默认时关闭的,控制台需要ro.debuggable=1才会启动,所以可以修改build/core/main.mk强制开启调试.在recovery中启用串口控制台,也是一样的.

diff --git a/core/main.mk b/core/main.mk
index aa617c3..3b93009 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -325,7 +325,7 @@ ifneq (,$(user_variant))
     tags_to_install += debug
   else
     # Disable debugging in plain user builds.
-    enable_target_debugging :=
+    enable_target_debugging := true
   endif
 
   # Turn on Dalvik preoptimization for user builds, but only if not
@@ -361,7 +361,7 @@ ifeq (true,$(strip $(enable_target_debugging)))
   INCLUDE_TEST_OTA_KEYS := true
 else # !enable_target_debugging
   # Target is less debuggable and adbd is off by default
-  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
+  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
 endif # !enable_target_debugging
 
 ## eng ##

init.rc中ro.debuggable=1会触发开启控制台

service console /system/bin/sh
    class core
    console
    disabled
    user shell
    group shell log
    seclabel u:r:shell:s0

on property:ro.debuggable=1
    start console

2. adb

如果需要在recovery中开启adb,需要预设persist.sys.usb.config=mtp,adb来默认开启adb服务,并且设置 ro.adb.secure=1来关闭授权确认,因为recovery中没有界面来开启授权确认,否则会报未被授权错误:

error: device unauthorized.
This adbd's $ADB_VENDOR_KEYS is not set; try 'adb kill-server' if that seems wrong.
Otherwise check for a confirmation dialog on your device.

adbd服务定义在init.rc中,由init..usb.rc进行触发控制:

# adbd is controlled via property triggers in init..usb.rc
service adbd /sbin/adbd --root_seclabel=u:r:su:s0
    class core
    socket adbd stream 660 system system
    disabled
    seclabel u:r:adbd:s0

rk3368触发启动adbd服务定义在init.rk30board.usb.rc:

on property:sys.usb.config=adb
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 2207
    write /sys/class/android_usb/android0/idProduct 0006
    write /sys/class/android_usb/android0/functions ${sys.usb.config}
    write /sys/class/android_usb/android0/enable 1
    start adbd
    setprop sys.usb.state ${sys.usb.config}

你可能感兴趣的:(android,linux,rockchip)