logo elektroda
logo elektroda
X
logo elektroda

Beken BK7231/BK7252 SPI flashing and recovery - new flasher tool and protocol specs

p.kaczmarek2  306 10911 Cool? (+8)
📢 Listen (AI):

TL;DR

  • BK7231GUIFlashTool v98+ adds CH341-based SPI flashing and recovery for Beken BK7231/BK7252 chips, including bricked devices with overwritten bootloaders.
  • The tool uses CH341 DLL C# bindings to toggle CEN via D2, reset the chip, send 0xD2, then flash Beken chips like generic SPI memory.
  • Connections use P20, P21, P22, and P23 for SCK, CSN, SI, and SO, with CEN wired to D2 and the CH341 jumper set to I2C mode.
  • A sample read identifies JEDEC ID FF-EF-40-16 and a 4096 KB flash, and the same tool can Read, Write, Verify, and Erase firmware.
  • If CH341 is not detected or CEN toggle fails, check driver configuration, jumper position, SPI wiring, and power before trying Beken SPI mode again.
Generated by the language model.

BK7231GUIFlashTool version 98 and above introduces a new Beken flashing method via SPI. Only a CH341 SPI programmer is required. This method can be used to recover bricked Beken devices whose bootloader has been overwritten. It can also serve as a general-purpose SPI flasher, supporting various memory chips.

Recommended Reading
This topic builds on my previous presentation, BK7231 Programming via SPI in Flash Memory Mode – Python and Banana Pi. Here, I’ll expand on that knowledge and adapt the same logic for use with the CH341 and C#.
Additionally, the current approach is based on the work of @divadiow — see this post. The main difference is that we’ve transitioned to a more complete and suitable tool.

Required Hardware
For this guide, you’ll need a CH341 programmer — either the same one used in our video or a similar model:



Additionally, you’ll need a soldering iron to attach a wire to the D2 pin, which will be used to control CEN:

Here’s how it looks in my setup:

Alternatively, you can use another version of the CH341 — the one with routed-out pins:

Make sure the device jumper is set to the I2C position so that Windows detects it as USB-EPP/I2C... CH341A.
Next, connect the CH341 to the Beken device in SPI mode:

Use the following pins: P20, P21, P22, P23 (SCK, CSN, SI, and SO).
As usual, connect MOSI → SI and MISO → SO. Additionally, connect CEN to the previously mentioned D2 pin.
You can also check for board markings — they might be available on some devices.
Here’s an example photo from @divadiow:

Connections summary:
Generic IOTuya Doorbell PadsCH341A
CE/CENCED2
SCKTCKSCK
CSNTMSCS0
SITDIMOSI
SOTDOMISO
GNDGNDGND

So, the pad naming may vary, but the connection remains the same. Don’t forget to connect power.

Implementation Details
Skip this section if you just want to flash your device!
Beken chips include an SPI mode — in this mode, they behave just like standard SPI memory, using the same protocol details and commands. I’ve described this in a previous topic.
However, this mode is only available after entering SPI mode — that’s why we need a custom script and the D2 pin connected to CEN. The new flasher tool uses CH341 DLL C# bindings to first toggle CEN, resetting the Beken device, then sends the 0xD2 bytes to switch it into SPI mode. After that, it handles the Beken chip just like any generic SPI flash memory. In our implementation, SPIFlasher_Beken class actually inherits from generic SPIFlasher, making it reusable and giving us "free" generic SPI flash support as well.
Code: C#
Log in, to see the code

Interestingly, once switched to SPI mode, you can even use a generic SPI flashing tool such as CH341 Programmer or NeoProgrammer. However, that’s not necessary — see the next section for details.

Flash Tool Usage for Beken
First, download our tool from the following link:
https://github.com/openshwprojects/BK7231GUIFlashTool
You can either download one of the prebuilt binaries or compile it yourself in Visual Studio.
After launching the tool, you should see a window like this — select the Beken SPI chip type:

Next, you can use the buttons to Read, Write, Verify, or Erase the firmware.
If you encounter an error like the one below:

Backup name has not been set, so output file will only contain flash type/date.
Now is: niedziela, 5 października 2025 00:35:37.
Flasher mode: BekenSPI
CH341 error Failed to open CH341 device.
Starting flash read, ofs 0x0, len 0x0
Done!
Performing a Beken CEN reset on D2 of CH341...
Failed to toggle CEN - is CH341 connected and ok?

Check if the CH341 is properly configured and detected by your PC.

If the Beken chip does not enter SPI mode, verify the SPI and CEN connections.
Once properly connected, the tool should correctly identify the flash ID and size, and begin the selected operation.

Sample ID output (your values may vary):

JEDEC ID: FF-EF-40-16
Detected flash size: 4096 KB

Wait for the entire operation to complete:
BK7231 Easy UART Flasher interface with “Reading done” message
To write firmware, simply drag and drop the binary file onto the flasher window:
Screenshot of BK7231 Easy UART Flasher with a firmware file path selected.

Sample application
This method can be used to recover bricked BK7252 camera device:
Camera module with multicolored wires connected to a USB adapter

Flash Tool Usage for Generic SPI
The tool can also handle generic SPI chips. While there isn’t yet a complete list of JEDEC IDs, it attempts to decode the flash size directly from the ID — this may improve in future updates.
Just connect the SPI memory as you would for any other flasher and choose Generic SPI mode:
BK7231 Easy UART Flasher interface during flash erase process
It should work without issue. If you’re uncertain, you can always run Verify afterward to confirm.


Summary
With the latest versions of BK7231GUIFlashTool (v98 and above), you can easily recover bricked Beken devices and flash new firmware using only a CH341 programmer. New BK7231GUIFlashTool utilizes CH341 for easier BK SPI mode control and flashing.

To summarize:
- Set the CH341 jumper to I2C mode (if applicable).
- Connect the SPI lines (P20, P21, P22, P23) and CEN to D2, power your device.
- Use the Beken SPI mode in the flasher tool.
- Verify connections if you get a CEN toggle or CH341 not detected error.
- The tool can also handle Generic SPI flash chips if needed.

This approach is much simpler than Banana/Raspberry PI method present before and hopefully makes SPI flashing of Beken chips easier to approach for anyone.

Get it here: https://github.com/openshwprojects/BK7231GUIFlashTool

We're still working on adding futher features to to our flasher, including support for other platforms, so stay tuned and let us know if you have any feature requests!

About Author
p.kaczmarek2
p.kaczmarek2 wrote 14318 posts with rating 12211 , helped 648 times. Been with us since 2014 year.

Comments

divadiow 06 Oct 2025 10:58

cool! thanks for adding this feature. Easy Flasher has grown in a number of regards in recent weeks/months! A couple of things I have noticed, however: v98: -In SPI mode EF requires a COM port to... [Read more]

p.kaczmarek2 06 Oct 2025 14:01

Thank you for testing. The incorrect COM port requirement should be fixed now, can you check? I can add CH341DLL later. Are you able to run the project with Visual Studio to check what crashes? I... [Read more]

divadiow 06 Oct 2025 19:39

yep. COM no longer mandatory. computer rebooted. test setup: https://obrazki.elektroda.pl/4229148900_1759768377_thumb.jpg https://obrazki.elektroda.pl/5536552500_1759768501_thumb.jpg 1st... [Read more]

p.kaczmarek2 06 Oct 2025 22:00

Verify verifies against selected firmware. So you're having a crash only with older NET? Well, I can't reproduce it in my MSVC anyway... I also see there is upgraded NET proposal by @insmod ? What... [Read more]

divadiow 06 Oct 2025 22:06

SPI works for me with GH build [Read more]

insmod 06 Oct 2025 22:14

Tasks, System.Text.Json, Hot reload while debugging, possibly others. I would've upgraded to 4.8, but i remember that mono support for it is incomplete. I also don't know if it will work with mono with... [Read more]

p.kaczmarek2 06 Oct 2025 22:30

The reason for using older NET is that I still have this Windows 7 laptop, which works very quickly and I sometimes use it for testing. Still, if you are convinced that newer NET is better for users, I... [Read more]

