2.6 KiB
2.6 KiB
Flashing with tuya-cloudcutter
tuya-cloudcutter is a tool that disconnects IoT devices from the Tuya cloud, while also allowing remote firmware flashing. This means you can flash ESPHome without even connecting USB-UART to the device.
This is an unofficial guide, that worked for me during testing. The steps may not work for every device; you should also refer to the cloudcutter's manual pages.
Currently, tuya-cloudcutter works for BK7231T and BK7231N only.
If your device doesn't have a profile yet, it will probably not work. You can contribute by taking a device dump and posting it on cloudcutter's issues page.
Instructions
Preparation
- Get a laptop (or a PC with Wi-Fi) with Linux and Docker installed. This was tested on Ubuntu 20.04, but you should be able to use another Debian-based distribution with NetworkManager.
- To install Docker, run
sudo apt-get install docker.io. When it completes, runsudo adduser <your username> dockerand reboot the machine. - This was also successfully performed on a VirtualBox VM, with a USB Wi-Fi adapter redirected to the VM.
- To install Docker, run
- Install
git, if you haven't already (sudo apt-get install git). git clone https://github.com/tuya-cloudcutter/tuya-cloudcutter
Firmware building
- Compile ESPHome, or your custom firmware based on LibreTuya.
- Get the firmware binary, named
bk7231x_app.ota.ug.binfrom the build directory (.pio/build/<board>/or.esphome/build/<board>/.pioenvs/<board>/). - Put the file to
custom-firmwareof tuya-cloudcutter.
Pairing and flashing
- Run
./run_flash.shfrom the cloudcutter directory. - Answer questions about the desired firmware file, the device vendor and profile.
- Put the device to AP mode: (**)
- Bulbs (devices without buttons) usually need to be power-cycled a few times, until they start blinking slowly.
- Switches, plugs, relays (devices with buttons) usually enable AP after pressing the button for a few seconds.
- If the device (bulb or switch LED) is blinking quickly (~2 times per second), do the procedure again.
- Cloudcutter will scan for APs, connect to the device and send a payload to it.
- The device will most likely hang (not respond). Reboot it again to AP mode (just like in step 9).
- Cloudcutter will scan for APs again, configure the device to talk to it, then begin the OTA update.
- After around 30 seconds, the device will boot new firmware 👏
** Use a smartphone with the Wi-Fi screen open and scanning, so that you can see if AP mode got enabled.