logo elektroda
logo elektroda
X
logo elektroda

[BL2028N/BK7231M] Flashing Dogness D07 (Belon Chip) - Boot Issues

terryb8s 4842 56
Best answers

Why does my Dogness D07 stop booting after flashing OpenBeken, and what flash layout should I use so it starts correctly?

The device needs its original RT-Thread bootloader layout preserved; it is not a standard Tuya-style flash map, and flashing the app at the wrong offset or overwriting the bootloader causes the no-boot symptom [#21096057][#21096267][#21109139] The working fix was to do a full erase, restore the factory 0x0–0x10000 bootloader from the backup, and then flash OpenBK7231N_App_QIO_1.0.0.bin starting at 0x10000 [#21108271][#21108341] The OpenBK flasher was later changed to skip the bootloader portion by default for BK7231N, because overwriting bootloader is usually a mistake on this device [#21109139] If you build a combined image manually, the thread shows the bootloader can be inserted with the zero-keys build, but the safer route is to leave the factory bootloader in place [#21108341] Wi‑Fi AP/UAP problems can still happen after it boots; in this case, “Restore RF” or writing only the OBK config SSID/password was used to get networking working [#21108271][#21109280][#21109319]
Generated by the language model.
ADVERTISEMENT
  • #1 21096016
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8
    Hi Everyone,

    I have a curly one, and I have spent a lot of time on this with little success so far but have a bunch of information as a result of my tinkering, I get the feeling the issue I'm having is its not a Tuya device so the partitions are in the wrong please, I have tried taking a look at the binary dump in Ghidra but I'm no firmware reverse engineer. Any help would be appreciated! Even if its to tell me its not possible so I know to stop :P

    I have uploaded the firmware dump in the attached zip.

    Flashing results in it not booting from what I can tell, both tx\rx lines display only "□" each time i perform a reset

    Have Tried the following
    * Flashing several versions of openbeken for BK7231N
    * Flashing a Tuya backup from another basic device, then flashing OpenBeken firmware.
    * Have been able to flash back to original firmware each time and it seems to be happy again.

    Flash information: mid: 1560EB, icName: TH25Q_16HB, manufacturer: TH, szMem: 1000000, szSR: 2, cwUnp: 0, cwEnp: 7, cwMsk: 407C, sb: 2, lb: 5, cwdRd: 05-35-FF-FF, cwdWr: 01-FF-FF-FF
    Entering SetProtectState(True)...
    sr: 4
    sr: 4004
    final sr: 4004
    msk: 407c
    cw: 0, sb: 2, lb: 5
    bfd: 0
    sr: 0
    sr: 0
    final sr: 0
    msk: 407c
    cw: 0, sb: 2, lb: 5
    bfd: 0

    Some of the serial output from alt set of tx\rx pins when dogness firmware loads.
    R0:0x00800000R1:0x00000000
    R2:0x005AA000
    R3:0x00000006
    R4:0x00400001
    R13:0x00401C1C
    R14(LR):0x000033AC
    ST:0x00000000
    [I/FAL] Fal(V0.4.0)success
    [I/OTA] RT-Thread OTA package(V0.2.4) initialize success.


    go os_addr(0x10000)..........
    0
    prvHeapInit-start addr:0x40ff70, size:131216
    [Flash]id:0xeb6015
    [Flash]init over
    sctrl_sta_ps_init
    SDK Rev: 3.0.46
    [THD]app:[tcb]411250 [stack]410248-411248:4096:5
    [THD]extended_app:[tcb]411ac0 [stack]4112b8-411ab8:2048:4
    [THD]idle:[tcb]411f30 [stack]411b28-411f28:1024:0
    [THD]timer_thd:[tcb]412cb8 [stack]4120b0-412cb0:3072:2
    OSK Rev: F-3.0.28
    cset:0 0 0 0
    /********flash_get_addr*******/
    read addr:1fd000
    00 99 33 41 0b 8d
    bandgap_calm_in_efuse=0x3c
    [load]bandgap_calm=0x20->0x1c,vddig=4->5
    [FUNC]rwnxl_init
    chip id=7231c device id=20521028
    IP Rev: W4-3.0.46-P0
    txdesc flush
    [FUNC]intc_init
    [FUNC]calibration_main
    get rfcali_mode:1
    device_id=0x20521028

    Device purchased here, for specs etc
    https://www.pbtech.co.nz/product/PETDON0003/D...ss-D07-Smart-18L-Fountain-Smart-Pet-Water-Dis

    Also found a copy of the Belon Writer V1.55 if anyone wants it, it seems to only have write not read, does have compare though

    All the images I have taken, would be keen to know if anyone has a good place to get a cheap bdm frame or similar, I like the look of PCBite probe kit but its too expensive for my use cases.

    Printed circuit board with connected wires Close-up of a Dogness device circuit board showing TXD and RXD pins with various electronic components. Close-up of a circuit board with multi-colored wires. Image of a circuit board with a microchip and a sticker with information. Circuit board with markings DO7 6.0.3B and 20230413. Mainboard of an electronic device with visible components and connected cables. Close-up of a circuit board with visible soldering points and an integrated circuit. Close-up of a circuit board with various electronic components. Close-up of a green circuit board with a semiconductor and soldering points visible. Close-up of a circuit board with electronic components, including a chip and connectors. Close-up of a circuit board with a BL2023N chip and surrounding electronic components. Close-up of BL2023N integrated circuit on a circuit board. Inside a smart device showing a PCB and connected wires. Photo of a PCB board of an electronic device with visible components and labels. Round PCB with markings, components, and connectors. Integrated circuit on a green printed circuit board with DOGNESS D07 5038 label and pin markings. Dogness device printed circuit board with visible electronic components and wires. Printed circuit board with electronics and connectors. Close-up of a circuit board with various electronic components.
    Attachments:
    • readResult_BK7231N_QIO_dogness_clean_2024-25-5-20-20-44.zip (635.39 KB) You must be logged in to download this attachment.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Helpful post
    #2 21096055
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29

    Usual problem is power.
    How do you power device after flashing? Serial adapter probably doesn't have enough current capability. You need to power it from an external regulator or from the original source.
    Also log in Beken firmware on BK7231T comes from TX2/RX2 uart. That's different from the one used for flashing. Which one are you trying to use?
  • Helpful post
    #3 21096057
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    This device has different bootloader, in case based on RT-Thread. This requires some work on development. Maybe an unencrypted binary would work or binary encrypted with different keys. Not sure about the firmware start offset. Similar issue has been already on forum but wasn't addressed because it seems to be very rare so far...
    Helpful post? Buy me a coffee.
  • #4 21096182
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29

    wouldn't flashing full binary replace bootloader? Or is it somewhere else?
  • #5 21096244
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    >>21096055This is good suggestion, I did think of this though, apologies I forgot to add this to the post, it was actually one of the last things I tried before posting this, powered it off the normal power supply.

    It also posts while attached to the serial adapter with its stock firmware which is how I got the logs from the other serial pins.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #6 21096267
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    Try flashing 2MB binary full of 0x00 bytes and you will see that RT thread message persists. Bootloader is... somewhere outside on N.
    Helpful post? Buy me a coffee.
  • #7 21096395
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    Oh that's a shame, I imagine this is something that's already been investigated? As at this point I'm up for more risky options and flashing a new bootloader seems like fun 😊 

    Is there anything I can check allow me to create a custom binary?

    I also considering that I could transplant bk7231n from another device, I have a bunch of rf blind controller I picked up on clearance that either have an N or T, haven't checked which as yet will be one or the other though.

    The other item is I know from ghidra that the firmware layout is quite different from tuya devices, this isn't likely to affect anything? Was kinda thinking given I flashed another devices tuya stock firmware this likely would rule that out though as I tried flashing openbeken after that which resulted in the same boot issue.
    Helpful post? Buy me a coffee.
  • #8 21103253
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    Have been able to get it working with some massive help from the lovely people working on LibreTiny

    The main component of the solution was from one of the cloudcutter team on their discord and then help from the lead Dev, thank you both!

    Created a config in ESPHome on my HA server which I was able to use to generate a uf2 then flash the device with it using ltchiptool
    Code: YAML
    Log in, to see the code

    I was then able to write the LibreTiny kickstart OTA as and get that going, which is an option I will explore as I already have a bunch of other ESPHome devices. I did have some issues with the device not connecting to WiFi but was able to resolve this with the Restore RF part in Easy UART flasher.

    For completeness though I also did the same again but flashed the latest openbeken OTA and have been able to get that going, I did however have some different WiFi issues where the standalone AP doesn't let you browse to the web server, Restore RF part didn't work in this case but I worked around by setting the WiFi AP settings in Easy UART Flasher and using the Write only OBK config.

    Obviously this isn't an ideal way to get this device booting and mostly working but gives me a way to start working on the module config for either LibreTiny or OpenBeken

    I have attached a working dump, that I removed WiFi settings from, so anyone who wants to use it will need to write new ones from Easy UART Flasher at this stage

    Would be keen to know if this can be used to add better support for Dogness devices, I have also attached the SPI dump I took using ltchiptools SPI addon

    P.S. if you live in NZ or AU I caution buying the FT232RL based duinotech USB to serial adapter (XC4594) from Jaycar, its junk especially for the price the 3.3/5v select switch doesn't work it just outputs 5v either way, I'm lucky I didn't let out the magic smoke...
    Attachments:
    • readResult_BK7231N_QIO_dogness_d07_working_clean_2024-02-6-01-06-18.zip (1.17 MB) You must be logged in to download this attachment.
    • ltchiptool_dogness_d07_spi_2024-06-01_03-34-38.zip (635.38 KB) You must be logged in to download this attachment.
    Helpful post? Buy me a coffee.
  • Helpful post
    #9 21103288
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    So they just use 0000 as encryption key? Well that certainly wouldn't be hard to guess.
    So I need to change key here:
    Screenshot of a text editor showing a highlighted build script line related to encryption.
    @terryb8s are you willing to help me testing that so we can add those binaries to OBK builds?

    Added after 1 [hours] 3 [minutes]:

    Screenshot showing a portion of the build.sh script with code changing the encryption key.
    Attachments:
    • test20240601.zip (7.78 MB) You must be logged in to download this attachment.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #10 21103347
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    i attached my binaries so you can try
    Helpful post? Buy me a coffee.
  • #12 21103729
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    Hopefully it will work soon, maybe not on the first try, but we will see... do we also need to change the flash address?

    Btw, in your binaries, which OBK version is it? Maybe I could try downloading and comparing it against my builds... but I would need to know which version you have exactly. Hmm
    Helpful post? Buy me a coffee.
  • #13 21103739
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8
    >>21103729 Flashed the QIO bin from the zip you attached, result seems to be not booting, I have serial attached to the P0/P1 UART2 along with another for flashing via UART1 and only get something similar to □, rather than full boot, no AP, this was flashed from 0x0 by the looks of Easy Flasher output.

    I can try with an offset if you like, I guess with ltchiptool? is there a way to do this with easy flasher, a hidden feature to load a file and set offsets?

    Build I used for OTA in the dump I attached was OpenBK7231N_1.17.601.rbl
    Helpful post? Buy me a coffee.
  • #14 21103748
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    Maybe you can use our QIO but keep (or overwrite) with their original bootloader, can you try? I will investigate it more in the morning (it's late night here in my country).
    Helpful post? Buy me a coffee.
  • #15 21103750
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8
    Tried flashing the QIO bin with ltchiptool at offset 0x11000 and same for skip offset for input file, no boot, reset it to factory image then also tried rbl at 0x132000, no boot (didn't think this would work)

    Added after 3 [minutes]:

    link to LibreTiny discord post if anything in there helps too, though I think I have posted most of the info here.
    https://discord.com/channels/967863521511608370/1246228719593328681

    sorry Its mid morning here, its all good I can wait as I can't work on this much longer till tonight anyway
    Helpful post? Buy me a coffee.
  • Helpful post
    #16 21103751
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    AES keys seems unchanged so I need to investigate more:
    Screenshot of a code snippet featuring commands related to encryption and file generation.
    Helpful post? Buy me a coffee.
  • #17 21104708
    divadiow
    Level 38  
    Posts: 4882
    Help: 427
    Rate: 869
    I have tried flashing OpenBK7231N_App_QIO_1.0.0.bin starting at 0x0 and no skip offset but no OBK and no boot log.

    Also tried going back to factory, which worked, then flashing OpenBK7231N_App_UA_1.0.0.bin from 0x1000 with no skip offset but no success either

    This was using this Matter device with 1.0.13 bootloader and seemingly no encryption

    https://www.elektroda.com/rtvforum/topic4032988.html

    Added after 4 [minutes]:

    here's a dump of the efuse for the Matter device if that's of any help investigating
    Attachments:
    • 1.0.13_Matter_efuse.bin (32 Bytes) You must be logged in to download this attachment.
  • #18 21105147
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    Got it working this morning :)

    Performed full erase.

    Flashed 0x0 to 0x10000 from factory goodness backup

    Flashed starting 0x10000 the OpenBK7231N_QIO_1.0.0.bin provided

    Had to do RF restore to get AP working.

    Not sure if the image is cut down in any way pwn seemed to not work on P7 which was working previously.

    I also see an error before it starts the OS about OTA
    Terminal screen view with boot logs for BK7231n device showing errors and success messages.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #19 21105156
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    I see, so in order to add support of that to our builds, I need construct a binary from 0x0 to 0x10000 your bootloader, then with OBK data?

    Why was restore RF required? Or maybe... maybe it makes sense, if this has totally different firmware, then RF partition was not present at all?

    Did you do restore RF on your first OBK attempt?

    I need to compare original 2MB dump with our RF patition to know what's there.
    Helpful post? Buy me a coffee.
  • #20 21105157
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    Thinking the OTA error is because of my full erase, so nothing will be there based on the memory map, correct?

    BK7231N:
    Name Code Start Length
    Bootloader BK_PARTITION_BOOTLOADER 0x00000000 0x11000 //68KB
    Application BK_PARTITION_APPLICATION 0x11000 0x121000//1156KB
    ota BK_PARTITION_OTA 0x12A000 0xA6000 //664KB
    RF Firmware BK_PARTITION_RF_FIRMWARE 0x1D0000 0x1000
    NET info BK_PARTITION_NET_PARAM 0x1D1000 0x1000


    Added after 6 [minutes]:

    >>21105156 Yes I believe i did do a RF restore as was having issues with wifi in with ESPhome

    The SPI dump will have the original RF

    The working version with original bootloader to 0x10000 and QIO image from 0x1000 this morning would not have had RF as I did full erase before I started.
    Helpful post? Buy me a coffee.
  • #21 21105162
    divadiow
    Level 38  
    Posts: 4882
    Help: 427
    Rate: 869
    terryb8s wrote:
    Thinking the OTA error is because of my full erase, so nothing will be there based on the memory map, correct?

    won't OTA fail because it's at 0x132000 like T and not at 0x12A000 like N
  • #22 21105163
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    Doing full erase will indeed also erase RF partition, which is later not affected by flashing OBK. So that's why you had to restore RF manually?
    Helpful post? Buy me a coffee.
  • #23 21105171
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    >>21105163 yes that would be the case as I said it erases first so would be nothing there.

    Yes had to do RF restore as the MAC ended with 000000 and AP mode wasn't working as a result.

    Just now replicated the same full erase then original bootloader, then your QIO image, then also restore RFNet data and I get the following. (see below: WARN: TCPIP mutex is NOT locked)

    Code: Text
    Log in, to see the code


    Added after 54 [seconds]:

    >>21105162with my full erase I think it's likely because nothing was there.
    Helpful post? Buy me a coffee.
  • #24 21105175
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    I don't know what kind of mystery is going on in that RF partition, but I was aware that in some rare cases doing my "restore RF" fixes broken WiFi. That being said, I had some devices with broken RF (MAC ending with 00 00 00) and they still had WiFi working, except for the MAC duplicate issue (with cleared MAC, both devices had the same MAC, ending with 00 00 00).

    Anyway, it's again late night in my country, so (hopefully) tomorrow morning I will try to replicate what you said in the build script and add binaries to main releases...

    Added after 1 [minutes]:

    I can see that there is our bootloader here:
    https://github.com/openshwprojects/OpenBK7231...r/platforms/bk7231n/bk7231n_os/tools/generate
    So I will have to paste dogness boot here and adjust script to support both versions...

    Added after 1 [minutes]:

    https://github.com/search?q=repo%3Aopenshwpro...%2FOpenBK7231N%20bk7231n_bootloader&type=code
    Script snippet from the OpenBK7231N project showing bootloader configuration.

    Added after 1 [minutes]:

    So I guess, for now, I need to take that into a conditional statement:
    Code: Bash
    Log in, to see the code

    and call N SDK build twice from Github workflow yaml
    Helpful post? Buy me a coffee.
  • #25 21105187
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    Sounds great I might start looking into how to do this sorta thing myself as I find all this very interesting.

    I'm no expert on this stuff as well so I really have no idea why the RF restore works, I just know it helped with the issue I was having, I don't understand what "configuring interface uap (with Static IP)WARN: TCPIP mutex is NOT locked (1) caller 53D07" means in terms of the RF mystery, it might not even be the problem.

    Also thanks again for all your help, I am in no rush so happy to wait given we are in different time zones no pressure from me, there are plenty of times I will be unavailable as well :-)
    Helpful post? Buy me a coffee.
  • #26 21106098
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    Ok so I made a 0x10000 file from backup from the first post:
    Screenshot of the XVI32 program showing the editing of a binary file with numerous FF values.
    I've added it here:
    https://github.com/openshwprojects/OpenBK7231...mmit/5f19b009a83056a34c16e84e205547bbad3cddfa
    I also modified scripts to allow extra argument to select build type:
    https://github.com/openshwprojects/OpenBK7231...mmit/2fc6ba04b25c577abe91e5c9edb5adc76d1b6a35
    https://github.com/openshwprojects/OpenBK7231...mmit/0dd12d65a28099184f3166727cda6238bd8c131c
    However, I am now getting some Tuya packager error, so more is to come..
    
    Start Combined
    Using zero keys mode - for those non-Tuya devices
    /**< @author <jiewu@bekencorp.com> */
    /**< @version v0.3.1 */
     encrypt without crc successfully!
     -file size: 0xc2610
    {
        "count": 4,
        "magic": "RT-Thread",
        "section": [
            {
                "firmware": "bk7231n_bootloader_zero_keys.bin",
                "partition": "bootloader",
                "size": "68K",
                "start_addr": "0x00000000",
                "version": "1.00"
            },
            {
                "firmware": "OpenBK7231N_App_1.0.0_enc.bin",
                "partition": "app",
                "size": "1150832",
                "start_addr": "0x00011000",
                "version": "1.00"
            }
        ],
        "version": "0.1"
    }
    beken packager V2.0.0
    Shanghai Real-Thread Electronic Technology Co.,Ltd
    
    load_config: config.json
    
    partition    flash_name       phy addr   size       logic addr size       file
    ------------ ---------------- ---------- ---------- ---------- ---------- ----------------
    bootloader   beken_onchip_crc 0x00000000 68K        0x00000000 64K        bk7231n_bootloader_zero_keys.bin
    app          beken_onchip_crc 0x00011000 1150832    0x00010000 1083136    OpenBK7231N_App_1.0.0_enc.bin
    
    [Error]: partition [bootloader] overflow, 65536 ==> 69664 > 69530!
    make: *** [Makefile:6: all] Błąd 127
    


    Added after 22 [minutes]:

    69664-69530=134 ... 134 bytes too much in my bootloader, did I accidentally cut too much? Where would that lead me?
    Screenshot of a hexadecimal editor showing binary data with navigation set to address 134.
    Those are just 0xFF bytes, I think I can strip them

    Added after 8 [minutes]:

    edit: no, still error:
    
    partition    flash_name       phy addr   size       logic addr size       file
    ------------ ---------------- ---------- ---------- ---------- ---------- ----------------
    bootloader   beken_onchip_crc 0x00000000 68K        0x00000000 64K        bk7231n_bootloader_zero_keys.bin
    app          beken_onchip_crc 0x00011000 1150832    0x00010000 1083136    OpenBK7231N_App_1.0.0_enc.bin
    
    [Error]: bk7231n_bootloader_zero_keys.bin please input a file without crc
    make: *** [Makefile:6: all] Błąd 127
    

    I may just manually write that bootloader into generated qio...

    Added after 57 [minutes]:

    hm maybe I can just dd it::
    
    	dd if="bk7231n_bootloader_zero_keys.bin" bs=1 count=65536 of="$TEMP_FILE"
    	dd if="${APP_BIN_NAME}_QIO_${APP_VERSION}.bin" bs=1 skip=65536 of="$TEMP_FILE" seek=65536
    
    Helpful post? Buy me a coffee.
  • #27 21107602
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    terryb8s wrote:

    Flashed 0x0 to 0x10000 from factory goodness backup

    Flashed starting 0x10000 the OpenBK7231N_QIO_1.0.0.bin provided

    0x10000 or 0x11000 ?
    Helpful post? Buy me a coffee.
  • #28 21108271
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    Works! using https://www.elektroda.com/rtvforum/topic4056533.html#21107630

    First Test:
    1. Erase all with BK7231 Easy UART
    2. Flash OpenBK7231N_App_QIO_1.0.0.bin
    3. Device boots! (Still has the TCPIP mutex is NOT locked (1) caller 53D07 error)
    4. Connect via WiFi to device, connected fine, MAC ends in all 000000
    5. Connected device to my WiFi network, access to device working!!! Awesome!

    Second test
    1. Erase all with BK7231 Easy UART
    2. Flash factory dogness binary
    3. Flash OpenBK7231N_App_QIO_1.0.0.bin
    4. Device boots! (Still has the TCPIP mutex is NOT locked (1) caller 53D07 error)
    5. Connect via WiFi to device from mobile device: failed, connect via second mobile device: connected, no access to Web App, connect via Windows PC: failed.
    6. Flash only OBK config wireless network SSID and password, connected and working, MAC is c8:47:8c:00:00:00
    7. Restore RF part, unique MAC present and connected to network SSID fine, I assume this likely has fixed the UAP issues as well but its late.

    Sorry its taken me a bit since my last post, worklife busy over last couple of days.

    Be keen to hear your thoughts on the WiFi issue and if there is anything I can do to help resolve that? I guess as long as people know that it might be an issue its fine?

    Curious did you use 0x10000 or 0x11000 in the end?

    Attached the boot if that's of any help just removed the SSID and password.

    Awesome thank you! hoping I can learn some of the ways you achieved this for future devices :-) Will be taking a look at the source in the git repo, hopefully I can learn a thing or two :-P
    Attachments:
    • Boot.txt (7.14 KB) You must be logged in to download this attachment.
    Helpful post? Buy me a coffee.
  • #29 21108294
    terryb8s
    Level 4  
    Posts: 41
    Help: 1
    Rate: 8

    Oh i see the WiFi error is gone in the boot.txt I attached, this was captured after a reboot...

    I tried another reboot and it happened again though... weird.
    Attachments:
    • Boot2.txt (8.69 KB) You must be logged in to download this attachment.
    Helpful post? Buy me a coffee.
  • #30 21108341
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12432
    I added encryption key reading to flasher, can you get latest build:
    https://github.com/openshwprojects/BK7231GUIFlashTool/releases/tag/v1.2
    And do just "Do firmware backup (read) only)" and show me what is there:
    Screenshot of BK7231 Easy UART Flasher tool showing reading success.
    Can you check if it's working for you and what's it showing?

    Added after 1 [minutes]:

    I used 0x10000, see here:
    https://github.com/openshwprojects/OpenBK7231...mmit/cf30fbec6d8ba48b2a70f5d8d23b5c980a304146
    
    	dd if="bk7231n_bootloader_zero_keys.bin" bs=1 count=65536 of="$TEMP_FILE"
    	dd if="${APP_BIN_NAME}_QIO_${APP_VERSION}.bin" bs=1 skip=65536 of="$TEMP_FILE" seek=65536
    	mv "$TEMP_FILE" "${APP_BIN_NAME}_QIO_${APP_VERSION}.bin"
    	echo "Successfully overwrote bootloader."
    
    Helpful post? Buy me a coffee.

