问题:在recovery模式下,可以使用adb devices 、adb root、adb remount、adb reboot 但是输入adb shell 提示:exec "/system/bin/sh": No such file or directory 。
解决方法:
1.在bootable\recovery\etc\init.rc中增加如下内容: ( 开启console 控制台支持)
89 service adbd /sbin/adbd --root_seclabel=u:r:su:s0 --device_banner=recovery
90 disabled
91 socket adbd stream 660 system system
92 seclabel u:r:adbd:s0
93
94 service console /system/bin/sh
95 class core
96 console
97 disabled
98 user shell
99 group shell log readproc
100 seclabel u:r:shell:s0
101
102 # Always start adbd on userdebug and eng builds
103 on property:ro.debuggable=1
104 start console
105 write /sys/class/android_usb/android0/enable 1
106 start adbd
2.在\build\core\Makefile中增加如下内容:(copy bin 文件的内容到recovery.img中)
1209 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system/bin
1210 $(hide) cp -r $(PRODUCT_OUT)/system/bin/sh $(TARGET_RECOVERY_ROOT_OUT)/system/bin
1211 @echo Copying baseline ramdisk...
1212 $(hide) rsync -a $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) # "cp -Rf" fails to overwrite broken symlinks on Mac.
1213 @echo Modifying ramdisk contents...
1214 $(if $(BOARD_RECOVERY_KERNEL_MODULES), \
1215 $(call build-image-kernel-modules,$(BOARD_RECOVERY_KERNEL_MODULES),$(TARGET_RECOVERY_ROOT_OUT),,$(call intermediates-dir-for,PACKAGING,depmod_recovery)))
1216 $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc
1217 $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/
1218 $(hide) cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ || true # Ignore error when the src file doesn't exist.
1219 $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
1220 $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
1221 $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
1222 $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
1223 $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
1224 cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
1225 $(hide) $(foreach item,$(recovery_fstab), \
1226 cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
3.在external\mksh\Android.mk中增加如下内容:(在recovery模式下,二进制文件都是静态连接方式)
80 #LOCAL_SYSTEM_SHARED_LIBRARIES := libc (原来就有,注释掉就行)
81
82 LOCAL_STATIC_LIBRARIES := libc
83 LOCAL_FORCE_STATIC_EXECUTABLE := true
4.重新烧录recovery.img镜像文件,ok。
5.参考链接:
0.
Android recovery.img 支持adb shell
https://blog.csdn.net/makeyourprogress/article/details/74231123#commentBox
1.
Android recovery.img 支持adb shell
http://blog.csdn.net/chituhuan/article/details/52383655
2.
[IMX6Q][Android5.1]移植笔记 --- Recovery mode的shell功能实现(sh+toolbox)
http://blog.csdn.net/kris_fei/article/details/50921384
3.
Android Recovery 支持 Adb
http://www.jianshu.com/p/a0bdcce0a5e1