I’ve been interested for the crypto world for a few months now and I’ve acquired a ming rig, otherwise I wouldn’t feel complete 🙂
For all of you that have a mining rig, you’re probably familiarised with those tiny usb devices that you stick in a usb port to monitor your computer and reset it in case it hangs/freezes.
This is known as a usb watchdog and the way it works is very simple:
- Connect this device to a USB port. The usb watchdog has 4 pins: 2 that should be connected to the power switch and another 2 for the reset button. Use jumper wires to make the connection.
- When the watchdog gets powered on, it will wait for x amount of time for you to tell him “Hey, I’m still a alive! Wait for x more seconds and if you don’t get back from me again then please reset the computer”.
- Repeat the previous step indefinitely
Those messages are sent by a specific software. If for some reason your computer crashes, then the watchdog won’t receive another message from the software. If a message is not sent within those x seconds, the usb watchdog will know that something isn’t right and it will issue a hardware reset simulating the physical push of the reset button.
This usb watchdogs are shipped with dedicated software, which in my case is pretty useless because it was made for Windows computers and my mining rig is linux based. I could try to use wine but I don’t feel like killing flies with bazookas.
The windows software seemed pretty basic how hard could it be to reverse engineer the protocol?
Couldn’t be easier:
The first thing was to find some software that could inspect the connection and check what was being passed back and fourth. The first link provided by google was all I needed. I’m talking about this one.
- Baud rate: 9600
- Parity bits: None
- Stop bits: 1
This is enough for you to start sending messages to the usb watchdog.
The only thing that you need to know now is the protocol. The sniffer will give you a good picture of it.
First of all, whenever you open the watchdog software, you can see that it sends a packet (0x80) which then get an answer from the watchdog (0x81). I’m not entirely sure of how data is encoded but it’s pretty clear that whenever the software connects, it presents you with a message containing the firmware version. I would say that this is probably encoded here in this byte.
Then you can see a sequence of bytes (0x10) that are being sent at a rate of 1/s. The timeout value was set to 160 seconds. If I set the timeout value to 10 seconds, the application will start sending 0x01.
So, if 1 equals to 10 seconds, 160 seconds should be equal to 16. What is the hexadecimal representation of 16? You guessed it: 0x10 🙂
If click on the reset button, a 0xff is sent and the relays are triggered.
As far as I know, there are only these three operations available:
- Send a heartbeat with the current timeout value.
- Check firmware version
If you were expecting something fancy, you’ll be disappointed, but the sources are available here: https://github.com/zatarra/usb-watchdog 🙂
Basic functionality is implemented but you might want to extend it. You can test your video cards, test an internet endpoint, or you could even remote restart your mining rig. Use your imagination! 😀
Warning: Do not set the heartbeat interval to a very low value, such as a minute. If you do that and your computer crashes, you will have one minute to complete the boot process and load this script. If your computer fails to do that it will get stuck in an infinite loop which sucks if your mining rig is in a remote location.
Check my repository for the latest version of this script.
If you find this useful, buy me a beer: 😀
bitcoin: 3Mj3v5hrx5qQhwzzWPMGwkJ8DRMCywhZFy bitcoin cash: 1KDbjLM9DdsCyfDMSYHdm52r5R3BRP2dfS ethereum: 0xfF7167e9ea8A4d882dd9161FC5F1560B9031A6c6 litecoin: MERSbMVM9NmQoDhr5ktswpaumWk8dGbyUu ripple: rN1sXzZUBej2wiZSjgKtAgNRTUoFhUdt36 stellar: GBYS4JGPYZI774ZIU3KNEKSDUK2E3VMXQO4AZTHAO7WU4EZRSG7QF5MG