diff --git a/general/overlay/etc/init.d/S30wireless b/general/overlay/etc/init.d/S30wireless index 696ac71b..338d188b 100755 --- a/general/overlay/etc/init.d/S30wireless +++ b/general/overlay/etc/init.d/S30wireless @@ -1,12 +1,10 @@ #!/bin/sh -device=$(fw_printenv -n wlandev) +dev=$(fw_printenv -n wlandev) +wlan=/etc/wireless +netif=/etc/network/interfaces.d -if [ "$1" = "start" ] && [ ! -z "$device" ]; then - if /etc/wireless "$device"; then - sed -i "s/^auto/#auto/g" /etc/network/interfaces.d/eth0 - sed -i "s/^#auto/auto/g" /etc/network/interfaces.d/wlan0 - else - sed -i "s/^#auto/auto/g" /etc/network/interfaces.d/eth0 - sed -i "s/^auto/#auto/g" /etc/network/interfaces.d/wlan0 +if [ "$1" = "start" ] && [ ! -z "$dev" ]; then + if $wlan/usb "$dev" || $wlan/modem "$dev" || $wlan/sdio "$dev"; then + grep -q "static" $netif/eth0 || cp -f $wlan/interfaces/* $netif fi fi diff --git a/general/overlay/etc/network/interfaces.d/wlan0 b/general/overlay/etc/network/interfaces.d/wlan0 index ee60684a..1351471f 100644 --- a/general/overlay/etc/network/interfaces.d/wlan0 +++ b/general/overlay/etc/network/interfaces.d/wlan0 @@ -1,4 +1,3 @@ -#auto wlan0 iface wlan0 inet dhcp post-up wpa_passphrase "$(fw_printenv -n wlanssid || echo OpenIPC)" "$(fw_printenv -n wlanpass || echo OpenIPC12345)" > /tmp/wpa_supplicant.conf post-up sed -i '2i \\tscan_ssid=1' /tmp/wpa_supplicant.conf diff --git a/general/overlay/etc/wireless b/general/overlay/etc/wireless deleted file mode 100755 index 9d1f7a42..00000000 --- a/general/overlay/etc/wireless +++ /dev/null @@ -1,145 +0,0 @@ -#!/bin/sh -set_gpio() { - echo $1 > /sys/class/gpio/export - echo out > /sys/class/gpio/gpio$1/direction - echo $2 > /sys/class/gpio/gpio$1/value - sleep 1 -} - -# MT7601U Generic -if [ "$1" = "mt7601u-generic" ]; then - modprobe mt7601u - exit 0 -fi - -# RTL8188FU Generic -if [ "$1" = "rtl8188fu-generic" ]; then - modprobe 8188fu - exit 0 -fi - -# RTL8733BU Generic -if [ "$1" = "rtl8733bu-generic" ]; then - modprobe 8733bu - exit 0 -fi - -# HI3516EV200 CamHi -if [ "$1" = "mt7601u-hi3516ev200-camhi" ]; then - set_gpio 9 0 - modprobe mt7601u - exit 0 -fi - -# HI3516EV300 CamHi -if [ "$1" = "mt7601u-hi3516ev300-camhi" ]; then - devmem 0x100C0080 32 0x530 - set_gpio 7 0 - modprobe mt7601sta - exit 0 -fi - -# SSC337DE Foscam -if [ "$1" = "rtl8188fu-ssc337de-foscam" ]; then - set_gpio 15 0 - modprobe 8188fu - exit 0 -fi - -# T21 BJS -if [ "$1" = "rtl8188fu-t21-bjs" ]; then - set_gpio 50 0 - modprobe 8188fu - exit 0 -fi - -# T21 Smartwares -if [ "$1" = "rtl8188fu-t21-smartwares" ]; then - set_gpio 49 1 - modprobe 8188fu - exit 0 -fi - -# T31 CamHi -if [ "$1" = "mt7601u-t31-camhi" ]; then - set_gpio 61 0 - modprobe mac80211 - exit 0 -fi - -# T31 CamHi with Quectel EC200S-CN, EC200T-EU and usb0 -if [ "$1" = "ec200-t31-camhi" ]; then - set_gpio 61 0 - modprobe usbserial vendor=0x2c7c product=0x6026 - modprobe rndis_host - sleep 10 - exit 0 -fi - -# T31 CamHi with Quectel EC800G-CN and usb0 -if [ "$1" = "ec800-t31-camhi" ]; then - set_gpio 61 0 - modprobe usbserial vendor=0x2c7c product=0x904 - modprobe rndis_host - sleep 10 - exit 0 -fi - -# T31 CamHi with Fibocom L610-CN and usb0 -if [ "$1" = "l610-t31-camhi" ]; then - set_gpio 61 0 - modprobe usbserial vendor=0x1782 product=0x4d11 - modprobe rndis_host - sleep 10 - echo "AT+GTRNDIS=1,2" >/dev/ttyUSB0 - exit 0 -fi - -# T31 CamHi with Fibocom L716-CN and usb0 -if [ "$1" = "l716-t31-camhi" ]; then - set_gpio 61 0 - modprobe usbserial vendor=0x2cb7 product=0x0001 - modprobe rndis_host - sleep 10 - exit 0 -fi - -# T31 ATBM603X mmc0 -if [ "$1" = "atbm603x-t31-mmc0" ]; then - # PB10 in wifi mmc1 is in the pull-down state by default, it needs to be set to a high-impedance state - devmem 0x10011128 32 0x400 - # set wifi mmc1 clk drive capability to 8mA - devmem 0x10011134 32 0x20000 - - # "insert" the bus mmc0 device - if [ "$(cat /sys/devices/platform/jzmmc_v1.2.0/present)" = "N" ]; then - echo "INSERT" > /sys/devices/platform/jzmmc_v1.2.0/present - sleep 1 - fi - - cp /usr/share/atbm603x_conf/atbm_txpwer_dcxo_cfg.txt /tmp - cp /usr/share/atbm603x_conf/set_rate_power.txt /tmp - - modprobe atbm603x_wifi_sdi0 - exit 0 -fi - -# T31 ATBM603X mmc1 -if [ "$1" = "atbm603x-t31-mmc1" ]; then - # not sure what this does, but it's copied from the stock fw - devmem 0x10011110 32 0x6e094800 - - # "insert" the bus mmc1 device - if [ "$(cat /sys/devices/platform/jzmmc_v1.2.1/present)" = "N" ]; then - echo "INSERT" > /sys/devices/platform/jzmmc_v1.2.1/present - sleep 1 - fi - - cp /usr/share/atbm603x_conf/atbm_txpwer_dcxo_cfg.txt /tmp - cp /usr/share/atbm603x_conf/set_rate_power.txt /tmp - - modprobe atbm603x_wifi_sdi1 - exit 0 -fi - -exit 1 diff --git a/general/overlay/etc/wireless/interfaces/eth0 b/general/overlay/etc/wireless/interfaces/eth0 new file mode 100644 index 00000000..4bbd4542 --- /dev/null +++ b/general/overlay/etc/wireless/interfaces/eth0 @@ -0,0 +1,5 @@ +auto eth0 +iface eth0 inet static + address 192.168.2.10 + netmask 255.255.255.0 + hwaddress ether $(fw_printenv -n ethaddr || echo 00:00:23:34:45:66) diff --git a/general/overlay/etc/wireless/interfaces/wlan0 b/general/overlay/etc/wireless/interfaces/wlan0 new file mode 100644 index 00000000..a5b8014f --- /dev/null +++ b/general/overlay/etc/wireless/interfaces/wlan0 @@ -0,0 +1,6 @@ +auto wlan0 +iface wlan0 inet dhcp + post-up wpa_passphrase "$(fw_printenv -n wlanssid || echo OpenIPC)" "$(fw_printenv -n wlanpass || echo OpenIPC12345)" > /tmp/wpa_supplicant.conf + post-up sed -i '2i \\tscan_ssid=1' /tmp/wpa_supplicant.conf + post-up wpa_supplicant -B -i wlan0 -D nl80211,wext -c /tmp/wpa_supplicant.conf + post-down killall -q wpa_supplicant diff --git a/general/overlay/etc/wireless/modem b/general/overlay/etc/wireless/modem new file mode 100755 index 00000000..5ec5e4ce --- /dev/null +++ b/general/overlay/etc/wireless/modem @@ -0,0 +1,48 @@ +#!/bin/sh + +set_gpio() { + echo $1 > /sys/class/gpio/export + echo out > /sys/class/gpio/gpio$1/direction + echo $2 > /sys/class/gpio/gpio$1/value + echo $1 > /sys/class/gpio/unexport + sleep 1 +} + +# T31 CamHi with Quectel EC200S-CN, EC200T-EU and usb0 +if [ "$1" = "ec200-t31-camhi" ]; then + set_gpio 61 0 + modprobe usbserial vendor=0x2c7c product=0x6026 + modprobe rndis_host + sleep 10 + exit 0 +fi + +# T31 CamHi with Quectel EC800G-CN and usb0 +if [ "$1" = "ec800-t31-camhi" ]; then + set_gpio 61 0 + modprobe usbserial vendor=0x2c7c product=0x904 + modprobe rndis_host + sleep 10 + exit 0 +fi + +# T31 CamHi with Fibocom L610-CN and usb0 +if [ "$1" = "l610-t31-camhi" ]; then + set_gpio 61 0 + modprobe usbserial vendor=0x1782 product=0x4d11 + modprobe rndis_host + sleep 10 + echo "AT+GTRNDIS=1,2" >/dev/ttyUSB0 + exit 0 +fi + +# T31 CamHi with Fibocom L716-CN and usb0 +if [ "$1" = "l716-t31-camhi" ]; then + set_gpio 61 0 + modprobe usbserial vendor=0x2cb7 product=0x0001 + modprobe rndis_host + sleep 10 + exit 0 +fi + +exit 1 diff --git a/general/overlay/etc/wireless/sdio b/general/overlay/etc/wireless/sdio new file mode 100755 index 00000000..da587d62 --- /dev/null +++ b/general/overlay/etc/wireless/sdio @@ -0,0 +1,49 @@ +#!/bin/sh + +set_gpio() { + echo $1 > /sys/class/gpio/export + echo out > /sys/class/gpio/gpio$1/direction + echo $2 > /sys/class/gpio/gpio$1/value + echo $1 > /sys/class/gpio/unexport + sleep 1 +} + +# T31 ATBM603X mmc0 +if [ "$1" = "atbm603x-t31-mmc0" ]; then + # PB10 in wifi mmc1 is in the pull-down state by default, it needs to be set to a high-impedance state + devmem 0x10011128 32 0x400 + # set wifi mmc1 clk drive capability to 8mA + devmem 0x10011134 32 0x20000 + + # "insert" the bus mmc0 device + if [ "$(cat /sys/devices/platform/jzmmc_v1.2.0/present)" = "N" ]; then + echo "INSERT" > /sys/devices/platform/jzmmc_v1.2.0/present + sleep 1 + fi + + cp /usr/share/atbm603x_conf/atbm_txpwer_dcxo_cfg.txt /tmp + cp /usr/share/atbm603x_conf/set_rate_power.txt /tmp + + modprobe atbm603x_wifi_sdi0 + exit 0 +fi + +# T31 ATBM603X mmc1 +if [ "$1" = "atbm603x-t31-mmc1" ]; then + # not sure what this does, but it's copied from the stock fw + devmem 0x10011110 32 0x6e094800 + + # "insert" the bus mmc1 device + if [ "$(cat /sys/devices/platform/jzmmc_v1.2.1/present)" = "N" ]; then + echo "INSERT" > /sys/devices/platform/jzmmc_v1.2.1/present + sleep 1 + fi + + cp /usr/share/atbm603x_conf/atbm_txpwer_dcxo_cfg.txt /tmp + cp /usr/share/atbm603x_conf/set_rate_power.txt /tmp + + modprobe atbm603x_wifi_sdi1 + exit 0 +fi + +exit 1 diff --git a/general/overlay/etc/wireless/usb b/general/overlay/etc/wireless/usb new file mode 100755 index 00000000..ffe8acf8 --- /dev/null +++ b/general/overlay/etc/wireless/usb @@ -0,0 +1,72 @@ +#!/bin/sh + +set_gpio() { + echo $1 > /sys/class/gpio/export + echo out > /sys/class/gpio/gpio$1/direction + echo $2 > /sys/class/gpio/gpio$1/value + echo $1 > /sys/class/gpio/unexport + sleep 1 +} + +# MT7601U Generic +if [ "$1" = "mt7601u-generic" ]; then + modprobe mt7601u + exit 0 +fi + +# RTL8188FU Generic +if [ "$1" = "rtl8188fu-generic" ]; then + modprobe 8188fu + exit 0 +fi + +# RTL8733BU Generic +if [ "$1" = "rtl8733bu-generic" ]; then + modprobe 8733bu + exit 0 +fi + +# HI3516EV200 CamHi +if [ "$1" = "mt7601u-hi3516ev200-camhi" ]; then + set_gpio 9 0 + modprobe mt7601u + exit 0 +fi + +# HI3516EV300 CamHi +if [ "$1" = "mt7601u-hi3516ev300-camhi" ]; then + devmem 0x100C0080 32 0x530 + set_gpio 7 0 + modprobe mt7601sta + exit 0 +fi + +# SSC337DE Foscam +if [ "$1" = "rtl8188fu-ssc337de-foscam" ]; then + set_gpio 15 0 + modprobe 8188fu + exit 0 +fi + +# T21 BJS +if [ "$1" = "rtl8188fu-t21-bjs" ]; then + set_gpio 50 0 + modprobe 8188fu + exit 0 +fi + +# T21 Smartwares +if [ "$1" = "rtl8188fu-t21-smartwares" ]; then + set_gpio 49 1 + modprobe 8188fu + exit 0 +fi + +# T31 CamHi +if [ "$1" = "mt7601u-t31-camhi" ]; then + set_gpio 61 0 + modprobe mac80211 + exit 0 +fi + +exit 1