Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for USB Ethernet driver? #62

Open
ryny24 opened this issue Dec 12, 2020 · 113 comments
Open

Request for USB Ethernet driver? #62

ryny24 opened this issue Dec 12, 2020 · 113 comments

Comments

@ryny24
Copy link

ryny24 commented Dec 12, 2020

I just found this WyzeHacks and I can't wait to try it.

Would it be possible to add ethernet (USB) support to the WyzeCam? For locations that don't have Wifi. Just a thought!

Keep up the good work!

@gtxaspec
Copy link

I was just thinking of this before bed last night, lol.

Reading the source to dafang, you need to compile usb-net support for the kernel and probably an asix ethernet device driver, as modules.

Can these be used from the dafang source? Hmm

@gtxaspec
Copy link

gtxaspec commented Jan 31, 2021

Download:

https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/blob/master/firmware_mod/driver/usbnet.ko
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/blob/master/firmware_mod/driver/asix.ko

copy these onto the camera somehow (you could have a custom script do this probably), then run the commands (example):

cd /tmp
insmod usbnet.ko (this must be done first, or you will get "unknown symbol" errors when loading asix.ko)
insmod asix.ko

then plug in your usb to ethernet adapter:

[44726.370013] usbcore: registered new interface driver asix
[45015.713488] usb 1-1: new high-speed USB device number 2 using dwc2
[45016.558155] asix 1-1:1.0 eth0: register 'asix' at usb-dwc2-1, ASIX AX88772B USB 2.0 Ethernet, xx:xx:xx:xx:xx

then configure eth0 using udhcpc or use ifconfig to set a static ip etc.

report back if it works for you...

now the real kicker is, lets do this for the v3 =D

@ryny24
Copy link
Author

ryny24 commented Feb 1, 2021

NO WAY! No way! I can't wait to try this. Thank you!

@gtxaspec
Copy link

gtxaspec commented Feb 1, 2021

remember, you'll need an ASIX based ethernet adapter; with a specific model ASIX chipset

ref EliasKotlyar/Xiaomi-Dafang-Hacks#536
https://cateee.net/lkddb/web-lkddb/USB_NET_AX8817X.html

@gtxaspec
Copy link

gtxaspec commented Feb 6, 2021

looks like the V3 cam has these modules built in to the kernel. using a pass through USB otg cable, it works.

cable: https://www.amazon.com/gp/product/B07QGZK4FF

@ryny24
Copy link
Author

ryny24 commented Feb 6, 2021

Wow, that's great! Sadly I don't have any of pass-thru cables but they are on the way now! I have several V2 on NYC roof tops with a great view. I'll get some swapped out to V3 with ethernet. I'll share the feed if you want it :)

I'm still trying the above driver on my V2 & PAN but I've been unable to get telnet to accept. Probably hasn't installed WyzeHacks correctly. Still trying!

@ryny24
Copy link
Author

ryny24 commented Feb 8, 2021

FYI - the cheap white $3 dongles off eBay from China do not work. Will confirm where to buy when I get one that works.

[root@v2_camera:ryan]# lsusb
Bus 001 Device 003: ID 0fe6:9700

@gtxaspec
Copy link

gtxaspec commented Feb 8, 2021

@ryny24
Copy link
Author

ryny24 commented Feb 8, 2021

Great! on it's way. Thank you.

@ryny24
Copy link
Author

ryny24 commented Feb 10, 2021

My USB dongle arrived today, and you are correct. The V3 already has the drivers for it. I created a custom script to UP eth0 and start dhcp. This works, I get an IP and can telnet into the camera over ethernet. Unfortunately, when Wifi is dropped, I also lose ethernet (ping & telnet). This is probably because the route table has the same subnet for wlan0 and eth0. Maybe wlan0 hasn't dropped yet, and the packets are still going out wlan0.

So I decided to keep Wifi off and reboot, it should bring up eth0 without wlan0 ever creating the duplicate subnet. Unfortunately, ping never starts for the ethernet IP, but I think this is due to the wait_wlan() function performed on startup. It's waiting for wifi, and thus, never runs my custom script.

I tried to modify wait_wlan() in main.sh to exit early without actually checking for wifi, but because the V3 has a read only file system, my changes are not saved on reboot.

CUSTOM_SCRIPT='/configs/eth0.sh'

/configs/eth0.sh
ifconfig eth0 up
udhcpc -i eth0 -p /var/run/udhcpc_eth0.pid -b

@ryny24
Copy link
Author

ryny24 commented Feb 12, 2021

I was able to get the camera to ping over ethernet on bootup. I had to modify a little in main.sh. Telnet is still connection refused, so I guess WyzeHacks is not finishing. And the Camera doesn't come online until Wifi is connected. But, it's progress.

I have created a 'fork'. It's my first fork, but it looks like I did it right.
https://github.com/ryny24/WyzeHacks

@thompatry
Copy link

Can you disable WiFi and force all the traffic to go through Ethernet? Just a thought to try. I am going to try to implement this on the v2.

@ryny24
Copy link
Author

ryny24 commented Feb 12, 2021

How would you disable Wifi? Here is where I think the problem is, the boot log shows the camera waiting at this spot:

[netService:1199]war: wpa_state=DISCONNECTED
wiif disconnect
[0211 19:50:27.993][A][iCam]shellcall.c:548 cmd:[wpa_cli -p /var/run/wpa_supplicant -i wlan0 STATUS | grep wpa_state]
[0211 19:50:28.004][A][iCam]shellcall.c:553 msgque ret:[wpa_state=SCANNING
]

I did manage to get Video and telnet working over ethernet with Wifi disabled by doing "ifconfig wlan0 down", but this was only after it booted up with Wifi.

@thompatry
Copy link

Could you put it in the script to do ifdown on the wlan?

@ryny24
Copy link
Author

ryny24 commented Feb 13, 2021

I will try. I'm not sure it will satisfy the wpa_cli, but it's worth a shot. I'll try tomorrow.

@MelonSmasher
Copy link

The ethernet adapter that your using uses the USB A port not the microUSB port? If so I'll purchase one to help, just want to make sure I get the right adapter. I bought one of these hoping I could get power and ethernet working through just the micro USB port. No luck. I'm hoping you get it working and I can pair the setup with one of these.

@gtxaspec
Copy link

use this with a v3:

https://www.amazon.com/gp/product/B07QGZK4FF

@MelonSmasher
Copy link

MelonSmasher commented Feb 25, 2021

So my parts came in today and I'm having some success on the V2 camera.

Here's my hardware:

Image

I'm attempting to get everything working manually before I try to script anything. Here's where I'm at:

usbnet.ko and asix.ko are on my NAS in the emulated SD card folder. I have them there for testing until I figure out a better place to put them. I was thinking about eventually splicing them into the official RTSP firmware.

I run the following:

[root@WyzeCam]# insmod usbnet.ko
[root@WyzeCam]# insmod asix.ko
[root@WyzeCam]# ifconfig eth0 up

As expected I'm able to see the device in ifconfig:

[root@WyzeCam]# ifconfig
eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:1038 (1.0 KiB)

However I run into a roadblock with DHCP. The device never gets a DHCP address. I get the following when I try to request a lease:

[root@WyzeCam]# udhcpc -i eth0 -p /var/run/udhcpc_eth0.pid -b
udhcpc (v1.22.1) started
Sending discover...
Sending discover...
Sending discover...
No lease, forking to background

If I manually assign an IP address I'm able to ping it from another machine and telnet into that address.

[root@WyzeCam]# ifconfig eth0 192.168.0.28
[root@WyzeCam]# ifconfig
eth0      Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
          inet addr:192.168.0.28  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Any ideas what I'm doing wrong for DHCP to work?

Scratch the DHCP issue above. The switch I was using had link aggregation enabled on the ports I was using. As soon as I disabled link aggregation DHCP worked.

@MelonSmasher
Copy link

Could you put it in the script to do ifdown on the wlan?

When I try that with a working ethernet connection everything works for a few minutes. After a minute or two the camera reboots. Seems like something is checking that the camera is connected to wireless and reboots the camera if it's not.

@ryny24
Copy link
Author

ryny24 commented Feb 27, 2021

The boot log shows that Wyze is waiting for wpa_cli to return "COMPLETED". Wyze does not finish booting until this. Until Wifi is available and connected, wpa_cli will return "SCANNING, ASSOCIATING or DISCONNECTED".

Unfortunately, we can't modify the wpa_cli since the file system is read only (V3 at least). very depressing.

[exec-assis:386]: (no.100000) popen  ret:[wpa_state=SCANNING  
wpa_state=ASSOCIATING                                              
wpa_state=DISCONNECTED

[root@ETH-TEST-3:tmp]# printf '#!/bin/sh\necho "wpa_state=COMPLETED"\n' > /bin/wpa_cli 
-sh: can't create /bin/wpa_cli: Read-only file system

I'll keep trying.

@MelonSmasher
Copy link

MelonSmasher commented Feb 27, 2021

@ryny24 I've been messing around with making a custom firmware based on this video. I've been able to modify files on the firmware and flash it and then apply WyzeHacks on top with success. wpa_cli is on the JFFS2 block within the firmware. I've been able to unpack the JFFS2 system using sviehb/jefferson however I'm not sure how to repack the JFFS2 system after making changes. It's been fairly trivial to make changes to the squashfs systems.

My thinkings is we may need to modify the stock firmware using the methods described in that video. Flash the modded firmware, then apply WyzeHacks on top. The mods to the firmware would include the kernel modules for USB ethernet and automatic detection of the USB ethernet adapter to choose and provision either Wifi or Ethernet.

@ryny24
Copy link
Author

ryny24 commented Feb 28, 2021

@MelonSmasher wow, he makes that look so simple lol. The only problem is, keeping wpa_cli functional when ETHERNET is not enabled in the config. Maybe we can create wpa_cli a link to another file system that we can modify. I will give it a try.

@ryny24
Copy link
Author

ryny24 commented Feb 28, 2021

Doing a binwalk on the Wyze firmware file shows the same as the video. Multiple volumes including Squashfs. However, the firmware.bin which WyzeHacks sends is only a tar file. I think it's only sending the hacked scripts needed and not the firmware itself. Good idea actually. But, that will make it a bit more complicated to fix wpa_cli.


DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             POSIX tar archive (GNU)

@MelonSmasher
Copy link

MelonSmasher commented Feb 28, 2021

I made a tool that unpacks and repacks the firmware. It mounts the JFFS2 image read/write so that changes can be made. I've only tried on the Cam V2 firmware. Here's a link if your interested: MelonSmasher/WyzeFirmwareTool

@MelonSmasher
Copy link

MelonSmasher commented Mar 2, 2021

@ryny24 I have been able to modify the JFFS2 file system with some success. What would you do to wpa_cli if you could modify it?

I've tried renaming both wpa_cli and wpa_supplicant to wpa_cli.disabled and wpa_supplicant.disabled. When I do that it does not connect to wireless, but unfortunatly the Wyze app does not see the camera as online even though it has a connection via eth0. I'm assuming that icamera it checking for a connection on wlan0 or something.

@MelonSmasher
Copy link

MelonSmasher commented Mar 2, 2021

While not ideal, I found that killing wpa_supplicant after the camera has been running for a while allows the camera to stay up and running with no wifi connection forcing all traffic over eth0. I generated some Wyze Cam v2 firmware images using my WyzeFirmwareTool. I've noticed that when wpa_supplicant is dead without the hacks in this repo the camera stays up and running. However when the hacks are enabled the camera reboots within a minute or two of wpa_supplicant being killed off.

Below are 4 different firmware images I generated for the cam v2. Two are based off the latest firmware from Wyze and two are based off of the RTSP firmware from Wyze. Two of them will kill wpa_supplicant after boot to force the connection over eth0 and the other two leave wpa_supplicant alone but do enable the ethernet adapter.

If I can't get the camera to stop rebooting, I may just work in the NFS mods from this repo into my firmware generator tool.

MelonSmasher/WyzeFirmwareTool/releases

@gtxaspec
Copy link

gtxaspec commented Mar 2, 2021

didn't @HclX add a subroutine to reboot if wifi is lost? I forgot, I may be wrong, I'll check the source.

@MelonSmasher
Copy link

Something else to note, here is that even with both wifi and eth0 enabled, traffic seems to be going over the ethernet adapter. While probably not the best way to measure this, but when I open the Wyze and look at the camera the ethernet adapter goes from a steady light to flashing continuously. I'm wondering if it's even worth killing the wifi connection.

@gtxaspec
Copy link

gtxaspec commented Mar 2, 2021

you're saying that the camera works even with no wifi to initially connect? I think some folks want to use this in areas with no wifi

@jdesai61ilu
Copy link

@satmandu Agree. But that's why the simple scripts mentioned above fools the rest of the system.

/system/bin/wpa_cli --> bogus wpa_cli
/system/bin/wpa_supplicant --> bogus wpa_supplicant
/system/bin/restart_wlan0.sh --> bogus restart_wlan0.sh

I am just trying to create a v3 firmware image with these substitute scripts replacing the aoriginal executables.

@jdm0
Copy link

jdm0 commented Aug 21, 2021

Gentlemen: I'm desperate to get something like WyzeHacks working on the Eufy Indoor Cam 2K (model T8400), but I lack the sharpened Linux hacking skillz you all seem to have. I can tell you that the Eufy cam uses the exact-same SoC as the Wyze V3 — namely, the Ingenic T31 — and I've spent countless hours running operational experiments and examining log files from the cams. If you know of anyone who's working on a project like this — which I suppose one might call "EufyHacks" — or if you would be interested in working on it yourself, PLEASE message me!! ~ Apologies for the tangential comment. Thanks.

@HclX
Copy link
Owner

HclX commented Aug 21, 2021 via email

@jdm0
Copy link

jdm0 commented Sep 2, 2021

@HclX wrote:

One problem with Eufy camera is they don't have SD card recovery mechanism also no firmware downloadable from their website. That definitely adds some barrier to get the firmware out for analysis. I think I will manage that by simply open the case and dump flash directly.

Another possible approach might be to manually initiate the download of a firmware update to the cam, the next time one becomes available, after preparing to use Wireshark/Debookie and a MITM technique to intercept the firmware binary as it's passing thru your local router on its way to the cam.

@satmandu
Copy link

I hope there's a way to enable USB ethernet for the official Wyze Cam v3 RTP firmware!

(Opened an issue for that here: #138 )

@dudududodododedede
Copy link

Is anyone using this Wyze ethernet method for constant RTSP streaming? Has it been more stable than wifi?

@satmandu
Copy link

I've been using the ethernet driver for constant rtsp streaming on the Cam v3, not using the official RTSP firmware. (I'm in a high density wifi area though, so any offloading from wifi is a good thing.)

@evanheckert
Copy link

evanheckert commented Sep 27, 2021

@satmandu I'd like to do the same, but can't even get logged into the Wyze apps. Multiple devices, and it always says "Login Error. Problem connecting to server, please try again." Is there a way to do this without ever connecting to wyze?

Edit: Secondary question - regarding your official firmware issue - what is your reasoning for wanting the USB Ethernet on that firmware if you've got RSTP via ethernet already working?

@satmandu
Copy link

I am using this: https://github.com/FiveLeavesLeft/WyzeCameraLiveStream

I don't think it requires you to login through the web interface at all.

@nadigo
Copy link

nadigo commented Sep 27, 2021 via email

@satmandu
Copy link

satmandu commented Sep 27, 2021 via email

@jdesai61ilu
Copy link

Is anyone using this Wyze ethernet method for constant RTSP streaming? Has it been more stable than wifi?

I use ethernet and constantly streaming/recording using frigate. It is completely stable. I can't comment on wifi comparision because I didn't try stability tests with wifi.

@jdm0
Copy link

jdm0 commented Oct 7, 2021

Lo and behold, someone has recently posted the SDK for the Ingenic T31 SoC here on Github. If you haven't seen it before, I think you may find it extremely helpful in making progress with hacking the Wyze V3 (and also the Eufy Indoor 2K).

Lots of juicy goodies there, including technical documentation of the Ingenic T31 chip. The section on the boot process (pp. 25–26) may be of particular interest.

Enjoy!

@evanheckert
Copy link

Could someone with a V3 and working ethernet based local network streaming comment with which firmware they're on, and which (if any) hacks they've applied?

@Vendo232
Copy link

Vendo232 commented Jan 4, 2022

@satmandu

Actually, the V3 works already with USB ethernet modules. @gtxaspec posted this on Feb 6 in this thread, and I confirmed it works.

Sir, would you know if it is possible to change SSID/Password of the V3 remotely using Telnet?

@Vendo232
Copy link

Vendo232 commented Jan 4, 2022

You might need an older firmware. Mine is stable. Getting the newer Actual RTSP firmware working with Ethernet would be ideal though.

On Mon, Sep 27, 2021, 9:43 AM nadigo @.> wrote: Did you get it to work on ver 3 camera? mine is crashing every 20s or so when i install this ... On Mon, Sep 27, 2021 at 9:10 AM Satadru Pramanik @.> wrote: > I am using this: https://github.com/FiveLeavesLeft/WyzeCameraLiveStream > > I don't think it requires you to login through the web interface at all. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <#62 (comment)>, or > unsubscribe > < https://github.com/notifications/unsubscribe-auth/ABOQZBNJBF7IDC64K7HM3BDUEBUNJANCNFSM4UXTSUHQ > > . > Triage notifications on the go with GitHub Mobile for iOS > < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 > > or Android > < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub >. > > — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#62 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAILX7PCNFRGNQ3HOIBOU2LUEBYJTANCNFSM4UXTSUHQ .

@satmandu Sir, would you be so kind and write a short few steps guide how to enable USB LAN on V3? Will try to place it on this WIKI repo for others. thank you

@satmandu
Copy link

satmandu commented Jan 4, 2022

@satmandu Sir, would you be so kind and write a short few steps guide how to enable USB LAN on V3? Will try to place it on this WIKI repo for others. thank you

I don't actually have Ethernet setup on my V3 at the moment, so you're best off following the steps mentioned above. I'm just using the RTSP firmware with wifi at the moment.

@Vendo232
Copy link

Vendo232 commented Jan 6, 2022

I just found this WyzeHacks and I can't wait to try it.

Would it be possible to add ethernet (USB) support to the WyzeCam? For locations that don't have Wifi. Just a thought!

Keep up the good work!

Hello , would you commands to change SSID and password in V3 via telnet?

@gtxaspec
Copy link

gtxaspec commented Apr 4, 2022

i got this to work without needing a wifi network present... that was the issue right? you still needed wifi when the camera booted?

@Vendo232
Copy link

Vendo232 commented Apr 7, 2022

i got this to work without needing a wifi network present... that was the issue right? you still needed wifi when the camera booted?

hello @gtxaspec , what steps did you run to make the ethernet working on V3?

@gtxaspec
Copy link

gtxaspec commented Apr 7, 2022

code goes like this:

echo "check if ethernet adapter is present"
 if [[ ! -d /sys/class/net/eth* ]]; then
        echo "usb ethernet not present"
    else
        ifconfig eth0 down
        ifconfig wlan0 down

        /media/mmc/busybox ip link set wlan0 name wlanold 
        /media/mmc/busybox ip link set eth0 name wlan0

        ifconfig wlan0 up
        udhcpc -i wlan0
        /media/mmc/dropbearmulti dropbear -R -m &
        sleep 5
        mount -o bind /media/mmc/wpa_cli.sh /bin/wpa_cli
    fi

wpa_cli.sh:

#!/bin/sh

echo 'wpa_state=COMPLETED'
echo ip_addresss=`ifconfig wlan0 | awk '/inet / {print $2}' | awk -F: '{print $2}'`

EDIT:
make sure you are using a busybox that has the ip applet built in. the stock wyze one does ont.

@evanheckert
Copy link

@gtxaspec Thanks for sharing this! I'll give this a try. What cable/adapter are you using to get ethernet connected?

@gtxaspec
Copy link

gtxaspec commented Apr 9, 2022

@evanheckert I'm using an AX88772B usb 2.0 ethernet adapter, an old macally one.
according to the kernel you should be able to use most asix or r8152 based usb ethernet adapters.

[    0.516183] usbcore: registered new interface driver r8152
[    0.521875] usbcore: registered new interface driver asix

@evanheckert
Copy link

@gtxaspec

EDIT: make sure you are using a busybox that has the ip applet built in. the stock wyze one does not.

Not sure I follow on this. What's a busybox?

Also I manually triggered

  • wlan0_kill.sh
  • eth0_init.sh

And both worked, so I made the grave mistake of adding them as export CUSTOM_SCRIPT lines. Then with a reboot, only wlan0_kill.sh worked, apparently, because it connects to wifi just long enough to see it at the router control panel, then disappears.

If I can't telnet in and wifi is disabled, am I bricked?

@gtxaspec
Copy link

busybox is a utility that included in the wyze firmware. You can always flash back using the stock firmware. I will release a version of wz_mini_hacks soon that has the ethernet stuff built in.

@evanheckert
Copy link

busybox is a utility that included in the wyze firmware. You can always flash back using the stock firmware. I will release a version of wz_mini_hacks soon that has the ethernet stuff built in.

Awesome! Starred and followed. I'll give it a go when the ethernet stuff is added. RTSP enabled as well?

@gtxaspec
Copy link

you can use the RTSP firmware too!

@UncleJohnsBnd
Copy link

busybox is a utility that included in the wyze firmware. You can always flash back using the stock firmware. I will release a version of wz_mini_hacks soon that has the ethernet stuff built in.

When will this be available?

@UncleJohnsBnd
Copy link

Does this work on V3?

@gtxaspec
Copy link

https://github.com/gtxaspec/wz_mini_hacks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests