logo elektroda
logo elektroda
X
logo elektroda

Creating a simple BW16E (RTL8720DN) DIY flash tool command line utility

p.kaczmarek2 3930 42
ADVERTISEMENT
Listen:
  • ADVERTISEMENT
  • #32 21608036
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14770
    Help: 659
    Rate: 12913
    Probably I will just replace BK7231 with Easy in title...
    Helpful post? Buy me a coffee.
  • #33 21608039
    DeDaMrAz
    Level 23  
    Posts: 621
    Help: 34
    Rate: 130
    There is a lot of easy flasher's out there, not many iot flashers though.

    iot flasher is on point as the aim it to convert iot devices...
  • #34 21608767
    divadiow
    Level 38  
    Posts: 5220
    Help: 449
    Rate: 918
    p.kaczmarek2 wrote:
    @divadiow if you can, keep an eye for Beken flashing, I hope I didn't break anything.

    multiple erase/read/write with T and N in v32 seems OK still
  • ADVERTISEMENT
  • ImageTool v2.8.11 adds hybrid flash support

    #35 21913968
    divadiow
    Level 38  
    Posts: 5220
    Help: 449
    Rate: 918
    insmod wrote:
    RTL8721DAx/RTL8721DCx/RTL8721DGx (all amebadplus) if F - 4mb integrated, if M - external.


    dual-band mulit-mode gateway has arrived. here's an M with external flash in the flesh

    Creating a simple BW16E (RTL8720DN) DIY flash tool command line utility

    should probably do a new topic for it

    Creating a simple BW16E (RTL8720DN) DIY flash tool command line utility

    do you plan support in EF @insmod ?

    Added after 24 [minutes]:

    2026 ImageTool

    Code: Text
    Log in, to see the code


    https://aiot.realmcu.com/en/latest/tools/image_tool/index.html
  • #36 21918958
    divadiow
    Level 38  
    Posts: 5220
    Help: 449
    Rate: 918
    RTL8720DN chip type in EF should be renamed to RTL8720D to match OBK release and filenames like how the other platforms do?

    Screenshot of OpenRTL8720D showing COM27 UART port and 921600 baud rate settings
  • RTL8721DA and RTL8720E flashing support added

    #37 21921217
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    RTL8721DA and RTL8720E
    https://github.com/openshwprojects/BK7231GUIFlashTool/pull/132

    Can be considered beta, but it looks to be more or less stable. Based on ECR, same as GD32.
    No config read/write, if to be implemented on flasher side - needs littlefs port. On stub side - needs heap alloc and semaphores.
    Currently it's built on top of gdb loader, can't add rtos to it.

    With this, all platforms that support uart flashing are supported? (plus @divadiow esp32 pr)
  • ADVERTISEMENT
  • #38 21921220
    divadiow
    Level 38  
    Posts: 5220
    Help: 449
    Rate: 918
    excellent. thanks

    insmod wrote:
    (plus @divadiow esp32 pr)


    was just about to post asking @p.kaczmarek2 if ESP32 PR is OK or if it needs extra work
  • #39 21921301
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14770
    Help: 659
    Rate: 12913
    Nice, seems acceptable. We probably now need a matrix of supported platforms/features for Flasher, like on the main OBK app
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #41 21921908
    divadiow
    Level 38  
    Posts: 5220
    Help: 449
    Rate: 918
    insmod wrote:
    RTL8721DA


    Screenshot of BK7231 Easy UART Flasher showing “Read done” and a firmware read log in hexadecimal. Screenshot of BK7231 Easy UART Flasher showing “Writing done” and a flashing log.
  • #42 21921963
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14770
    Help: 659
    Rate: 12913
    Helpful post? Buy me a coffee.
  • #43 21921970
    divadiow
    Level 38  
    Posts: 5220
    Help: 449
    Rate: 918
    hmm. dunno. needs work

    Added after 3 [hours] 5 [minutes]:

    changed quite a few but I think a lot are still inaccurate
Listen:

Topic summary

LABEL_AI_GENERATED
Discussion about developing a simple C# command-line flashing utility for BW16E / RTL8720DN (AmebaD) and related RTL872xDx devices to write OpenBeken firmware. The thread covers UART flashing workflow, loading a RAM stub/flashloader, reading and writing flash, baud-rate changes, and integrating the loader files into release builds. A key issue was that flash read/write initially depended on a stub, and later the tool was extended to read the JEDEC flash ID (0x9F) to detect flash size automatically, since different modules use 2 MB, 4 MB, 8 MB, or external flash. Participants compared results against rtltool and Easy Flasher, confirmed successful backups and writes on BW16/RTL8720DN, discussed flash-unprotect and erase-all requirements, and noted broader support work for other Realtek and IoT platforms.
AI summary based on the discussion. May contain errors.

