Elektroda.com
Elektroda.com
X
Elektroda.com

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

p.kaczmarek2 65427 1072
This content has been translated flag-pl » flag-en View the original version here.
  • p.kaczmarek2
    Level 28  
    You can try hot air with the right amount of flux, you can also try to add ordinary lead binder, but I don't know how much space there is and what module it is.

    Or provide more complete logs instead of downloading the screen.

    This is what the log from BK7231 looks like, do you get such a log in the UART?
    Code:


           
    V:BK7231S_1.0.5

    CPSR:000000D3

    R0:E56F05AF

    R1:AC3E48E8

    R2:6A7FBF7C

    R3:5333FCE4

    R4:CB643E15

    R13:ABF7DBA7

    R14(LR):B8FE67F7

    ST:6CF21514

    J 0x10000

    prvHeapInit-start addr:0x41f4a0, size:133984
    [01-01 18:12:15 TUYA Info][mqc_app.c:175] mqc app init ...
    [01-01 18:12:15 TUYA Info][sf_mqc_cb.c:42] register mqc app callback
    [01-01 18:12:15 TUYA Debug][mqc_app.c:118] mq_pro:5 mqc_handler_cnt:1
    [01-01 18:12:15 TUYA Debug][mqc_app.c:118] mq_pro:31 mqc_handler_cnt:2
    [01-01 18:12:15 TUYA Debug][uni_thread.c:215] Thread:sys_timer Exec Start. Set to Running Status
    [01-01 18:12:15 TUYA Debug][log_seq.c:732] read from uf. max:0 first:0 last:0
    [01-01 18:12:15 TUYA Debug][svc_online_log.c:288] svc online log init success
    [01-01 18:12:15 TUYA Err][tuya_ws_db.c:314] kvs_read fails gw_bi -1
    [01-01 18:12:15 TUYA Err][ws_db_gw.c:111] gw base read fails -935
    [01-01 18:12:15 TUYA Debug][tuya_bt_sdk.c:89] ty bt cmmod register finish 1
    [01-01 18:12:15 TUYA Debug][tuya_ble_api.c:301] ble sdk inited
    !!!!!!!!!!tuya_bt_port_init
    [01-01 18:12:15 TUYA Debug][tuya_ble_api.c:337] ble sdk re_inited
    [01-01 18:12:15 TUYA Notice][tuya_bt_sdk.c:130] ty bt sdk init success finish
    [01-01 18:12:15 TUYA Debug][tuya_device.c:259] < TUYA IOT SDK V:1.0.2 BS:40.00_PT:2.2_LAN:3.3_CAD:1.0.2_CD:1.0.0 >
    < BUILD AT:2020_09_25_17_24_52 BY embed FOR ty_iot_wf_bt_sdk_bk AT bk7231t >
    IOT DEFS < WIFI_GW:1 DEBUG:1 KV_FILE:0 SHUTDOWN_MODE:0 LITTL[01-01 18:12:15 TUYA Debug][tuya_device.c:260] template_demo:1.0.0
    [01-01 18:12:15 TUYA Notice][tuya_device.c:261] firmware compiled at Sep 27 2021 07:47:11
    [01-01 18:12:15 TUYA Notice][tuya_device.c:262] Hello, is this really working? Let's compile and check!
    bk_rst:0 tuya_rst:0[01-01 18:12:15 TUYA Notice][tuya_device.c:263] system reset reason:[(null)]
    [01-01 18:12:15 TUYA Debug][tuya_ws_db.c:438] init fs. Path: (null)
    [01-01 18:12:15 TUYA Notice][simple_flash.c:432] key_addr: 0x1ee000   block_sz 4096
    [01-01 18:12:15 TUYA Notice][simple_flash.c:500] get key:
    0xcb 0x4e 0x3e 0xa4 0x0 0x30 0x9d 0xab 0x65 0x6d 0x8d 0xbf 0xe4 0xb9 0x3f 0x35
    [01-01 18:12:15 TUYA Notice][tuya_main.c:311] **********[template_demo] [1.0.0] compiled at Sep 27 2021 07:47:10**********
    [01-01 18:12:15 TUYA Debug][uni_thread[bk]tx_txdesc_flush
    .c:215] Thread:cmmod Exec Start. Set to Running Status
    [rx_iq]rx_amp_err_rd: 0x042
    [rx_iq]rx_phase_err_rd: 0xfffffe01
    [rx_iq]rx_ty2_rd: 0x095
    *********** finally result **********
    gtx_dcorMod            : 0x8
    gtx_dcorPA             : 0xa
    gtx_pre_gain           : 0x0
    gtx_i_dc_comp          : 0x1fe
    gtx_q_dc_comp          : 0x20d
    gtx_i_gain_comp        : 0x3f4
    gtx_q_gain_comp        : 0x3ff
    gtx_ifilter_corner over: 0x11
    gtx_qfilter_corner over: 0x11
    gtx_phase_comp         : 0x20f
    gtx_phase_ty2          : 0x200
    gbias_after_cal        : 0x16
    gav_tssi               : 0x22
    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: 0x94708c74
    g_rx_dc_gain_tab 4 over: 0x94729472
    g_rx_dc_gain_tab 5 over: 0x92709272
    g_rx_dc_gain_tab 6 over: 0x93709270
    g_rx_dc_gain_tab 7 over: 0x94719371
    grx_amp_err_wr         : 0x226
    grx_phase_err_wr       : 0x2dc
    **************************************
    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
    [01-01 18:12:15 TUYA Notice][tuya_main.c:337] have actived over 15 min, not enter mf_init
    [01-01 18:12:15 TUYA Notice][tuya_main.c:341] mf_init succ
    [01-01 18:12:15 TUYA Debug][tuya_main.c:347] gwcm_mode 3


    Or at least this headline:

    V:BK7231S_1.0.5

    And for example, the XR809 log looks like this:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    And this is the BL602 log:
    Code:


    Starting bl602 now....
    Booting BL602 Chip...
    ██████╗ ██╗      ██████╗  █████╗ ∈█████╗

    ██╔══██╗██║     ██╔════╝ ██╔═████╗╚════██╗

    ██████╔╝██║     ███████╗ ██║██╔██║ █████╔╝

    ██╔══██╗██║     ██╔═══██╗████╔╝██║██╔═══╝

    ██████╔╝███████╗╚██████╔╝╚██████╔╝███████╗

    ╚═════╝ ╚══════╝ ╚═════╝  ╚═════╝ ╚══════╝



    -----------------------------------------------------------
    RISC-V Core Feature:RV32-ACFIMX
    Build Version: release_bl_iot_sdk_1.5.12-5-g6a078b47-dirty
    PHY   Version: a0_final-12-ge8d1d24
    RF    Version: 89d5eb1
    Build Date: Oct 24 2020
    Build Time: 10:50:50
    ------------------------------------------------------------
    Heap 111102@0x42024602, 3632@0x420491d0

    blog init set power on level 2, 2, 2.
    [IRQ] Clearing and Disable all the pending IRQ...
    [         0][INFO  : bl_sec.c:  88] Feed random number is 00000000
    [         0][INFO  : bl_sec.c:  88] Feed random number is 00000000
    ------------------TRNG TEST---------------------------------
    **********TRNG TEST rand[34d073ef]**************
    **********TRNG TEST rand[3e9c8f42]**************
    ------------------------------------------------------------
    [         0][INFO  : hal_boot2.c: 276] [HAL] [BOOT2] Active Partition[0] consumed 596 Bytes
    ======= PtTable_Config @0x4200df90=======
    magicCode 0x54504642; version 0x0000; entryCnt 7; age 0; crc32 0x12DF9A26
    idx  type device activeIndex     name   Address[0]  Address[1]  Length[0]   Length[1]   age
    [00]  00     0         0            FW  0x00010000  0x000d8000  0x000c8000  0x000b7000  0
    [01]  01     0         0           mfg  0x00180000  0x00000000  0x00010000  0x00000000  0
    [02]  02     0         0         media  0x00190000  0x00000000  0x00001000  0x00000000  0
    [03]  03     0         0           PSM  0x001e9000  0x00000000  0x00008000  0x00000000  0
    [04]  04     0         0           KEY  0x001f1000  0x00000000  0x00002000  0x00000000  0
    [05]  05     0         0          DATA  0x001f3000  0x00000000  0x00005000  0x00000000  0
    [06]  06     0         0       factory  0x001f8000  0x00000000  0x00008000  0x00000000  0
    [         0][INFO  : bl_flash.c:  96] ======= FlashCfg magiccode @0x42049c18, code 0x47464346 =======
    [         0][INFO  : bl_flash.c:  97] mid       0xEF
    [         0][INFO  : bl_flash.c:  98] clkDelay    0x1
    [         0][INFO  : bl_flash.c:  99] clkInvert    0x1
    [         0][INFO  : bl_flash.c: 100] sector size   4KBytes
    [         0][INFO  : bl_flash.c: 101] page size   256Bytes
    [         0][INFO  : bl_flash.c: 102] ---------------------------------------------------------------
    [         0][INFO  : hal_board.c: 755] [MAIN] [BOARD] [FLASH] addr from partition is 001f8000, ret is 0
    [         0][INFO  : hal_board.c: 763] [MAIN] [BOARD] [XIP] addr from partition is 231e7000, ret is 0
    [         0][INFO  : hal_board.c: 315] xtal_mode length 2
    [         0][INFO  : hal_board.c: 319] xtal_mode is MF
    [         0][INFO  : hal_board.c: 243] xtal dtb in DEC :36 36 0 60 60
    [         0][INFO  : hal_board.c: 486] channel_div_table :


    Does your log resemble any of these?
  • kbechler
    Level 9  
    There was a sticker on the other side of the module. When I removed it, this message appeared:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    For 99% it is NOT BK7231T but some F8088 from Foneric or something similar. The rest of the logs confirm this:
    Code:
    [bl] goto 0x10101===============================================
    
    SP1-C  Jan  4 2021 19:46:51
    Foneric IoT WLAN SDK 1.3.1


    It's a pity, a nice socket could be....
  • p.kaczmarek2
    Level 28  
    I've uploaded a fix. From what I can see, the entry about MW013_V02 comes from a post by some user who described two sockets in one post, so some error could have crept in.
  • Dark Man
    Level 12  
    I found on some German forum that the Foneric F8089 chip appeared in the Gosund SP1-C socket
    Someone after connecting to RXt Tx got a list of commands after the "help" command

    Code:

    Available commands:
    > echo
    > net
    > heap
    > thread
    > reboot
    > ota
    > efpg
    > netcmd
    > etf
    > sysinfo
    > homekit
    > rp
    > wacreset
    > pdata
    > factoryreset
    > upgrade
    > rtc
    > flash
    > testmode
    > print
    > module
    > model
    > firmware
    > bct
    > help
  • kbechler
    Level 9  
    I saw it. But no one made a custom batch for this chip, so even if you managed to throw something in, it's not much.
  • kbechler
    Level 9  
    p.kaczmarek2 wrote:
    It's hard without the SDK... and what do these commands show? Anyone have their results?

    Unfortunately I do not have. I didn't even try to enter them.
    But if necessary, I can solder it again and check.
    Only ... there are quite a lot of combinations ;-) so I'd be happy to take suggestions as to what exactly we want to know.
  • boozeman
    Level 11  
    Hi,

    Long time no see :)

    Just compiled and updated my Nedis Smart plug and got changed MAC-address C8478C000000. I can not change it back to original.


    Edit. That "Restore RF config" fixed this, so by gone :)


    Cheers Timo
  • p.kaczmarek2
    Level 28  
    Hello @boozeman . We have added many, many features during your absence. Feel free to check out our readme. Also remember that we are improved MQTT stability and are actively improving it.
  • Dark Man
    Level 12  
    He is preparing a teardown from a decorative LSC 970729 bulb (for which there is no cloudcutter profile) in which all electronics sit in an E27 socket.
    I managed to extract the electronics, desolder the WBL5C module, rip the 2MB batch using CH340 and BKwriter, but I can't upload anything for nothing.
    I tried:
    - normally using RX1, TX1
    - with external 3.3V power supply
    - by soldering to RX2 TX2
    - desoldering RX1
    - using different speeds
    - using NodeMCU v3 with ESP disabled
    I thought that maybe something from the TX1 pad was damaged, but by desoldering from it, the ripping of the batch did not go.

    Each time BKwriter immediately after connecting the WBL5C power supply spits out the error:
    Flash ID:0x00000000
    Time:2.827s
    Speed of Programm:115200bps
    erasing flash:0x00011000...FAILED

    I also installed everything for ripping/uploading via python, but even the ripping wouldn't start there.
    (python) PS C:\python\hid_download_py-master> python uartprogram backup.bin -d com4 -r -s 0x0 -l 0x200000
    UartDownloader....
    Read Getting Bus...
    GottenBus...
    Set baudrate successful
    linen: 200,000
    startAddr: 0
    Reading 0
    ReadSector Failed 0

    Any ideas?

    [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

    Won batch attached
  • p.kaczmarek2
    Level 28  
    Show where you get 3.3V, put a 100nF capacitor after the LDO regulator, make sure you reset by cutting off VDD between the module itself and the 3.3V regulator output (and if so, try to cut off together with the entire 3.3V regulator), change the USB to UART converter to another one, change to other baudrate...

    Sometimes a slightly higher baud may work and a lower one may not. E.g. 921600 might work.
  • Dark Man
    Level 12  
    I reset for LDO.
    I gave a 10nF capacitor (because I had no other) for the LDO.
    This capacitor and changed to baudrate 921600 helped! Thx
    I have always been taught by experience that it is better to program at lower speeds and I did not think that higher speeds might be required here :)

    Accidentally, through many attempts, the RX pad from the PCB fell off, but I managed to stick a pin in the tin connecting the chip with the PCB :P
  • marioalmeida
    Level 9  
    Unable to change the MAC address
    I have upgrade 2 device (BK7231T) to 1.15.83 and 1.15.108, thereafter both are having same mac address as C8:47:8C:00:00:00, tried to change the mac address but, it give an error which says "MAC change error?" in the UI
  • p.kaczmarek2
    Level 28  
    Hello @marioalmeida, it's nice to see you after so long time! OBK is now much more stable, it's good you're updating devices.

    Regarding your question, see a screenshot from our FAQ:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    BTW, Windows port with a working scripting demo will be soon released! You will be able to quickly develop and test OBK advanced scripting on Windows machine, without even having an IoT device!
  • marioalmeida
    Level 9  
    Hello p.kaczmarek2, yes after long time. After the issue of BK7231N hanging where I had to toggle the circuit breaker, I gave up on all the BK7231 T/N devices, now thought to revisit and started to upgrade to the latest firmware but ended up with duplicate mac address, I am not sure how the TLV header of RF partition was overwritten as I just upgraded from 1.12.54 to 1.15.x
    After executing "Restore RF Config (T and N, not fully tested, dont click)" button and then reboot, I was able to change the mac address

    p.kaczmarek2 wrote:
    Hello @marioalmeida, it's nice to see you after so long time! OBK is now much more stable, it's good you're updating devices.

    Regarding your question, see a screenshot from our FAQ:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • p.kaczmarek2
    Level 28  
    @marioalmeida we are sorry that you experienced that issue with early version of OBK. We had a MQTT issue that was appearing in a certain usage scenario, it should be now fixed. I am testing dozens of devices daily and they are stable:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Our team has resolved this issue already. If anything else bad happens, please report.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    PS: "startDriver SSDP" , I recommend putting that in startup. Devices will show up in Network Devices then.

    Your support is very valuable, we need users and testers in order to improve the firmware.
  • marioalmeida
    Level 9  
    @p.kaczmarek2 Very nice, I'll find some device to try out as most of the N modules are replaced with T
    p.kaczmarek2 wrote:

    Our team has resolved this issue already. If anything else bad happens, please report.


    What is the use case of this? autoexec, firmware upgrade?
    p.kaczmarek2 wrote:

    PS: "startDriver SSDP" , I recommend putting that in startup. Devices will show up in Network Devices then.


    In this new version I have seen 2 mqtt topics energycounter and energycounter_last_hour, is this Wh, KWh ? or something else?
  • p.kaczmarek2
    Level 28  
    Now both T and N are stable, the only thing that is missing is a power saving mode, but we have a proof of concept working, so stay tuned.

    SSDP? It lists all devices in Windows Network devices section and when you open a device, it leads you to its web page. Very handy.

    I think it's Wh. You need to run NTP for that. This was mostly added by our contributor @valeklubomir who also did a great fixes for MQTT stability. We will add more documentation later.
  • marioalmeida
    Level 9  
    @p.kaczmarek2 , is it possible to add these mqtt topics to HA auto discovery?
    rssi, uptime, freeheap and mac but entity_category must be diagnostic
  • p.kaczmarek2
    Level 28  
    @marioalmeida if Home Assistant Discovery protocol supports that kind of values, there is no problem. I can look into it if you want, but it might be faster to ask our contributor @iprak who wrote the HA discovery support for OBK.