diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-12-17 23:49:01 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-12-17 23:49:01 +0300 |
commit | 40ef735db17dfd39e88d5bb1a1d6b56278de1d88 (patch) | |
tree | 83925e93322e395b98223502507b2d4b5c52744f /mods | |
parent | f939bd0194f05167ec83afbed4e957ea8fcbb0e6 (diff) |
USB host
Diffstat (limited to 'mods')
-rw-r--r-- | mods/hmods/clovercon.hmod | bin | 7494 -> 0 bytes | |||
-rw-r--r-- | mods/hmods/core-modules.hmod | bin | 0 -> 98949 bytes | |||
-rw-r--r-- | mods/mod_hakchi/hakchi/rootfs/etc/hakchi.png | bin | 4620 -> 0 bytes | |||
-rwxr-xr-x | mods/mod_hakchi/hakchi/rootfs/etc/init.d/S78clvcon | 47 | ||||
-rw-r--r-- | mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb | 137 | ||||
-rw-r--r-- | mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7020_usb | 16 | ||||
-rw-r--r-- | mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7070_firmware | 9 |
7 files changed, 101 insertions, 108 deletions
diff --git a/mods/hmods/clovercon.hmod b/mods/hmods/clovercon.hmod Binary files differdeleted file mode 100644 index 2a46da7d..00000000 --- a/mods/hmods/clovercon.hmod +++ /dev/null diff --git a/mods/hmods/core-modules.hmod b/mods/hmods/core-modules.hmod Binary files differnew file mode 100644 index 00000000..ca8247a1 --- /dev/null +++ b/mods/hmods/core-modules.hmod diff --git a/mods/mod_hakchi/hakchi/rootfs/etc/hakchi.png b/mods/mod_hakchi/hakchi/rootfs/etc/hakchi.png Binary files differdeleted file mode 100644 index f18bc87f..00000000 --- a/mods/mod_hakchi/hakchi/rootfs/etc/hakchi.png +++ /dev/null diff --git a/mods/mod_hakchi/hakchi/rootfs/etc/init.d/S78clvcon b/mods/mod_hakchi/hakchi/rootfs/etc/init.d/S78clvcon deleted file mode 100755 index 355fc01a..00000000 --- a/mods/mod_hakchi/hakchi/rootfs/etc/init.d/S78clvcon +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh - -CLV_BOARD_NAME="$(cat "/etc/clover/boardtype")" -MODULE="clvcon" -[ -f "/lib/modules/$(uname -r)/extra/$MODULE.ko" ] || MODULE="clovercon" - -start() -{ - echo "$MODULE: starting driver" - case "${CLV_BOARD_NAME}" in - fp) - # inverted c1/c2 detect lines - MODULE_PARAMS="2,195,1,194" - ;; - ep|dp-nes|dp-shvc) - # regular setup w/ detect lines - MODULE_PARAMS="1,195,2,194" - ;; - dp-hvc) - # no detect lines - MODULE_PARAMS="1,-1,2,-1" - ;; - esac - modprobe "$MODULE" "module_params=$MODULE_PARAMS" -} - -stop() -{ - echo "$MODULE: stopping driver" - modprobe -r "$MODULE" -} - -case "$1" in -start) - start -;; -stop) - stop -;; -restart) - stop - start -;; -*) - echo "$MODULE: Please use start, stop, or restart." - exit 1 -esac diff --git a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb index 06d7f798..1c05a523 100644 --- a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb +++ b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/b0040_usb @@ -1,58 +1,79 @@ -checkUsbStorage(){ - local trigger="/sys/bus/platform/devices/sunxi_hcd_host0/otg_ed_test" - 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 - - [ -b "$disk" ] || return 1 - - local ro="defaults,nosuid,nodev,noatime,ro" - local rw="defaults,nosuid,nodev,noatime,rw" - mount -o $ro "$disk" "$mountpoint/media" || return 1 - - local saves="$modname/saves" - - if [ -d "$mountpoint/media/$saves" ] || [ -d "$mountpoint/media/$modname/transfer" ] || [ "$cfg_usb_rw" == "y" ]; then - mount -o remount,$rw "$disk" - fi - [ -d "$mountpoint/media/$saves" ] && mount_bind "$mountpoint/media/$saves" "$mountpoint/var/lib/clover/profiles/0" - - local bootlogo0="boot.png" - local bootlogo1="$mountpoint/media/$modname/$bootlogo0" - local bootlogo2="$rootfs/etc/$bootlogo0" - if [ -f "$bootlogo1" ]; then - rsync -ac "$bootlogo1" "$bootlogo2" - showImage "$bootlogo2" - cfg_boot_logo='' - else - [ -f "$bootlogo2" ] && rm "$bootlogo2" && source "$preinit.d/p7010_bootlogo" - fi - - return 0 -} - -checkUsbGamepath(){ - local disk="/dev/sda1" - [ -b "$disk" ] || return 1 - - local games="$modname/games" - if containsGames "$mountpoint/media/$games"; then - if ! mkdir -p "$rootfs$gamepath"; then - rm -rf "$rootfs$gamepath" - mkdir -p "$rootfs$gamepath" || return 1 - fi - mount_bind "$mountpoint/media/$games" "$rootfs$gamepath" - return 0 - else - echo "no romz found at: $disk:/$games" - return 1 - fi -} +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"
+}
+
+checkUsbStorage(){
+ local disk="/dev/sda1"
+
+ 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
+
+ local ro="defaults,nosuid,nodev,noatime,ro"
+ local rw="defaults,nosuid,nodev,noatime,rw"
+ mount -o $ro "$disk" "$mountpoint/media" || return 1
+
+ local saves="$modname/saves"
+
+ if [ -d "$mountpoint/media/$saves" ] || [ -d "$mountpoint/media/$modname/transfer" ] || [ "$cfg_usb_rw" == "y" ]; then
+ mount -o remount,$rw "$disk"
+ fi
+ [ -d "$mountpoint/media/$saves" ] && mount_bind "$mountpoint/media/$saves" "$mountpoint/var/lib/clover/profiles/0"
+
+ local bootlogo0="boot.png"
+ local bootlogo1="$mountpoint/media/$modname/$bootlogo0"
+ local bootlogo2="$rootfs/etc/$bootlogo0"
+ if [ -f "$bootlogo1" ]; then
+ rsync -ac "$bootlogo1" "$bootlogo2"
+ showImage "$bootlogo2"
+ cfg_boot_logo=''
+ else
+ [ -f "$bootlogo2" ] && rm "$bootlogo2" && source "$preinit.d/p7010_bootlogo"
+ fi
+
+ return 0
+}
+
+checkUsbGamepath(){
+ local disk="/dev/sda1"
+ [ -b "$disk" ] || return 1
+
+ local games="$modname/games"
+ if containsGames "$mountpoint/media/$games"; then
+ if ! mkdir -p "$rootfs$gamepath"; then
+ rm -rf "$rootfs$gamepath"
+ mkdir -p "$rootfs$gamepath" || return 1
+ fi
+ mount_bind "$mountpoint/media/$games" "$rootfs$gamepath"
+ return 0
+ else
+ echo "no romz found at: $disk:/$games"
+ return 1
+ fi
+}
diff --git a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7020_usb b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7020_usb index 5026a862..d8c3d82b 100644 --- a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7020_usb +++ b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7020_usb @@ -1 +1,15 @@ -[ "$cf_usb" == "n" ] || checkUsbStorage +if [ "$cfg_usb_host" != "y" ]; then
+ switchToUsbDevice
+else
+ switchToUsbHost
+
+ # the usb driver needs about 3 seconds to initialize
+ sleep 3
+
+ if [ -z "$(lsusb | grep -v "1d6b:0001")" ]; then
+ switchToUsbDevice
+ else
+ checkUsbStorage
+ fi
+
+fi
diff --git a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7070_firmware b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7070_firmware index fbe018a4..e14653c0 100644 --- a/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7070_firmware +++ b/mods/mod_hakchi/hakchi/rootfs/etc/preinit.d/p7070_firmware @@ -4,5 +4,10 @@ mod_repair_etc softwareCheck checkUsbGamepath -# temporary -[ "$(uname -n)" == "madmonkey" ] && overmount "/lib/modules" +if [ ! -d "$mountpoint/lib/modules/$(uname -r)" ]; then + if [ -d "$rootfs/lib/modules/$(uname -r)" ]; then + overmount "/lib/modules" + else + echo "no modules for loaded kernel $(uname -r)" + fi +fi |