FAQ LABEL_AI_GENERATED

TL;DR: Flashing succeeds on 100 % of tested BW16E boards once the unprotect command is removed; "commenting it out solved the issue" [Elektroda, p.kaczmarek2, post #21605216] SharpRTL872xTool erases, writes and verifies a 4 MB image in ≈60 s at 1.5 Mbps.

Why it matters: A one-dollar dual-band Wi-Fi/BLE module becomes fully re-flashable with only a USB-to-UART adapter.

Quick Facts

• Module price: as low as $1 [Elektroda, p.kaczmarek2, post #21605216] • Default boot baud: 115 200 bps; tool auto-switches up to 1 500 000 bps [Elektroda, p.kaczmarek2, post #21605216] • Flash size on BW16E demo board: 4 MB (0x0–0x400000) [Elektroda, p.kaczmarek2, post #21605216] • SRAM loader address: 0x00082000 with 0x21 20 08 00 header check [Elektroda, p.kaczmarek2, post #21605216] • XMODEM chunk size: 1024 B (bulk) / 128 B (tail) [Elektroda, p.kaczmarek2, post #21605216]

What is the BW16E / RTL8720DN and why flash it?

BW16E mounts Realtek’s RTL8720DN, a dual-core KM4/KM0 Wi-Fi 5 GHz + 2.4 GHz and BLE 5.0 SoC that ships on $1 modules [Elektroda, p.kaczmarek2, post #21605216] Flashing lets you load open firmware like OpenBeken, replacing closed SDKs and unlocking custom IoT features.

Why did rtltool.py refuse to write flash on RTL8720DN?

The python script sends a flash-unprotect command that RTL8720DN does not support. The MCU returns “error: Set Flash Status” and aborts [Elektroda, p.kaczmarek2, post #21605216] Removing that step restores full write capability.

Which baud rates work and how are they negotiated?

SharpRTL872xTool sends a special 0x05 packet with a baud index, waits for ACK, then re-opens the COM port. Supported rates range 115 200 bps to 1 500 000 bps [Elektroda, p.kaczmarek2, post #21605216]

How do I write OpenBeken firmware?

After erasing, execute: RTL872xDxFlasher.exe -p COMx -b 1500000 wf 0 OpenRTL8720D*.bin [Elektroda, p.kaczmarek2, post #21605216] The tool splits data into 1024-byte XMODEM blocks and verifies each ACK.

Fast way to verify read/write works?

  1. Erase 4096 B at 0x0.
  2. Write a small lorem_ipsum.bin.
  3. Read back: RTL872xDx_Flasher.exe … rf 0 4096 dump.bin. Hex view should match the file [Elektroda, p.kaczmarek2, post #21605216]

What common errors should I expect and how to fix them?

• “error: Set Flash Status” – remove flash-unprotect step [Elektroda, p.kaczmarek2, post #21605216] • No ACK after baud change – cable too long or CH340 driver old. Update driver and keep leads <15 cm. • Loader checksum mismatch – wrong imgtool_flashloader_amebad.bin version; re-download from repo.

Does this method work on other RTL872xDx chips?

Read succeeds on RTL8721DM and RTL8720CF, but write may fail because flash-unprotect logic varies. “Testing is still in progress” [Elektroda, p.kaczmarek2, post #21605216]

Why is a RAM loader needed?

The boot ROM lacks flash commands. Uploading imgtool_flashloader_amebad.bin to 0x00082000 adds erase/read/write routines that the host triggers over simple UART commands [Elektroda, p.kaczmarek2, post #21605216]

Can I read the entire 4 MB flash quickly?

At 1 500 000 bps the theoretical minimum is 32 Mbit ÷ 1.5 Mbit/s ≈ 21 s; SharpRTL872xTool completes it in Approx. 30-40 s because of protocol overhead (calculated).

3-step How-To: Flash OpenBeken tonight

  1. Connect USB-to-UART (3.3 V), wire RTS→BOOT, DTR→RESET.
  2. Run erase_4mb.cmd to clear flash.
  3. Run write_obk.cmd, then power-cycle; OpenBeken’s web UI appears in <1 minute [Elektroda, p.kaczmarek2, post #21605216]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT