Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mod
diff options
context:
space:
mode:
authorDanTheMan827 <790119+DanTheMan827@users.noreply.github.com>2017-12-18 07:35:28 +0300
committerGitHub <noreply@github.com>2017-12-18 07:35:28 +0300
commit395539c0c65942b732a7f11b3a647ca390110269 (patch)
tree63d46df9ea4770b87e243c8338d0df3d4fb14730 /mod
parent64d3c5a9018d4c237c262946c68ef8fa23572d52 (diff)
USB improvements (#41)
Diffstat (limited to 'mod')
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/b0040_usb50
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p0000_config1
-rw-r--r--mod/hakchi/rootfs/etc/preinit.d/p7020_usb14
3 files changed, 54 insertions, 11 deletions
diff --git a/mod/hakchi/rootfs/etc/preinit.d/b0040_usb b/mod/hakchi/rootfs/etc/preinit.d/b0040_usb
index 06d7f79..f6facc8 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/b0040_usb
+++ b/mod/hakchi/rootfs/etc/preinit.d/b0040_usb
@@ -1,16 +1,46 @@
+disableUsbDevice(){
+ #disable usb
+ echo 0 > "/sys/devices/sunxi_usb/usb_role"
+}
+
+switchToUsbDevice(){
+ disableUsbDevice
+
+ # enable device mode
+ echo 2 > "/sys/devices/sunxi_usb/usb_role"
+
+ # make sure the usb gadgets are disabled
+ echo 0 > "/sys/devices/virtual/android_usb/android0/enable"
+}
+
+switchToUsbHost(){
+ # make sure the usb gadgets are disabled
+ echo 0 > "/sys/devices/virtual/android_usb/android0/enable"
+
+ disableUsbDevice
+
+ # enable host mode
+ echo 1 > "/sys/devices/sunxi_usb/usb_role"
+}
+
+getUsbStorageIds(){
+ find "/dev/bus/usb" -type c | while read device
+ do
+ hexdump -n 1 -s 32 "$device" -C | grep -e '^00000020 08' && echo "$device"
+ done
+}
+
checkUsbStorage(){
- local trigger="/sys/bus/platform/devices/sunxi_hcd_host0/otg_ed_test"
+ [ -z "$(getUsbStorageIds)" ] && return 1
+
local disk="/dev/sda1"
- if [ -f "$trigger" ]; then
- echo "1" > "$trigger"
- local timeout=5
- while [ $timeout -gt 0 ] && ! [ -b "$disk" ]; do
- echo "waiting for media $timeout"
- let timeout=timeout-1
- sleep 1
- done
- fi
+ local timeout=5
+ while [ $timeout -gt 0 ] && ! [ -b "$disk" ]; do
+ echo "waiting for media $timeout"
+ let timeout=timeout-1
+ sleep 1
+ done
[ -b "$disk" ] || return 1
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p0000_config b/mod/hakchi/rootfs/etc/preinit.d/p0000_config
index 2130e4e..c1d33a3 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p0000_config
+++ b/mod/hakchi/rootfs/etc/preinit.d/p0000_config
@@ -2,3 +2,4 @@ cfg_boot_stock='n'
cfg_disable_armet='y'
cfg_firmware='auto'
cfg_nes_extra_args='--ppu-palette 2'
+cfg_usb_host='y'
diff --git a/mod/hakchi/rootfs/etc/preinit.d/p7020_usb b/mod/hakchi/rootfs/etc/preinit.d/p7020_usb
index 5026a86..1ee0c31 100644
--- a/mod/hakchi/rootfs/etc/preinit.d/p7020_usb
+++ b/mod/hakchi/rootfs/etc/preinit.d/p7020_usb
@@ -1 +1,13 @@
-[ "$cf_usb" == "n" ] || checkUsbStorage
+if [ "$cfg_usb_host" != "y" ]; then
+ switchToUsbDevice
+else
+ # the usb driver needs some time to initialize
+ sleep 1
+
+ if [ -z "$(lsusb | grep -v "1d6b:0001")" ]; then
+ switchToUsbDevice
+ else
+ checkUsbStorage
+ fi
+
+fi