init.qcom.usb.rc: Move the usb init sequence from boot to post-fs
While trying to enumerate in any usb composition with diag involved,
the general expectation is as follows:
1. on boot (usb init sequence creates /dev/ffs-diag)
2. on boot (vendor.diag-router gets started)
3. on property:sys.usb.config triggers the composition rules
However, currently there is nothing to make sure that the diag-router
service starts exactly after the usb init sequence has run.
For example, if instead of the diag-router getting started after usb
init if it starts before the that, due to no retry mechanism in the
diag code it will fail to open the file node and the enumeration will
fail.
Similarly if the service starts after sys.usb.config trigger is
executed where the diag descriptors are expected, due to the
descriptors missing by that point the enumeration will fail.
Therefore to ensure that the process is executed in exact sequence,
moving the usb init sequence from on boot to on post-fs &
seperate the property where we are setting sys.usb.config to the
composition desired to execute on boot.
With this fix the sequence will be as follows:
1. on post-fs (usb init sequence creates /dev/ffs-diag)
2. on early-boot ( vendor.diag-router gets started)
3. on boot sys.usb.config getting assigned.
4. on property:sys.usb.config triggers to composition rules
Change-Id: I6244b7fcdc7828f9c346aab344d9d0bc25e9806f
diff --git a/etc/init.qcom.usb.rc b/etc/init.qcom.usb.rc
index 2653ee3..19896b0 100644
--- a/etc/init.qcom.usb.rc
+++ b/etc/init.qcom.usb.rc
@@ -42,7 +42,7 @@
setprop sys.usb.config mass_storage
setprop sys.usb.configfs 1
-on boot
+on post-fs
mount configfs none /config
mkdir /config/usb_gadget/g1 0770
mkdir /config/usb_gadget/g2 0770
@@ -108,9 +108,8 @@
exec u:r:vendor_qti_init_shell:s0 -- /vendor/bin/init.qcom.usb.sh
write /config/usb_gadget/g1/strings/0x409/product ${vendor.usb.product_string}
write /config/usb_gadget/g2/strings/0x409/product ${vendor.usb.product_string}
- setprop sys.usb.config ${persist.vendor.usb.config}
-on boot && property:vendor.usb.use_ffs_mtp=1
+on post-fs && property:vendor.usb.use_ffs_mtp=1
mkdir /config/usb_gadget/g1/functions/ffs.mtp
mkdir /config/usb_gadget/g1/functions/ffs.ptp
mkdir /dev/usb-ffs/mtp 0770 mtp mtp
@@ -118,6 +117,9 @@
mkdir /dev/usb-ffs/ptp 0770 mtp mtp
mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
+on boot
+ setprop sys.usb.config ${persist.vendor.usb.config}
+
on boot && property:vendor.usb.use_gadget_hal=1
setprop sys.usb.configfs 2