Topic summary

✨ The discussion addresses boot issues encountered when flashing the Dogness D07 device, which uses a Belon BK7231N chip, with custom firmware such as OpenBeken and LibreTiny. The device is not a standard Tuya device, leading to challenges due to different partition layouts and an RT-Thread-based bootloader. Flashing attempts with various OpenBeken versions and Tuya backups resulted in non-booting devices showing only garbled serial output. Key findings include the necessity to preserve the original encrypted bootloader (occupying 0x0 to 0x11000) and flash the application firmware starting at offset 0x11000 or 0x10000. Full flash erases require manual RF partition restoration to recover WiFi functionality and unique MAC addresses, as the RF calibration data is device-specific and stored separately. The community developed a solution involving a combined binary with the original bootloader and OpenBeken application, enabling successful boot and WiFi connectivity, though some warnings like "TCPIP mutex is NOT locked" persist. The Easy BK7231 GUI Flash Tool was updated to support reading encryption keys and skipping bootloader overwrites. Additional challenges include unstable or slow WiFi Access Point (UAP) functionality, which improves after RF data restoration but is not fully resolved. The discussion also covers PWM control for the water pump and LEDs on the device, with attempts to configure PWM channels and button inputs, noting unexpected channel interactions and waveform characteristics observed via oscilloscope. The community continues to refine firmware builds and flashing tools to support this off-brand device, emphasizing the importance of preserving bootloader and RF partitions and adapting encryption keys for successful firmware deployment.
Generated by the language model.

