logo elektroda
logo elektroda
X
logo elektroda

NiceMCU XH-WB3S BK7238 Flashing, Testing, Pinout, Development, Porting

divadiow 27909 382
ADVERTISEMENT
  • Separate config variants for Berry and power metering

    #181 21521519
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14794
    Help: 659
    Rate: 12941
    I'm still working on it, but I can't see now any other way to pass the define to make other than manually setting it per platform in like:
    
    \OpenBK7231T\apps\OpenBK7231T_App\sdk\OpenBK7231N\platforms\bk7231n\bk7231n_os\application.mk
    

    Screenshot from Visual Studio showing makefile code with highlighted lines related to the CPPDEFINES variable.
    Maybe I will fall back to separate obk_config.h, at least currently. not sure yet

    Added after 48 [minutes]:

    Ok so I did copy config approach, at least for now. Here is current obk with and without berry:
    A list of files in Windows Explorer, with three .rbl and .bin files highlighted.

    Added after 12 [minutes]:

    Current permutations idea (not finished):
    1. Obk default (like usual)
    2. Obk TuyaMCU
    + enabled berry support
    + enabled charts
    - removed I2C LED drivers
    - removed BL0937, BL0942 and stuff
    - removed IR
    - removed W2812
    3. Obk PowerMetering
    + enabled berry support
    + enabled charts
    - removed generic LED driver
    - removed I2C LED drivers
    - removed TuyaMCU
    - removed W2812
    - removed IR

    Added after 4 [hours] 35 [minutes]:

    List of firmware files, including RBL and OTA types for OpenBK7231, with four RBL files selected.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #182 21521915
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    >>21514572

    did your A9 arrive yet?
  • Helpful post
    #183 21522144
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14794
    Help: 659
    Rate: 12941
    Helpful post? Buy me a coffee.
  • #184 21522713
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14794
    Help: 659
    Rate: 12941
    Can anyone help with testing? I've integrated that second IR library into permutations build:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1608
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • BK7238 binary simplification and RF partition offset note

    #185 21523993
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    @p.kaczmarek2
    I think most permutations aren't needed. Tuyamcu and power metering can be merged back into default, since they aren't winning much in terms of ota size. Especially on T, where there is more than enough space since i disabled bluetooth.
    And i don't think we really need all of those binaries (QIO, UG, UA) that are not default, just having ota binaries are enough i think.

    BK7238 is 'broken', only berry binaries are available.

    In the future berry should be enabled on all realteks i think, except B (about 170kb is free now), since they have a lot of free space available, TR6260 (no ota - possibility of writing drivers without reflashing), ECR6600 (enough space), ESP with 4mb, and perhaps W600/W800 (never used them, so i don't know about their flash sizes/partitions).

    Also, is RF partition on beken have some recognizable header? Perhaps a function in gui flasher can be created, that would search for it in a dump and flash it to device at a required offset. I noticed that my HLK-B30 mac address was a default one, instead of the one it came with. I eventually found that a partition with TLV header was at 0x1fe000, instead of 0x1e1000 like on T.
  • Berry-enabled TuyaMCU binary and RF partition header idea

    #186 21524088
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14794
    Help: 659
    Rate: 12941
    insmod wrote:
    @p.kaczmarek2
    I think most permutations aren't needed. Tuyamcu and power metering can be merged back into default

    Well, let me ask you first, to make sure that we're on the same page - did you take in account that TuyaMCU and PowerMetering permutations are with Berry enabled, and default has no Berry?
    They also have charts and stuff enabled.
    The most crucial idea here is that we have a somewhat fixed channels system that is not flexible enough for TuyaMCU scripting. That's why I want to use Berry to parse TuyaMCU datapoints without worrying about adding channel types.
    The endgame here is a separate Berry-enabled binary for TuyaMCU with full Berry TuyaMCU guide on forum. This binary will benefit from stripping WS2812, IR, BL0942, BL0937, bl_shared.c etc.


    insmod wrote:

    BK7238 is 'broken', only berry binaries are available.

    Thank you for pointing that out, I will try to check it soon, however currently I'm adding XR806 to online builds, and then I need to do PIR driver for a user...


    insmod wrote:

    In the future berry should be enabled on all realteks i think, except B (about 170kb is free now), since they have a lot of free space available, TR6260 (no ota - possibility of writing drivers without reflashing), ECR6600 (enough space), ESP with 4mb, and perhaps W600/W800 (never used them, so i don't know about their flash sizes/partitions).

    This is also a good idea, thank! I will check this or just make a PR yourself and I will accept it. Just please take care, we already had broken OTA on BL602 once due to too high binary size. The current system is building permutations only for Beken, so no problem here. I don't want to end up with hundreds of jobs on Github.

    insmod wrote:

    Also, is RF partition on beken have some recognizable header? Perhaps a function in gui flasher can be created, that would search for it in a dump and flash it to device at a required offset.

    Well, TLV header for the start, and then, I don't know, but I know that MAC is at fixed offset in this section, because in the flasher, the "Restore RF partition" and "change MAC" just writes mac to fixed offset along with header. For more info, we would need to write script to check https://github.com/openshwprojects/FlashDumps/commits/main
    Screenshot of a configuration panel for reading and writing device flash memory with displayed data in hexadecimal format.

    insmod wrote:

    I noticed that my HLK-B30 mac address was a default one, instead of the one it came with. I eventually found that a partition with TLV header was at 0x1fe000, instead of 0x1e1000 like on T.

    Do we have source code for that partition read? We have a partition table in code, I remember. Could we modify it to search for RF partition in a list of predefined places so OBK works out of the box on various chip types?

    Added after 32 [seconds]:

    Actually, couldn't we write just a Github action for our repo here: https://github.com/openshwprojects/FlashDumps and use it to analyze all bins to get some nice stats data...
    Helpful post? Buy me a coffee.
  • #187 21524139
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    like a kind of byte pattern search?

    Screenshot of a Windows console showing a list of .bin files and TLV section offsets.
  • Check bins for Tuya config magic string

    #188 21524171
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14794
    Help: 659
    Rate: 12941
    As a search? Yes, that's what've been thinking about, but make sure you list all occurencies and not just first, just to be sure.

    Regarding Github actions -I've been thinking about much more. Maybe on each commit we could generate some statistics or information or just check for firmware versions/flavours/etc and create a report in HTML, etc. Still, it would not be actually that useful, so it's a very low priority idea.

    You can also check bins for Tuya config magic string.
    Helpful post? Buy me a coffee.
  • PowerShell script to scan bin files for TLV markers

    #189 21524326
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    just a little gpt thing for PS

    Code: Powershell
    Log in, to see the code


    Screenshot of a terminal window showing .bin file analysis results for various IoT devices.
  • ADVERTISEMENT
  • #190 21527585
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    the BK7238 asset links in the main table on release page are broken. big asset list below works.

    https://github.com/openshwprojects/OpenBK7231...eases/download/1.18.92/OpenBK7238_1.18.92.rbl
    https://github.com/openshwprojects/OpenBK7231...s/download/1.18.92/OpenBK7238_QIO_1.18.92.bin

    script checked all others in latest release and they work
  • #191 21527713
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14794
    Help: 659
    Rate: 12941
    Strange
    A screenshot of a file list with the text BK7238 highlighted.
    it was run as berry and not default, fixed
    Helpful post? Buy me a coffee.
  • #192 21542254
    apsis
    Level 6  
    Posts: 26
    Help: 2
    Rate: 4
    Hello,

    I am really sorry, but I went through all comments as I did receive NiceMCU board(s) and hit the CRC issue.

    Is there a bin (firmware) and flash tool I can use without requiring to compile stuff ?
  • #194 21542272
    apsis
    Level 6  
    Posts: 26
    Help: 2
    Rate: 4
    I am using BK7231GUIFlashTool-v19 which reports icName: P25Q16HBK

    on the shield board says:
    sparkle IoT
    MODEL XH-WB3S
  • ADVERTISEMENT
  • Helpful post

    BK7238 requires OpenBK7238_QIO firmware and slower UART

    #195 21542280
    DeDaMrAz
    Level 23  
    Posts: 621
    Help: 34
    Rate: 130
    WB3S module is based on BK7231T chip - so you should use the file named OpenBK7231T_UA_1.18.99.bin link here - https://github.com/openshwprojects/OpenBK7231...s/download/1.18.99/OpenBK7231T_UA_1.18.99.bin

    CORRECTION: XH-WB3S is BK7238 so file to be used is here - https://github.com/openshwprojects/OpenBK7231...s/download/1.18.99/OpenBK7238_QIO_1.18.99.bin

    If the problem persists lower your UART speed from 921k to something like 115200. Also share log form the GUI flasher.
  • #196 21542291
    apsis
    Level 6  
    Posts: 26
    Help: 2
    Rate: 4
    Tried all possible modes.
    including getting 7238 image, renaming it and flashing as 7231N
    Screenshot of BK7231 Easy UART Flasher software with a red Bad CRC! error and flashing operation logs.
    A set of electronic modules: a USB programmer, an ESP8266 board, a small ESP module, and two ICs in plastic bags.
  • #199 21542301
    DeDaMrAz
    Level 23  
    Posts: 621
    Help: 34
    Rate: 130
    Ok, stand-by, I will do the same on my side and try to figure out what is going on and report here shortly.

    Brand new module:

    Screenshot of a firmware flashing tool showing the message “Write success!”.

    Screenshot of a computer desktop with a sector scan window and a list of available Wi-Fi networks.

    Can't find anything unusual on the first go. Did you maybe tried to flash any other BIN file before?
  • #200 21542305
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    Did you check uart output?
    OpenBeken outputs log to UART1 by default. Connect adapter RX to P0 and see if it outputs anything.
    Also try to overwrite bootloader.
  • Bootloader output appears on P0 at 115200

    #201 21542320
    apsis
    Level 6  
    Posts: 26
    Help: 2
    Rate: 4
    Connected adapter RX to P0, opened putty on the COM port with baud rate 115200 - noting, attempted 921600 and 9600 with reboots after each - nothing.
    then tried with override bootloader flash, checked P0 again and got this

    BK7238_1.0.14
    REG:cpsr spsr r13 r14
    SVC:0x000000D3 0x00401C1C 0x000033A0
    IRQ:0x000000D2 0x00000010 0x00401E0C 0x2C008209
    FIR:0x000000D1 0x00000010 0x00401FFC 0x5501882C
    SYS:0x000000DF 0x0040192C 0x00000158
    ST:0x00000000
  • #202 21542329
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    Could try BKFIL to erase/write. Then maybe try Easy Flasher again to see if any different
  • #203 21542333
    apsis
    Level 6  
    Posts: 26
    Help: 2
    Rate: 4
    Hmm, attempted same on the soldered module /that I never flashed/ and seemed to work....

    Then tried to write the backup on the other chip (with other programmer) - got same issue (CRC) with same settings - ODD

    Likely some of the previous flash attempts bricked the board?

    Seems I placed power on p17 and p16 instead of VCC and GND - FACEPALM
  • #204 21542621
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    apsis wrote:
    Seems I placed power on p17 and p16 instead of VCC and GND - FACEPALM


    😁 did it survive?
  • #205 21543100
    apsis
    Level 6  
    Posts: 26
    Help: 2
    Rate: 4
    >>21542621 for some time, eventually it did die fully... anyhow flashed rest with no issues
  • #206 21549891
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    >>21511229

    still up with new SDK

    Screenshot of the OpenBK7231T device control panel showing status, measurements, and configuration details.
  • #207 21549984
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14794
    Help: 659
    Rate: 12941
    The best stability test is MQTT.
    Helpful post? Buy me a coffee.
  • #208 21550043
    Ogurezzz
    Level 5  
    Posts: 10
    Rate: 2
    Flash done. But no AP appears.
    What should I do?
    Window of a microcontroller flashing program with the „Write success!” message and detailed memory write log.
  • #209 21550104
    divadiow
    Level 38  
    Posts: 5236
    Help: 449
    Rate: 918
    >>21550043

    what device have you flashed and do you get any log output from uart2 - P0 @ 115200 baud?
  • BK7238 UART2 log stuck in init loop

    #210 21550649
    Ogurezzz
    Level 5  
    Posts: 10
    Rate: 2
    >>21550104

    Sparcle IoT XH-WB3S V2.0

    uart2 output: https://pastebin.com/ZwDdthbx
    
    bk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHea0bk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHea0bk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHea0bk_misc_init_start_type 0 0
    prvHea0bk_misc_init_start_type 0 0
    prvHea0bk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    prvHea0bk_misc_init_start_type 0 0
    prvHea0bk_misc_init_start_type 0 0
    prvHeabk_misc_init_start_type 0 0
    
    

    Sparkle IoT XH-WB3S V2.0 module held in hand, with colorful wires connected.

Topic summary

LABEL_AI_GENERATED
Discussion centers on NiceMCU XH-WB3S dev boards/modules, initially suspected to be BK7231T but confirmed to use BK7238. Participants identify flash IDs, per-chip encryption keys, and note that OTA flashing is blocked for unencrypted images, while BKFIL and factory restore methods can still recover devices. The thread evolves into porting OpenBeken/OpenBK7231T to the BK7238/new Beken SDK, including Arduino-based builds, makefile/HAL adjustments, flashvars alignment fixes, timing/delay_us implementation, HTTP/TCP server stability fixes, UART logging routing, power-save handling, and sensor support such as DHT11 and DS18B20. Later posts cover BK7231N/BK7231U compatibility, bootloader behavior, flash chip detection, and flashing tool fixes for unsupported flash MID values.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT