Elektroda.com
Elektroda.com
X

[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

p.kaczmarek2 89274 1198
This content has been translated flag-pl » flag-en View the original version here.
  • #61
    p.kaczmarek2
    Moderator Smart Home
    boozeman wrote:

    Successfull write for OpenBK7231T-20220203fx-956kb\OpenBK7231T_App_UA_1.0.0.bin

    Good job, can you tell us how did you solve the flash write problem? New UART converter helped or something else?

    boozeman wrote:

    Well, I can't see any wifi network to connect with my phone. I will continue to debug :)

    No WiFi, even after restarting module several times?

    boozeman wrote:

    Do you have Kicad Symbols for WB2S and WB3S already?

    I am using Eagle and I draw WB2S by hand, but in a hindsight, it would certainly make sense to create Eagle library for it.

    boozeman wrote:

    I can try to reverse schematic for Nedis device. Not the high voltage section but normal what pin goes where BL0937 etc.

    If you want, of course it might be helpful.



    Great news - I got next Beken chip module. That one supposedly supports Bluetooth as well. I will try flashing it soon:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #62
    boozeman
    Level 11  
    p.kaczmarek2 wrote:

    Good job, can you tell us how did you solve the flash write problem? New UART converter helped or something else?


    It fails 8/10 but some patient trying I got successfull write with Beken Writer and also with python method.

    p.kaczmarek2 wrote:

    No WiFi, even after restarting module several times?


    Yep, no wifi.

    After flashing with OpenBK7231T_App_UA_1.0.0.bin got this in second uart

    
    [20:18:08.795] 
    V:BK7231S_1.0.5
    CPSR:000000D3
    R0:AFEB93F9
    R1:F6C67B29
    R2:FF7E7AF7
    R3:72EE2B75
    R4:97BBF3D6
    R13:956DBF7F
    R14(LR):F5D9FF3D
    ST:22CEA70E
    J 0x10000
    [20:18:08.895] prvHeapInit-start addr:0x41c790, size:145520
    init log
    

    The chip seems to be BK7231S
  • #63
    kuba2k2
    Level 12  
    p.kaczmarek2 wrote:
    That one supposedly supports Bluetooth as well.

    WB2L supports bluetooth. BK7231T supports it. So probably your WB2S etc. also does. The datasheet also says it supports BT, and I can confirm as the default tuya example shows up as "TY" on my phone.

    boozeman wrote:
    The chip seems to be BK7231S

    The bootloader in BK7231T also shows this symbol, so you probably don't have S.
  • #64
    esanford
    Level 1  
    I have some Martin Jerry SS01 smart switches with WB2S, I'd love for them to be included in your upcoming firmware!

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [img-4] [img-5] [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #65
    p.kaczmarek2
    Moderator Smart Home
    @esanford , thank you for the photos, it looks like your device is already supported, you just have to select proper pin as relay and button in the Configurator. Just like in Tasmota.

    @boozeman here is the log output that I get (up to the MQTT connection success) on WB2S device:
    
    V:BK7231S_1.0.5
    CPSR:000000D3
    R0:E76F0DEF
    R1:AD3E49E8
    R2:7EFFBF7C
    R3:5371FCF4
    R4:DF443E15
    R13:2BF7D327
    R14(LR):B8FF6FF7
    ST:4CF25514
    J 0x10000
    
    prvHeapInit-start addr:0x41c790, size:145520
    init log
    [bk]tx_txdesc_flush
    [rx_iq]rx_amp_err_rd: 0x013
    [rx_iq]rx_phase_err_rd: 0x1ff
    [rx_iq]rx_ty2_rd: 0x095
    *********** finally result **********
    gtx_dcorMod            : 0x8
    gtx_dcorPA             : 0xa
    gtx_pre_gain           : 0x0
    gtx_i_dc_comp          : 0x1fd
    gtx_q_dc_comp          : 0x20d
    gtx_i_gain_comp        : 0x3ee
    gtx_q_gain_comp        : 0x3ff
    gtx_ifilter_corner over: 0x11
    gtx_qfilter_corner over: 0x11
    gtx_phase_comp         : 0x20e
    gtx_phase_ty2          : 0x200
    gbias_after_cal        : 0x14
    gav_tssi               : 0x21
    g_rx_dc_gain_tab 0 over: 0x80788078
    g_rx_dc_gain_tab 1 over: 0x80788078
    g_rx_dc_gain_tab 2 over: 0x84788478
    g_rx_dc_gain_tab 3 over: 0x94708c70
    g_rx_dc_gain_tab 4 over: 0x946e946e
    g_rx_dc_gain_tab 5 over: 0x936e926e
    g_rx_dc_gain_tab 6 over: 0x9470936e
    g_rx_dc_gain_tab 7 over: 0x91709270
    grx_amp_err_wr         : 0x23f
    grx_phase_err_wr       : 0x124
    **************************************
    ble use fit!
    temp in flash is:250
    lpf_i & q in flash is:17, 17
    xtal in flash is:21
    -----pwr_gain:12, g_idx:12, shift_b:0, shift_g:0
    -----[pwr_gain]12
    Initializing TCP/IP stack
    Using SSID [MY_SSID_IN_PLAINTEXT]
    
    Using Pass [MY_PASS_IN_PLAINTEXT]
    [bk]tx_txdesc_flush
    bssid 48-ee-0c-48-93-12
    security2cipher 2 3 24 8 security=6
    cipher2security 2 3 24 8
    enter low level!
    mac d4:a6:51:30:36:8a
    leave low level!
    do td cur_t:224--last:idx:13,t:250 -- new:idx:11,t:226 
    --0xc:08, shift_b:-1, shift_g:-1, X:0
    
    wl_status 3
    ssid:MY_SSID_IN_PLAINTEXT, 1
    ht in scan
    scan_start_req_handler
    Channel has changed! Publishing change 1 with 100 
    
    26 key_short_press
    
    SM_DISCONNECTING status=1
    Timer discovetrs disconnected mqtt 0
    Timer is 1 free mem 112016
    Timer discovetrs disconnected mqtt 1
    Timer is 2 free mem 112016
    Timer discovetrs disconnected mqtt 2
    Timer is 3 free mem 112016
    Timer discovetrs disconnected mqtt 3
    Timer is 4 free mem 112016
    Timer discovetrs disconnected mqtt 4
    Timer is 5 free mem 112016
    Timer discovetrs disconnected mqtt 5
    Timer is 6 free mem 112016
    Timer discovetrs disconnected mqtt 6
    Timer is 7 free mem 112016
    Timer discovetrs disconnected mqtt 7
    Timer is 8 free mem 112016
    Timer discovetrs disconnected mqtt 8
    Timer is 9 free mem 112016
    
    sta: 0, softap: 0, b/g/n
    Timer discovetrs disconnected mqtt 9
    
    Timer is 10 free mem 112016
    
    dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=d4:a6:51:30:36:8a 
    
    wl_status 9
    ht in scan
    scan_start_req_handler
    Timer discovetrs disconnected mqtt 10
    
    Timer is 11 free mem 111344
    
    do td cur_t:234--last:idx:11,t:226 -- new:idx:12,t:238 
    --0xc:08, shift_b:-1, shift_g:-1, X:0
    Timer discovetrs disconnected mqtt 0
    
    Timer is 12 free mem 110904
    
    wl_status 3
    ssid:MY_SSID_IN_PLAINTEXT, 1
    found scan rst rssi -46 > -50
    ht in scan
    scan_start_req_handler
    me_set_ps_disable:840 0 0 0 374465 534940
    sm_auth_send:1
    sm_auth_handler
    ht in assoc req
    sm_assoc_rsp_handler
    rc_init: station_id=0 format_mod=0 pre_type=2 short_gi=383193 max_bw=535451
    rc_init: nss_max=0 mcs_max=0 r_idx_min=7 r_idx_max=383235 no_samples=535518
    __l2_packet_send: ret 0
    
    new ie: 0 : 44 4c 49 4e 4b 5f 46 61 73 74 4e 65 74 
    new ie: 1 : 82 84 8b 96 c 12 18 24 
    new ie: 3 : 8 
    new ie: 30 : 1 0 0 f ac 4 1 0 0 f ac 4 1 0 0 f ac 2 0 0 
    new ie: 2d : ef 11 1b ff ff 0 0 0 0 0 0 0 0 0 0 80 0 0 0 0 0 0 0 0 0 0 
    
    __l2_packet_send: ret 0
    sta_mgmt_add_key
    ctrl_port_hdl:1
    me_set_ps_disable:840 0 0 0 374465 534940
    wl_status 10
    
    configuring interface mlan (with DHCP client)wl_status 11
    Timer discovetrs disconnected mqtt 1
    Timer is 13 free mem 111320
    Timer discovetrs disconnected mqtt 2
    Timer is 14 free mem 111360
    Timer discovetrs disconnected mqtt 3
    Timer is 15 free mem 111360
    Timer discovetrs disconnected mqtt 4
    Timer is 16 free mem 111360
    Timer discovetrs disconnected mqtt 5
    Timer is 17 free mem 111384
    Timer discovetrs disconnected mqtt 6
    Timer is 18 free mem 111384
    Timer discovetrs disconnected mqtt 7
    Timer is 19 free mem 111384
    
    sta: 1, softap: 0, b/g/n
    sta:rssi=-50,ssid=MY_SSID_IN_PLAINTEXT,bssid=30:b5:c2:5d:70:72 ,channel=8,cipher_type:MIXED
    do td cur_t:246--last:idx:12,t:238 -- new:idx:13,t:250 
    --0xc:08, shift_b:-1, shift_g:-1, X:0
    Timer discovetrs disconnected mqtt 8
    
    Timer is 20 free mem 111384
    
    dhcp=0 ip=192.168.0.115 gate=192.168.0.1 mask=255.255.255.0 mac=d4:a6:51:30:36:8a 
    
    Timer discovetrs disconnected mqtt 9
    Timer is 21 free mem 111384
    Timer discovetrs disconnected mqtt 10
    Timer is 22 free mem 111384
    mqtt_connection_cb: Successfully connected
    
    MQTT client "192.168.0.113" request cb: err 0
    
    Timer is 23 free mem 111352
    Timer is 24 free mem 111352
    Timer is 25 free mem 111352
    Timer is 26 free mem 111352
    Timer is 27 free mem 111384
    Timer is 28 free mem 111352
    



    Ok ok, I did prelimary tests with CB2S but so far I haven't managed to write to it.
    CB2S is BK7231N and not BK7231T.
    1. I can read its contest in BK7231 mode in Beken Writer. Can anyone decrypt it?
    CB2S_dump_...220204.zip Download (1.97 MB)
    2. When trying to flash in BK7231 mode , it's seemingly erasing and writing to it successfully, but then it fails at verify:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    the most interesting thing is that the relay continues to work like before after this process (button works etc), which suggests that it didn't write anything to flash at all, but I need to check this more
    3. when trying to flash in BK7231N mode, it fails at "deprotecting the flash"
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    I didn't have the time to connect debug UART as well, I also haven't tested SPI so far.
  • #66
    boozeman
    Level 11  
    Hi,

    Patient dies while experimental surgery. I surely bricked my first module with UartDownloader. I was used that -s 0x00000 just for fun! > CRC failed and it's dead now :-)

    I will buy another Nedis today and continue my "experiments"

    Edit:

    Some observations about Nedis Device:

    - Flashing when module is onboard is not possible. All leds blinked and relay switched on and off. (stabile 3.3v source with external vdc line)
    - Plain module can be flashed successfully with Beken Writer or UartDownloader.
    - Sadly no Wifi after flashing. Second uart shows beginning of the init message, then no further activity. 2 of 2 modules acting like this
    - Wifiscan firmware works with modules. Second UART shows scan results
  • #67
    kuba2k2
    Level 12  
    p.kaczmarek2 wrote:
    CB2S is BK7231N and not BK7231T

    I'd say that you need another firmware, compiled with another SDK, as they are mostly CPU-specific. Bdk_freertos has support for the N, and as I tried before, that version does not boot on the T, even after changing the loading address.
  • #68
    marioalmeida
    Level 10  
    MrTechGadget wrote:
    That’s what I was afraid of, I only see a Windows binary, not Linux or OSX, so I’ll have to dig out a Windows device. If there is another option I’d love to try it.


    I was able to backup and update from arch linux
  • #69
    p.kaczmarek2
    Moderator Smart Home
    p.kaczmarek2 wrote:
    CB2S is BK7231N and not BK7231T

    kuba2k2 wrote:
    Bdk_freertos has support for the N, and as I tried before, that version does not boot on the T, even after changing the loading address.


    https://github.com/tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231n

    It seems there is another SDK for bk7231n which looks very similiar to the one for bk7231t which I used to start OpenBK7231T project.
    It should be very easy to integrate them both into my Beken-Tasmota replacement, especially considering that I already taken a multi-platform approach.
  • #70
    asomkin
    Level 1  
    I have some TUYA RGBWWCW Downlight running on BK7231T on different module.

    It's quite popular on AliExpress item/4001156825209.html
    I think it is the same as Moes 7W RGBCCT Downlight (WB-D7-RCW-1).

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #71
    zopieux
    Level 2  
    Hi folks,

    I got a bunch of no-name Tuya-compatible WiFi switches, which come with external switch sensing (so you can wire a physical switch and react to it). It's exciting to see that a small community has gathered around freeing these devices from crappy cloud providers! Thanks for all the work done so far.

    These switches feature the BK7231N (not T) as well, sadly. Here are some detailed pictures with references:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Datasheet for BP2525X: (redacted because I "don't have enough points" to include links, wtf)

    The 1117 33 JMA9 is an LDO. Is M7 an LDO as well? OP says "connect 5V before LDO" and on the picture it seems it's on one of the M7 pads. But M7 seems to be 230V as it then goes to BP2525X's drain with according to datasheet is the high voltage 230V "drain".

    As you can see there seems to have test pads on the back of the blue PCB, but to reach them I'd need to unsolder either the blue PCB or the small green square-angle "transport" PCB.

    The main blue PCB also features pins "pwm0" to "pwm5", 3.3V, GND, RX1, TX1, ADC3.

    All in all it looks very similar to the one from OP.

    Where do you think I should wire 5V (or maybe direct 3.3V?) and ground here to start toying? OP says "before the LDO", does that still apply to this circuit?

    I'm very new to electronics so any advice would be appreciated on how to proceed to at least get some console out, then I'll attempt compiling and flashing using the official tuya SDK from GitHub. I already have a TTL-USB with RX, TX and Ground, will need to order another one for programming though.

    Thanks!
  • #72
    boozeman
    Level 11  
    One more off the docket

    I was running some tests, here's the result

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    With wifi_scan_1.0.0_UA.bin I got results on uart2 -> works as planned


    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    With app_name_1.0.0_UA.bin I got also results on uart2 -> works as planned

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    With openbk7231app_UA_1.0.0.bin Tested with 3 different versions of this bin and I even compiled my own. No victory yet.
  • #73
    kuba2k2
    Level 12  
    boozeman wrote:
    With openbk7231app_UA_1.0.0.bin Tested with 3 different versions of this bin and I even compiled my own. No victory yet.

    Is the other UART sending info? I've seen somewhere in the SDK that it's theoretically possible to choose UART1 for logging.

    If not, try to find the line that prints "init log", and see what happens there and what may be the problem. Adding your own debugging lines in various places might help reveal the exact spot where it hangs.
  • #74
    btsimonh
    Level 11  
    Calex power strip from Tesco in the UK. Currently on offer at £7.50, reduced from £30.... :).

    Now running Openbk7231app.

    Challenges:
    The unit had never seen my wifi. I dumped the flash using
    python uartprogram -r -s 11000 lead-11000-1ef000.bin -d com4 -l 1ef000
    and then flashed it.
    At first, it died in starting MQTT. Once i'd commented that out, it did not want to start AP mode on the wifi.
    In the end, I solved it by delaying the AP mode start by 5 seconds. I'm pretty sure that 'role_launch' would do all of this for us, including main and backup SSSIDs.

    Anyway, proposed mods on the way, which include one bugfix....
    We will need a little more finesse in the config (like a 'wifi status' LED type, and what to do with that single button - currently controls relay 1)

    Pictures below :).
    br, Simon

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #75
    gladkib
    Level 1  
    I found WBLC5 with BK7231T in Hama light bulb, Item No.: 00176583.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #76
    boozeman
    Level 11  
    kuba2k2 wrote:

    Is the other UART sending info? I've seen somewhere in the SDK that it's theoretically possible to choose UART1 for logging.


    My setup:

    COM14 programmer tx0 and rx0
    COM10 listener at tx1 and rx2

    All reasonable messages comes to COM10.

    COM14 gives only time when resetting
    [18:11:34.346] 


    kuba2k2 wrote:

    If not, try to find the line that prints "init log", and see what happens there and what may be the problem. Adding your own debugging lines in various places might help reveal the exact spot where it hangs.


    OK, thanks. Eventually we will bend this device to work too :)

    
    Get-ChildItem -Recurse | Select-String "init log" -List | Select Path
    
    Path
    ----
    xxx\bk7231sdk\apps\openbk7231app\src\logging\logging.c
    xxx\bk7231sdk\apps\openbk7231app\src\logging\logging.o
    xxx\bk7231sdk\platforms\bk7231t\bk7231t_os\Debug\obj\logging.o
  • #77
    kuba2k2
    Level 12  
    Though if the files compiled with my SDK work, there has to be a problem with OpenBK7231T. They are based on the same code, so something is clearly not OK. Could you try compiling OpenBK7231T_App with the cmake SDK? I don't think it would make a difference, but you could at least eliminate one possibility.
  • #78
    p.kaczmarek2
    Moderator Smart Home
    Thanks for the replies and special thanks to anonymous donor who's sending me Biedronka Light Bulb!
    It's time for more good news.

    zopieux wrote:

    These switches feature the BK7231N (not T) as well, sadly

    Luckily there was also SDK for the BK7231N (not T) and I started fixing it and porting our firmware to it:
    https://github.com/openshwprojects/OpenBK7231N
    Right now, our App compiles well on both platforms:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Platforms are similiar with some minor changes, more functions arguments for PWM, some header files moved (some typos fixed as well - tuya_hal_storge.h, really?), etc.

    I introduced some #defines, for BK7231N it's PLATFORM_BK7231N and for BK7231T it's PLATFORM_BK7231T. They are set in application.mk:
    
    
    # Compile options
    # -------------------------------------------------------------------
    CFLAGS =
    CFLAGS += -g -mthumb -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -fsigned-char -fdata-sections -Wunknown-pragmas -nostdlib -Wno-unused-function -Wno-unused-but-set-variable
    
    CFLAGS += -DPLATFORM_BK7231N=1
    
    OSFLAGS =
    OSFLAGS += -g -marm -mcpu=arm968e-s -march=armv5te -mthumb-interwork -mlittle-endian -Os -std=c99 -ffunction-sections -Wall -fsigned-char -fdata-sections -Wunknown-pragmas
    


    I hadn't time to test more flashing on BK7231N platform but the compilation certainly works right now.

    zopieux wrote:

    Where do you think I should wire 5V (or maybe direct 3.3V?) and ground here to start toying? OP says "before the LDO", does that still apply to this circuit?

    Of course, you connect 5V to the input pin of low dropout regulator, 1117 or a simiiliar one, to get a 3.3V on the output for Beken chip...
  • #79
    pepesuriano
    Level 9  
    @btsimonh @p.kaczmarek2 thank you both for the clarifications!! I think I get it much more clearer now. Just one more question before giving it my first try, I see that it is mentioned to use a trusted usb uart converter, what does exactly mean? I have a cheapo PL2303 which I use for most UART things and works fine, it has 5v, 3v3, GND, TX and RX pins, it's not a good idea to use it for flashing? I have a bus pirate or an arduino laying around also if it's something that I can use.

    Thanks again
  • #80
    boozeman
    Level 11  
    pepesuriano wrote:
    I have a cheapo PL2303 which I use for most UART things and works fine, it has 5v, 3v3, GND, TX and RX pins, it's not a good idea to use it for flashing? I have a bus pirate or an arduino laying around also if it's something that I can use.

    Thanks again


    Hi, if you use Beken Writer for writing, you have to use 921600 bps settings. I just checked that PL2303 can do as high as 12000000bps so I think that your adapter works just fine :)
  • #81
    tjclement
    Level 2  
    Hi all, for those interested in running custom firmware on devices that can't be opened without breaking them: a buddy and I have made a wireless jailbreak for BK7231-based devices from Tuya that has so far worked on all devices (lights) we tried it on. It makes use of a bug that is currently in Tuya's SDK and has been since 2019.

    We'll be able to publish it after coordinated disclosure with Tuya. More info (I'm not allowed to post links yet on here): twitter dot com /Tom_Clement/status/1490796204862627853



    PS: to those who were interested in looking at the bootloader but couldn't get it dumped (it's protected against dumping via the bootloader's own UART protocol, but still possible), you can also find a copy in the SDK -> github dot com /tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t/blob/master/platforms/bk7231t/bk7231t_os/tools/generate/bootloader.bin
  • #82
    ferbulous
    Level 15  
    tjclement wrote:
    Hi all, for those interested in running custom firmware on devices that can't be opened without breaking them: a buddy and I have made a wireless jailbreak for BK7231-based devices from Tuya that has so far worked on all devices (lights) we tried it on. It makes use of a bug that is currently in Tuya's SDK and has been since 2019.

    We'll be able to publish it after coordinated disclosure with Tuya. More info (I'm not allowed to post links yet on here): twitter dot com /Tom_Clement/status/1490796204862627853



    PS: to those who were interested in looking at the bootloader but couldn't get it dumped (it's protected against dumping via the bootloader's own UART protocol, but still possible), you can also find a copy in the SDK -> github dot com /tuya/tuya-iotos-embeded-sdk-wifi-ble-bk7231t/blob/master/platforms/bk7231t/bk7231t_os/tools/generate/bootloader.bin


    Nice, looking forward to this
    I have some led bulbs that's sealed with silicone inside which makes it hard to connect the right pins
  • #83
    p.kaczmarek2
    Moderator Smart Home
    @tjclement , great job! I hope you will soon release it in some kind of easily accessible form! It's crucial for our community to be able to remotely flash Beken devices.
  • #84
    schrad
    Level 2  
    asomkin wrote:
    I have some TUYA RGBWWCW Downlight running on BK7231T on different module.
    It's quite popular on AliExpress item/4001156825209.html
    I think it is the same as Moes 7W RGBCCT Downlight (WB-D7-RCW-1).


    I got the same module. I managed to read out a backup with beken writer successfully.
    Afterwards i try to program the new firmware - also with beken writer.

    Unfortunately it didn't work properly.
    I flash following firmwares:
    - app_name_1.0.0_UA
    - wifi_scan_1.0.0_UA
    - OpenBK7231T-20220203fx-956kb (App_UA)

    In BKwriter everything looks fine.

    But when I start the module afterwards it fails.

    Attached you find the outputs of TX2.
    App_name (pic1) and wifi_scan (pic2) restart again and again...
    OpenBK stops at this point.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #85
    kuba2k2
    Level 12  
    schrad wrote:
    App_name (pic1) and wifi_scan (pic2) restart again and again...

    I was getting the same results when trying bdk_freertos (which is for BK7231N/U) on BK7231T. Are you sure your module is the T version?
  • #86
    schrad
    Level 2  
    kuba2k2 wrote:
    schrad wrote:
    App_name (pic1) and wifi_scan (pic2) restart again and again...

    I was getting the same results when trying bdk_freertos (which is for BK7231N/U) on BK7231T. Are you sure your module is the T version?


    Yeah, I am Sure :-)
    I have a BK7231TQN32.

    I find more infos about these but i only understand ~50%
    Link
  • #87
    boozeman
    Level 11  
    schrad wrote:
    In BKwriter everything looks fine.

    But when I start the module afterwards it fails.

    Attached you find the outputs of TX2.
    App_name (pic1) and wifi_scan (pic2) restart again and again...
    OpenBK stops at this point.


    I will join your guild! :)

    I tried 3 different plugs with WB2s. Only working bin for me is that wifi_scan. The up to date Git repositories are my Debian 11 machine with installed build-essential and libc6-i386 (build_app.sh fails without those). There is no errors only for warnings when compiling the bin files.

    I flashed the last one while the WB2S card is on the plug. I just desolder the VCC from the main board, so the usb-serial converter supply only the module.

    I tried to look howto compile OpenBK7231T with cmake like wifi_scan, but my coding skills in c language are pretty non-existent. So for now I let it be and maybe open one of the module's RF-shield to check what chip there are hiding. Edit: It was BK7231TQN32
  • #88
    ExploWare
    Level 10  
    I am very happy with your work!
    I have flashed several WB2S modules, reported my progress on the github cloned in /ExploWare/OpenBK7231T/

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    I have found one issue though:
    I am using the image on the Releases folder, and that seems to have a hardcoded identifier for the MQTT topic
    They all are using the "obk708976F8/0/"
    I hoped this would be determined by the MAC or adjustable by the MQTT settings page, but its not changing yet with anything I try.

    Any clue?
    Cheers for the great job so far!
  • #89
    p.kaczmarek2
    Moderator Smart Home
    How are your devices seen by the DHCP on the router? What are their MAC addresses?

    There was indeed a small bug in MQTT settings where default device name was hardcoded to "test" instead of using one determined by MAC, but it seems you have different issue.

    Or... I think I know what might be wrong. This is how identifier (like obk708976F8) is generated from MAC:
    Code: c
    Log in, to see the code

    Currently only four bytes of MAC are used, maybe it would make more sense to use the latter bytes or somehow run a hash function over them. Can devices from one batch have the same first 4 bytes of MAC?

    I will try to fix your issue right away and do a new release.
  • #90
    kuba2k2
    Level 12  
    All MAC addresses' first 3 bytes correspond to the manufacturer. In this case, all modules will have 70:89:76 as it means "Tuya Smart Inc.". The last 3 bytes should be unique for this manufacturer.

    EDIT:
    All Tuya Smart Inc's MAC address prefixes:
    https://maclookup.app/vendors/tuya-smart-inc