FAQ

TL;DR: With a 2 MB flash dump and the factory bootloader preserved, the workable fix was: "leave the factory one" and flash OpenBeken as a QIO app instead of replacing boot code. This FAQ is for Dogness D07 and similar BL2028N/BK7231M-style devices that boot to garbage UART output or lose Wi‑Fi after flashing. [#21109139]

Why it matters: This thread shows how to recover and modernize an RT-Thread-based BK7231 device without destroying the original boot path.

Option Boot result Required special settings Reported issues
Standard BK7231N OpenBeken flash from 0x0 No boot None UART shows squares, no AP
LibreTiny/ESPHome UF2 with zeroed crypto settings Boots Custom key/IV and 0x132000+0xAE000 download map Initial Wi‑Fi issues
OpenBeken QIO while preserving factory bootloader Boots Keep factory bootloader, then flash app RF restore may still be needed

Key insight: The decisive fix was not a different UART adapter or more power. The device used a nonstandard RT-Thread bootloader and partitioning, so preserving the original bootloader and app layout mattered more than flashing another generic BK7231N image. [#21096057]

Quick Facts

  • The device flash identified as TH25Q_16HB reported szMem: 1000000, which corresponds to a 16 Mbit / 2 MB flash size used throughout the recovery attempts. [#21096016]
  • Stock firmware logs showed go os_addr(0x10000) and RT-Thread OTA init, indicating the original application booted from 0x10000, not a typical plain Tuya-style layout. [#21453281]
  • A working OpenBeken path used full erase, then factory bootloader region from 0x0 to 0x10000, then OpenBK7231N_App_QIO_1.0.0.bin; later confirmation said the build process used 0x10000. [#21108341]
  • The BK7231N partition map discussed in-thread listed bootloader 0x00000000–0x11000, application start 0x11000, OTA at 0x12A000, and RF firmware at 0x1D0000 with NET info at 0x1D1000. [#21105157]
  • When RF data was missing, one observed MAC ended with 00:00:00 and UAP became unreliable; after RF restore, a unique MAC returned and STA mode connected correctly. [#21108271]

How do I flash OpenBeken on a Dogness D07 with a BL2028N/BK7231M-style RT-Thread bootloader without bricking the original bootloader?

Preserve the factory bootloader and flash OpenBeken only as the application. Use this 3-step method: 1. Back up the full 2 MB flash. 2. Keep or restore the factory region from 0x0 to 0x10000. 3. Flash the OpenBeken QIO app without overwriting boot code. Later flasher changes explicitly skipped the bootloader by default because overwriting it was considered a mistake on these devices. That approach solved booting on the Dogness D07 while keeping the RT-Thread startup path intact. [#21109139]

Why does a Dogness D07 only show square characters on UART after flashing BK7231N OpenBeken builds, and what does that usually indicate?

It usually indicates the flashed image is not booting correctly, not just a wrong terminal setting. The thread tied the square characters to a mismatch between the Dogness RT-Thread bootloader and standard BK7231N OpenBeken images. Once the factory bootloader path was preserved, the device booted normally. One early expert summary said the device had “different bootloader” and uncertain firmware start offset, which matches the no-boot symptom seen after generic flashes. [#21096057]

What flashing layout finally worked for the Dogness D07 — full erase, factory bootloader region, QIO image, and RF restore?

The working layout was full erase, then factory boot region, then OpenBeken QIO, then RF restore if Wi‑Fi was broken. The confirmed sequence was: 1. Erase all. 2. Flash the factory dump from 0x0 to 0x10000. 3. Flash OpenBK7231N_App_QIO_1.0.0.bin, then restore RF/Net if needed. A later code note confirmed the combined image used 0x10000, not 0x11000, when overwriting the bootloader section in the build workflow. [#21108341]

Which UART pins should I use on BK7231-based devices for flashing versus boot logs, especially when stock firmware logs appear on TX2/RX2?

Use the normal flashing UART for programming, but expect stock firmware logs on UART2 on some Beken devices. In this thread, the stock Dogness firmware printed readable logs from the alternate TX2/RX2 pair, while flashing still used the regular UART. A moderator explicitly noted that Beken firmware logs on BK7231T come from TX2/RX2 and that this UART differs from the one used for flashing. The same distinction helped interpret the Dogness D07 serial behavior. [#21096055]

Why did restoring the RF partition fix Wi-Fi issues like a MAC address ending in 00:00:00 and a broken AP on this Dogness device?

Restoring RF data fixed missing radio identity and calibration data after a full erase. The clearest symptom was a MAC ending in 00:00:00, plus a UAP that either failed to load or connected with no usable web app. After RF restore, the device regained a unique MAC and connected correctly in STA mode. The thread also noted that full erase wipes the RF partition, while later OpenBeken flashing does not recreate its original contents automatically. [#21105171]

What is the RF partition on BK7231N/BK7231M devices, and what kinds of calibration or network data does it usually store?

“RF partition” is a flash storage area that keeps radio-related calibration and network identity data, including MAC-related values, RF firmware, and network parameters. In this thread, the posted BK7231N map placed RF firmware at 0x1D0000 with length 0x1000, and NET info at 0x1D1000 with length 0x1000. The original Dogness logs also showed missing or defaulted calibration items such as TX power tables, thermal values, and XTAL settings when reading flash. [#21453281]

What does UAP mean on BK7231/OpenBeken devices, and why would UAP connect slowly or fail to open the web app even when STA mode works?

UAP is the device’s own Wi‑Fi access point mode used for local setup. In this case, UAP was unstable even when STA mode worked after writing SSID and password through the flasher. One report measured more than 900 ms latency and many retransmits in Wireshark, while another noted Android phones could connect yet not reach the web app. That pattern suggests the OpenBeken AP path booted, but the radio or network stack remained degraded on this specific Dogness platform. [#21111254]

How can I read or verify the encryption keys and efuse data on a Belon or Dogness BK7231 device with BK7231GUIFlashTool or Easy UART Flasher?

Use the updated flasher and run a firmware backup read to display the key-related data. The thread states that encryption key reading was added to BK7231GUIFlashTool v1.2, and the requested method was “Do firmware backup (read) only.” A follow-up screenshot confirmed the feature worked on the Dogness device. This was presented as a useful way to inspect unusual non-Tuya devices and compare their efuse or key setup before flashing alternate firmware. [#21108341]

LibreTiny vs OpenBeken on a Dogness D07 — which is easier to get booting first when the device uses non-Tuya partitions and RT-Thread OTA?

LibreTiny with a custom ESPHome UF2 was the first working route reported in the thread. It booted after setting zeroed bkcrypt_coeffs, custom OTA key and IV, and a nonstandard 0x132000+0xAE000 download map. OpenBeken also worked later, but only after preserving the factory bootloader path or using adjusted builds. If your goal is first boot on this exact Dogness D07, LibreTiny reached a working state earlier in the troubleshooting timeline. [#21103253]

What does the 'TCPIP mutex is NOT locked' warning mean in OpenBeken boot logs, and how likely is it to be related to AP instability?

It is a network-stack warning seen during UAP setup, but the thread did not prove it was the root cause. The message appeared as WARN: TCPIP mutex is NOT locked (1) caller 53D07 while the AP initialized, yet another tester reported seeing similar “mutex” messages on a different device where AP still worked. That makes it a plausible clue, not a confirmed diagnosis. On the Dogness D07, AP instability persisted even after RF restore, so the warning alone does not explain everything. [#21109280]

How do I generate a LibreTiny or ESPHome UF2 for a BK7231N device that needs zeroed bkcrypt coefficients, custom OTA key/IV, and a nonstandard download offset?

Create an ESPHome config that explicitly sets zeroed crypto coefficients, a custom OTA key and IV, and the Dogness download map. The successful config used board_build.bkcrypt_coeffs: "000...000", board_build.bkota.key: "0123456789ABCDEF0123456789ABCDEF", board_build.bkota.iv: "0123456789ABCDEF", and board_flash.download: "0x132000+0xAE000". Then generate the UF2 and flash it with ltchiptool. That produced a bootable image on the Dogness D07 and enabled further LibreTiny or OpenBeken testing. [#21103253]

What is RT-Thread OTA on BK7231 devices, and how is it different from the usual Tuya/OpenBeken boot and partition scheme?

RT-Thread OTA is the stock update and boot framework used by this device instead of the usual Tuya-style scheme. The Dogness logs showed RT-Thread OTA package(V0.2.4) and booting with go os_addr(0x10000), which already differs from typical plain OpenBeken assumptions. “RT-Thread OTA is a firmware update framework that boots applications from a defined offset and manages packaged images, using its own partition expectations and metadata.” That difference explains why a generic BK7231N image failed until the factory boot path was respected. [#21453281]

Why is preserving the factory bootloader recommended on some BK7231N/BK7231M devices instead of overwriting it with a standard OpenBeken QIO image?

Preserving it is recommended because some devices use encrypted or vendor-specific boot code that generic OpenBeken images do not replace correctly. The maintainer later changed flasher behavior so it skips the bootloader portion by default, even for QIO images. He also stated that overwriting the bootloader seemed to be a mistake and suggested the vendor bootloader was encrypted. On the Dogness D07, keeping the original bootloader was the turning point between repeated no-boot failures and a working OpenBeken startup. [#21109139]

What is the best way to control a PWM-driven water pump separately from LEDs in OpenBeken, including using custom sliders, channel mapping, or Btn_ScriptOnly with autoexec.bat?

Use separate channels and, if button behavior gets mixed with LED logic, switch to Btn_ScriptOnly plus autoexec.bat. In the Dogness config, pump control used P8 and P9 on channel 4, while P28 was a relay on channel 5. The user found that a normal button mapping still triggered channel 5, but stripping the config showed the LED driver caused that interaction. The maintainer’s recommended workaround was Btn_ScriptOnly and manual scripting so the pump slider stays independent from LED toggles. [#21112302]

How can I reproduce the stock Dogness D07 pump drive waveforms — like overlapping triangle and sawtooth PWM seen on P8 and P9 — to reduce pump noise in OpenBeken?

You cannot reproduce that waveform from this thread alone, and OpenBeken did not offer a confirmed method here. The user measured two overlapping shapes on P8 and P9 with an oscilloscope in November 2024, hoping to reduce pump noise versus plain PWM. The maintainer replied that he had never seen BK7231 generate such waveforms and asked whether the GPIO had been isolated before measurement, suggesting passive components on the board may have altered the observed shape. That leaves the waveform unconfirmed and unreproduced. [#21316886]
Generated by the language model.
ADVERTISEMENT