insmod 06 Oct 2025 22:36

Well, Windows 7 can use .NET 6 and earlier just fine, exception being .NET 4.8.1, and even it can be installed with some tricks. [Read more]

DeDaMrAz 06 Oct 2025 22:44

Just to chime in and ask a super stupid question is mono really that important? [Read more]

p.kaczmarek2 06 Oct 2025 22:45

I remember we had multiple reports saying that Easy Flasher UART timings are broken with mono, can this be fixed by NET SDK upgrade? [Read more]

insmod 06 Oct 2025 22:46

For linux users - yes. It's that, or wine. And i don't know how wine handles com ports. [Read more]

DeDaMrAz 06 Oct 2025 23:02

So answer is no then 😁 [Read more]

p.kaczmarek2 06 Oct 2025 23:31

We need someone to test it with mono https://github.com/openshwprojects/BK7231GUIFlashTool/pull/72 . To be honest, it's probably not that hard, maybe even GPT can guide [Read more]

insmod 07 Oct 2025 00:07

$ mono --version Mono JIT compiler version 6.12.0.200 (tarball Tue Jul 11 21:32:10 UTC 2023) Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com ... [Read more]

DeDaMrAz 07 Oct 2025 00:08

Does download latest release works? It doesn't for me. [Read more]

insmod 07 Oct 2025 00:19

If you mean v99 flasher, then yes. If you mean automatic firmware downloader in flasher, then yes too With mono too: Target platform: RTL8720D Will request page: https://github.com/openshwprojects/OpenBK7231T_App/releases Got... [Read more]

DeDaMrAz 07 Oct 2025 00:23

So how important/relevant is mono support again? [Read more]

insmod 07 Oct 2025 00:29

Relevant enough to get a mention in readme.md Will have to compile .so library then. [Read more]

DeDaMrAz 07 Oct 2025 00:44

I have to ask another very stupid question then. Why are "we" dissipating so much energy and time on such a trivial tasks? We had 35 releases before workflow change and 99 releases now with various... [Read more]

FAQ

TL;DR: New BK7231GUIFlashTool v98+ adds SPI flashing for Beken chips; sample 4,096 KB flash detected. “Only a CH341 SPI programmer is required.” Use CH341A D2 to toggle CEN, send 0xD2, then read/write like generic SPI. [Elektroda, p.kaczmarek2, post #21711721]

Why it matters: It lets you recover bricked BK7231/BK7252 devices without a working bootloader, using low‑cost tools.

Who this is for: DIYers, repair techs, and firmware engineers asking how to unbrick or mass‑flash Beken SoCs via SPI with a CH341A and the latest tool.

Quick Facts

What exactly is the new Beken SPI flashing method and what do I need?

The tool drives CH341A as an SPI master, resets BK via CEN on D2, sends 0xD2 to enter BK’s SPI-memory mode, then treats the chip like a standard SPI flash. You need a CH341A (jumper at I2C), 3.3 V power, and wiring for P20–P23 (SCK/CSN/SI/SO) plus CEN. Select “Beken SPI” in BK7231GUIFlashTool v98+. “Only a CH341 SPI programmer is required.” [Elektroda, p.kaczmarek2, post #21711721]

How do I wire CH341A to BK7231/BK7252 for SPI mode?

Connect CH341A SCK→P20, CS0→P21, MOSI→P22 (SI), MISO→P23 (SO), and D2→CEN. Keep MOSI→SI and MISO→SO mapping. Provide GND and target power. Some boards have pads labeled CE/TCK/TMS/TDI/TDO that map to CEN/SCK/CSN/SI/SO respectively. [Elektroda, p.kaczmarek2, post #21711721]

How do I reliably enter BK SPI mode? (3‑step)

  1. Use CH341 D2 to pull CEN low then high to reset the BK chip. 2. Stream 0xD2 bytes repeatedly over SPI. 3. Issue 0x9F and confirm a valid JEDEC response; then proceed to Read/Write/Erase. [Elektroda, p.kaczmarek2, post #21711721]

I get “Failed to open CH341 device” or “Failed to toggle CEN.” What should I check?

Confirm CH341A is jumpered to I2C, recognized by Windows, and the D2 wire is soldered to CEN. Re‑seat USB, power the target, and verify SPI lines. The tool logs these errors when CH341 isn’t detected or CEN can’t be driven; fix wiring or driver, then retry. [Elektroda, p.kaczmarek2, post #21711721]

The app says “missing ch341dll.dll” or quits in SPI mode—how do I fix that?

Place CH341DLL.DLL alongside the GitHub build, or build from source in Visual Studio. Earlier builds could exit if CH341A wasn’t present; recent fixes improved handling, but adding the DLL resolved missing‑library errors during testing. [Elektroda, divadiow, post #21712310]

Do I need to select a COM port for SPI flashing?

No. As of v99, SPI mode does not require a COM port. This was confirmed after fixes; previous v98 prompts were removed. Ensure CH341A is connected; SPI operations run without a serial port. [Elektroda, divadiow, post #21712310]

What does the Verify button do?

Verify compares flash contents against the firmware file currently selected in the tool. Use it after Write or Erase to confirm success. “Verify verifies against selected firmware.” [Elektroda, p.kaczmarek2, post #21712551]

Can this recover a bricked BK7252 camera?

Yes. After wiring CEN and SPI lines, use Beken SPI mode to read/erase/write. The author provides a BK7252 camera recovery example using this exact method with CH341A and the new flasher. [Elektroda, p.kaczmarek2, post #21711721]

Can I use CH341 Programmer or NeoProgrammer once SPI mode is active?

Yes. After the 0xD2 hand‑off, the BK behaves like a generic SPI flash. You can then operate with common SPI flash tools (CH341 Programmer or NeoProgrammer) if you prefer. [Elektroda, p.kaczmarek2, post #21711721]

Linux support: what baud rates are stable under mono?

Mono 6.12 worked for testers. They reported stable operation at 921,600 baud; 1,500,000 worked on Windows, but they lowered to 921,600 on Linux. LAN Scanner and release downloader also worked. [Elektroda, insmod, post #21712663]

The tool shows a 4,096 KB device. Is that normal for these chips?

Yes. A sample JEDEC ID FF‑EF‑40‑16 decoded to 4,096 KB and printed by the tool. That confirms JEDEC read and size decoding in SPI mode. Actual sizes vary by module; always check the tool’s detected flash size. [Elektroda, p.kaczmarek2, post #21711721]

How do I just switch a BK device into SPI mode without reading or writing?

Use the new “Detect” button. It performs a zero‑length custom operation to toggle CEN and send the 0xD2 sync, placing the chip in SPI mode for use with other SPI tools. [Elektroda, p.kaczmarek2, post #21731041]

I flashed many times and now erase fails. What should I try?

Expand Unprotect logic before erase, similar to AsProgrammer. A contributor noted needing stronger Unprotect after many BK7252 cycles. Add an Unprotect/Status-Register release step, then retry the erase/write. [Elektroda, p.kaczmarek2, post #21714737]

What is OpenBeken (OBK) in this context?

OpenBeken is an open‑source firmware used across supported Wi‑Fi MCUs in this ecosystem. The author uses OBK devices for testing and demos, including camera boards and remote flashing concepts. [Elektroda, p.kaczmarek2, post #21714427]

Can I flash a BK device over Wi‑Fi/TCP instead of USB?

Yes, a Wi‑Fi flasher demo proxies UART over TCP and controls CEN via an OBK device. It’s a separate utility that mirrors the BK UART routines, useful when PC‑to‑target wiring is hard. [Elektroda, p.kaczmarek2, post #21720013]

Any known edge cases or failure symptoms I should expect?

If CH341DLL is missing, some GitHub builds previously exited. On mono/Linux, 1,500,000 baud may fail while 921,600 works. Also, after heavy cycling, protection bits may block erase until Unprotect expands. Address each symptom as noted, then retry. [Elektroda, divadiow, post #21712310]
Generated by the language model.
%}