logo elektroda
logo elektroda
X
logo elektroda

[Youtube] Firmware change in Tuya relay with busy UART lines

p.kaczmarek2  0 3681 Cool? (+9)
📢 Listen (AI):

TL;DR

  • A Tuya WiFi relay based on BK7231N/CB2S is reflashed with new firmware despite extra circuitry on the UART programming lines.
  • The flashing process traces the RX and TX paths and removes blockers by cutting tracks, unsoldering a microcontroller, or holding it in RESET.
  • The setup centers on the BK7231N/CB2S platform, with OpenBeken, hid_download_py, bkWriter 1.60, and Tuya-cloudcutter named as the main tools.
  • Programming can fail even when the wiring matches the instructions, because added elements on RX/TX may interfere and make beginners think nothing works.
  • The post also notes an upcoming OpenBeken stability patch, Home Assistant Discovery, W600/W601 support, and an online device database.
Generated by the language model.
The video recorded with my assistant shows the process of changing the firmware of the WiFi module in the Tuya relay built on the BK7231 (here: BK7231N/CB2S) taking into account possible difficulties, such as additional elements that hinder programming connected to the paths from the UART.



A still from the film for encouragement:
Circuit board with electronic components and tracks.
The difficulties shown in the video do not always occur, for example, there were none in the once described Qihip relay . There, the RX and TX lines had no additional functions, it was enough to solder the wires and everything worked right away. I had a similar problem once when I changed the firmware of the device to ESP.
Similar difficulties may occur, for example, in devices with TuyaMCU - there, on the RX / TX lines used for programming, there is a microcontroller, which can also interfere with the change of the batch. Then you can also cut the paths, or unsolder this microcontroller, or put it in the RESET state.

These difficulties can scare a beginner because " how is it, I connected everything according to the instructions and nothing works?! ", but it's really not difficult. You just need to trace the paths and cleverly remove what may interfere - see the video above. Outlet is not that difficult, reconstruction of the path is too.

If you like this form of presentation, it's worth watching the previous video in the series:
[Youtube] Removing the SMD module and changing the BK7231 firmware in the RGBCW LED lamp

This film is somewhat complementary to the topics:
- Light switch from USA - Gosund Smart Switch SW5-A-V2.1 - BK7231T
- Garden double relay Tuya CCWFIO232PK - BK7231T - programming
Also, check out other topics about related products:
- 'Bulb' LED WiFi RGBCW Tuya - interior, programming, BK7231N
- Nous Smart WiFi Bulb P3 RGBCW - CB2L + BP5758 - firmware change
and many other topics, not only mine, from the department "Insides of Devices" .

It's worth getting to know the Home Assistant tutorial:
Tutorial Home Assistant - configuration, WiFi, MQTT, Zigbee, Tasmota

Let's not forget about Tasmota - this firmware is my inspiration when creating OpenBeken, as well as e.g. OpenBeken is compatible with Tasmota through Tasmota Device Groups:
ESP8266 and Tasmota - controlling the WiFi relay step by step
Links mentioned in the video:
- OpenBeken https://github.com/openshwprojects/OpenBK7231T_App
- hid_download_py: https://github.com/OpenBekenIOT/hid_download_py
- bkWriter 1.60: https://github.com/openshwprojects/OpenBK7231T/blob/master/bk_writer1.60.zip
- ready builds for various platforms (BK7231T, BK7231N, XR809, W800, W801, T34, BL602) to download: https://github.com/openshwprojects/OpenBK7231T_App/releases

Tuya-cloudcutter, an alternative way to upload firmware without soldering wires, but only for supported devices:
https://github.com/tuya-cloudcutter/tuya-cloudcutter

And the contest:
Present your own construction or send an article and receive a 64GB SD card
It also applies to topics placed in " Equipment indoors ", i.e. descriptions of e.g. IoT gadgets, but not only.

Side news/organizational matters:
1. The BK7231N platform in OpenBeken will get a patch this week that significantly improves stability with a large number of MQTT events (problems were reported by several users, they are now fixed)
2. OpenBeken recently supports Home Assistant Discovery, so you don't have to manually copy the configuration. Config->Generate Home Assistant CFG and there you need to click the new button:

3. OpenBeken already supports the W600 and W601 WinnerMicro platform (thanks to the help of one of the contributors).
4. OpenBeken has recently supported an online device database (Launch Web Application->Config):

The database contains photos of devices, their templates, settings and scripts as well as links to Elektroda. Do you have any new device? Anyone can add them via pull request to:
https://github.com/OpenBekenIOT/webapp/blob/gh-pages/devices.json

That's it for now, another video on the way, for now I will only reveal that it will be again with soldering and soldering / soldering the system in SOIC08 ...

About Author
p.kaczmarek2
p.kaczmarek2 wrote 14395 posts with rating 12318 , helped 650 times. Been with us since 2014 year.

Comments

FAQ

TL;DR: BK7231N provides 2 MB on-chip flash [BK7231N Datasheet] and, as the author notes, “it’s really not difficult” to reflash [Elektroda, p.kaczmarek2, post #20217554] The linked 10-minute video shows cutting traces to silence busy UART lines and loading OpenBeken via USB-TTL.

Why it matters: A clean flash unlocks open firmware, local control and Home Assistant auto-discovery.

Quick Facts

• Flash memory: 2 MB NOR inside BK7231N [BK7231N Datasheet] • Supply voltage: 3.0 – 3.6 V logic levels [BK7231N Datasheet] • Recommended flashing speed: 115 200 bps UART [OpenBK7231T Wiki] • OpenBeken v1.17 builds for 7 MCU families (BK7231N/T, XR809, W800, W801, T34, BL602, W600/W601) [OpenBK7231T Releases] • Tuya-cloudcutter lists 60+ supported device profiles (Sep 2023) [Tuya-cloudcutter GitHub]

What is the BK7231 chip used in Tuya relays?

BK7231N/T is a 32-bit Wi-Fi/BLE SoC with 2 MB flash and 256 kB SRAM, powering many low-cost Tuya smart plugs and relays [BK7231N Datasheet].

Why do busy RX/TX lines block flashing?

Extra parts—LED drivers or a TuyaMCU microcontroller—share the UART pins, forcing them high or low. The USB-TTL adapter then fails to handshake with the bootloader [Elektroda, p.kaczmarek2, post #20217554]

How can I isolate those busy UART lines?

  1. Trace RX/TX tracks visually.
  2. Cut the copper just before interfering parts.
  3. After flashing, bridge the cuts with solder to restore function.
    This three-step method takes under five minutes on single-layer boards [Elektroda, p.kaczmarek2, post #20217554]

Which software tools are required to load OpenBeken?

Install hid_download_py or bkWriter 1.60, grab the correct OpenBeken binary from GitHub releases, and connect a 3.3 V USB-TTL adapter set to 115 200 bps [Elektroda, p.kaczmarek2, post #20217554]

Does OpenBeken integrate with Home Assistant automatically?

Yes. Click Config → Generate Home Assistant CFG, then press the new Discovery button; HA pulls entities without manual YAML [Elektroda, p.kaczmarek2, post #20217554]

Can I avoid soldering altogether?

If your device is listed, Tuya-cloudcutter exploits OTA updates to load custom firmware wire-lessly—no wires, no disassembly [Tuya-cloudcutter GitHub]. Edge-case: unsupported models may soft-brick if you attempt the exploit.

What is a common flashing failure scenario?

If TuyaMCU holds the RX pin low during power-up, the bootloader never enters UART mode, so the flash tool times out every attempt [Elektroda, p.kaczmarek2, post #20217554]

Is 5 V safe for BK7231 UART lines?

No. The lines tolerate only 3.6 V max; using 5 V risks permanent damage [BK7231N Datasheet]. A $3 logic-level shifter prevents this issue.

How long does a typical firmware upload take?

At 115 200 bps, a 512 kB OpenBeken binary transfers in about 45 s, plus 10 s for verification [OpenBK7231T Wiki].
Generated by the language model.
%}