user版本串口不能输入

 

描述:编译为userdebug版本时调试时,调试串口是可以正常输入输出的,编译为user版本时,串口就只能输出不能输入了。

原因:

 out/target/product/rk3288/recovery/root/init.rc  

  # Always start adbd on userdebug and eng builds
    on property:ro.debuggable=1
    write /sys/class/android_usb/android0/enable 1
    start adbd
    start console

可见,console的启用受ro.debuggable的控制,即是ro.debuggable=1时,才启动console。

可以通过指令getprop ro.debuggable查看该属性的值:

改属性在build/core/main.mk中定义:

ifeq (true,$(strip $(enable_target_debugging)))
  # Target is more debuggable and adbd is on by default
  ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
  # Enable Dalvik lock contention logging.
  ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
  # Include the debugging/testing OTA keys in this build.
  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
endif # !enable_target_debugging

解决:在main.mk中修改ro.debuggable=1

 

也可以不修改ro.debuggable的值:

system/core

diff --git a/rootdir/init.rc b/rootdir/init.rc
index a9af0b094..c9bdfab33 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -1043,14 +1043,14 @@ service console /system/bin/sh
     seclabel u:r:shell:s0
     setenv HOSTNAME console

 
-on init && property:ro.debuggable=1
+on init && property:ro.debuggable=0
     start console

 

posted @ 2020-06-10 20:15  M-kobe  阅读(1020)  评论(0)    收藏  举报