Skip to content

Commit

Permalink
WIP -- testing fastbootd fix
Browse files Browse the repository at this point in the history
  • Loading branch information
juic3b0x committed Oct 2, 2022
1 parent 6e3689a commit 0b9ac8a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 21 deletions.
15 changes: 12 additions & 3 deletions device.mk
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ TARGET_USES_MKE2FS := true
TW_NO_SCREEN_BLANK := true
TW_EXCLUDE_APEX := true

# TWRP Debug Flags
TARGET_USES_LOGD := true
TWRP_EVENT_LOGGING := false
TWRP_INCLUDE_LOGCAT := true
TARGET_RECOVERY_DEVICE_MODULES += debuggerd
TW_RECOVERY_ADDITIONAL_RELINK_FILES += $(TARGET_OUT_EXECUTABLES)/debuggerd

# TWRP Installer
RECOVERY_INSTALLER_PATH := bootable/recovery/installer
USE_RECOVERY_INSTALLER := true

# Crypto
TW_USE_FSCRYPT_POLICY := 1
TW_INCLUDE_CRYPTO := true
Expand Down Expand Up @@ -119,9 +130,7 @@ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/prebuilt/libandroidicu.so:$(TARGET_COPY_OUT_RECOVERY)/root/system/lib64/libandroidicu.so \
$(LOCAL_PATH)/prebuilt/android.hardware.boot@1.0-impl-1.1-qti.so:$(TARGET_COPY_OUT_RECOVERY)/root/system/lib64/hw/android.hardware.boot@1.0-impl-1.1-qti.so \
$(LOCAL_PATH)/prebuilt/librecovery_updater_msm.so:$(TARGET_COPY_OUT_RECOVERY)/root/system/lib64/librecovery_updater_msm.so \
$(LOCAL_PATH)/prebuilt/libboot_control_qti.so:$(TARGET_COPY_OUT_RECOVERY)/root/system/lib64/libboot_control_qti.so \
$(LOCAL_PATH)/prebuilt/android.hardware.fastboot@1.0-impl-mock.so:$(TARGET_COPY_OUT_RECOVERY)/root/system/lib64/hw/android.hardware.fastboot@1.0-impl-mock.so

$(LOCAL_PATH)/prebuilt/libboot_control_qti.so:$(TARGET_COPY_OUT_RECOVERY)/root/system/lib64/libboot_control_qti.so
PRODUCT_PACKAGES += \
qcom_decrypt \
qcom_decrypt_fbe
Binary file removed prebuilt/android.hardware.fastboot@1.0-impl-mock.so
Binary file not shown.
1 change: 1 addition & 0 deletions recovery/root/init.recovery.qcom.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import /init.recovery.qcom_decrypt.rc
import /init.recovery.usb.rc

on init
write /sys/class/backlight/panel0-backlight/brightness 200
Expand Down
60 changes: 42 additions & 18 deletions recovery/root/init.recovery.usb.rc
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

on early-init
setprop sys.usb.configfs 0

on init
mkdir /config
mount configfs none /config
mkdir /config/usb_gadget/g1 0770 shell shell
write /config/usb_gadget/g1/bcdUSB 0x0200
write /config/usb_gadget/g1/idVendor 0x18d1
write /config/usb_gadget/g1/idProduct 0xd001
write /config/usb_gadget/g1/idVendor 0x22b8
write /config/usb_gadget/g1/idProduct 0x2e81
mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell
write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
mkdir /config/usb_gadget/g1/functions/ffs.adb
mkdir /config/usb_gadget/g1/functions/ffs.fastboot
mkdir /config/usb_gadget/g1/functions/mass_storage.0
mkdir /config/usb_gadget/g1/functions/mtp.gs0
write /config/usb_gadget/g1/os_desc/use 1
write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
mkdir /config/usb_gadget/g1/configs/b.1 0777 shell shell
symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
setprop sys.usb.configfs 1

on boot
Expand Down Expand Up @@ -77,21 +78,23 @@ on property:sys.usb.ffs.ready=1
symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
write /config/usb_gadget/g1/UDC ${sys.usb.controller}

on property:sys.usb.config=mtp && property:vendor.usb.use_ffs_mtp=1 && property:sys.usb.configfs=1
on property:sys.usb.config=none && property:sys.usb.configfs=1
write /config/usb_gadget/g1/UDC "none"
stop adbd
setprop sys.usb.ffs.ready 0
write /config/usb_gadget/g1/bDeviceClass 0
write /config/usb_gadget/g1/bDeviceSubClass 0
write /config/usb_gadget/g1/bDeviceProtocol 0
rm /config/usb_gadget/g1/configs/b.1/f1
symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1

on property:sys.usb.config=mtp && property:sys.usb.configfs=1
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "mtp"
rm /config/usb_gadget/g1/configs/b.1/f2
rm /config/usb_gadget/g1/configs/b.1/f3
rm /config/usb_gadget/g1/configs/b.1/f4
rm /config/usb_gadget/g1/configs/b.1/f5
write /config/usb_gadget/g1/idVendor 0x0B05
write /config/usb_gadget/g1/idProduct 0x7772
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
rmdir /config/usb_gadget/g1/functions/rndis.gs4
setprop sys.usb.state ${sys.usb.config}

on property:init.svc.adbd=stopped
setprop sys.usb.ffs.ready 0

# Recovery Mode- ADB & MTP
on property:sys.usb.config=mtp,adb && property:sys.usb.configfs=1
start adbd

Expand All @@ -111,6 +114,7 @@ on property:sys.usb.ffs.ready=1 && property:sys.usb.config=mtp,adb && property:s
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}

# Mass Storage USB Mode
on property:sys.usb.config=mass_storage && property:sys.usb.configfs=1
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "msc"
rm /config/usb_gadget/g1/configs/b.1/f1
Expand All @@ -128,6 +132,7 @@ on property:sys.usb.config=mass_storage && property:sys.usb.configfs=1
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}

# Mass Storage & ADB USB Mode
on property:sys.usb.config=mass_storage,adb && property:sys.usb.configfs=1
start adbd

Expand All @@ -149,6 +154,25 @@ on property:sys.usb.ffs.ready=1 && property:sys.usb.config=mass_storage,adb && p
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}

on property:ro.boot.usbcontroller=*
setprop sys.usb.controller ${ro.boot.usbcontroller}
write /sys/class/udc/${ro.boot.usbcontroller}/device/../mode peripheral
# FastbootD ADB Functionality
on property:sys.usb.config=adb && property:sys.usb.configfs=1
start adbd

on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb && property:sys.usb.configfs=1
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "Motorola Recovery ADB"
symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}

# FastbootD fastboot Functionality
on property:sys.usb.config=fastboot && property:sys.usb.ffs.ready=1 && property:sys.usb.configfs=1
write /config/usb_gadget/g1/UDC "none"
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "Motorola Recovery Fastboot"
rm /config/usb_gadget/g1/configs/b.1/f1
rm /config/usb_gadget/g1/configs/b.1/f2
rm /config/usb_gadget/g1/configs/b.1/f3
write /config/usb_gadget/g1/idVendor 0x22b8
write /config/usb_gadget/g1/idProduct 0x2e80
symlink /config/usb_gadget/g1/functions/ffs.fastboot /config/usb_gadget/g1/configs/b.1/f1
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}
2 changes: 2 additions & 0 deletions system.prop
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ro.adb.secure=0

# Audio
audio.offload.min.duration.secs=30
persist.vendor.audio.hac.enable=false
Expand Down

0 comments on commit 0b9ac8a

Please sign in to comment.