logo elektroda
logo elektroda
X
logo elektroda

Qiachip Smart Switch - BK7231N / CB2S - interior, programming

p.kaczmarek2 64371 288
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #121 20149237
    p.kaczmarek2
    Moderator Smart Home
    SFMax wrote:

    start to work intensively (saving pins, name, mqtt settings more than one time, toggling relay state, watching WebApp log) device was rebooted (or just disconnected from WiFi connection as AP) one moment and than it began to be rebooted (or just disconnected from WiFi connection as AP) on some random actions (some time on attempt to open pin config page, some time on toggling relay state and so on)

    Can't reproduce it so far, do you do that with MQTT connected?


    The one issue I have in mind is the HTTP handler buffer malloc/free fragmentation. I can change the code to use thread-safe buffer cache with mutex and see if it helps you.

    EDIT: Mqtt is not connected, Web app is open and I am clicking 10 times on each option and device is still up.
    Maybe I need to have more relays or MQTT for it to crash.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #122 20149247
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    It seemed like MAC flash sector was broken, but I don't know if it was wrong in the first place or did it break during the 0xFF overwrite made by @00svd00 if I remember correctly.


    After last flashing MAC address was not broken (I could see my original MAC in page with MAC settings) but on first load I've tried to change it to new random one using OpenBeken MAC config page and it looks like that it caused problems with AP disappearing.

    p.kaczmarek2 wrote:
    Can you try this QIO firmware update?

    See please my previous message I've already reflashed device one more time without changing MAC and now everything is OK with AP. But I have other problems (discribed in previous message). Can you check my new dump with debug log and if you find anything else then I try to flash your new QIO firmware update.
    Many thanks to you for help!!!

    Added after 13 [minutes]:

    p.kaczmarek2 wrote:
    Can't reproduce it so far, do you do that with MQTT connected?

    MQTT broker is not set up. In my case MQTT is not connected too. I've just left settings in default.

    p.kaczmarek2 wrote:
    Maybe I need to have more relays or MQTT for it to crash.

    I have only one relay. But as I wrote it is hot enough after 5-10 minutes of intensive working with reading log and changing some settings and state of relay.

    p.kaczmarek2 wrote:
    The one issue I have in mind is the HTTP handler buffer malloc/free fragmentation. I can change the code to use thread-safe buffer cache with mutex and see if it helps you.

    It would be good if you can do it. I want to understand what is problem - memory usage or heating due to such scheme of device.
  • #123 20149270
    p.kaczmarek2
    Moderator Smart Home
    The exact flash version should not matter for that, futhermore I am using still your old one, just with a MAC change..
    I've set up 4 dummy relays (with inverted values but it doesn't matter), a MQTT and a log window:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    I am clicking and clicking and no crashes so far.

    The only crash I remember having is some months ago, when I tried BL0937 socket with MQTT reporting many values every loop. It was doing publish for voltage, energy, power, etc all the time and it was crashing, but I don't think it's related.

    My device is slightly warm. I can feel that, but that's not much warm, I would say.

    8 minutes up
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming


    but still, it could be that memory fragmentation issue, if you are really doing lots of HTTP request, but that's not even the expected usage by me

    edit: 32 minutes
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Helpful post? Buy me a coffee.
  • #124 20149301
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    but still, it could be that memory fragmentation issue, if you are really doing lots of HTTP request, but that's not even the expected usage by me

    I have more than one relay (they are the same) and one of them with the same flashed firmware is set up in wall light switch socket now and connected to MQTT. I don't use HTTP request to it at all and don't make lots of request by mqtt. It has the same behaviour - after some time of working (powered on) less than one day it also starts to reboot (disconnect from WiFi) repeatedly. More time of working - more often reboots (disconnects from WiFi). And when frequency of reboots becomes frequent enough device is unavailable by WiFi and MQTT. Powering off for long time (more than some hours) can make device to work.
    One more thing - with original firmware it is also rebooted (disconnected from WiFi) sometimes but not so often and not repeatedly. And after rebooting (disconnecting from WiFi) it continues working.

    UPD: As example now I powered on my second relay in socket, waited 5 minutes and then toggled relay state two times (on and off) with 2 seconds delay between operations. After second time of toggling relay began rebooting (disconnecting from WiFi) repeatedly and then became unavailable by wifi. Light switch button is not working also. Now I need to power off device, wait for some time and then it will be available again.
  • #125 20149316
    p.kaczmarek2
    Moderator Smart Home
    Do you think it's mostly the amount of HTTP request that makes the device crash faster?
    So, if:
    - if device is left alone, it will be online for long time
    OR
    - device will always crash after about a day or so?
    Helpful post? Buy me a coffee.
  • #126 20149326
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    - if device is left alone, it will be online for long time

    p.kaczmarek2 wrote:
    device will always crash after about a day or so?

    It is online for long time (may be some hours) if device is left alone only after fresh reflashing firmware. Online time is less after it was rebooted for the first time. See example in previous message (I flashed that device two days ago and it was rebooted for the first time yesterday). Now time of still online work - some minutes only.
  • ADVERTISEMENT
  • #127 20149524
    p.kaczmarek2
    Moderator Smart Home
    Still up:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    I am not sure how to trigger that at will, I will most likely have to connect it to other machine than my notebook and leave it overnight with USB to UART dongle connect to collect logs...
    Helpful post? Buy me a coffee.
  • #128 20149626
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    Still up:

    So I am afraid that it is hardware problem - may be power supply of my device can not manage this firmware on CB2S module. It is overheated, power is not enough and I have unpredictable behaviour of device. OpenBeken firmware is too difficult (HTTP, MQTT and so on) for my scheme. Original firmware is more light than OBK.
  • #129 20149684
    p.kaczmarek2
    Moderator Smart Home
    I don't think it is. I think something might be wrong with N SDK in certain cases.
    I suspect that you might have the same issue that the two BL0937 users from Github. At first I tought it was related to MQTT and was an other thing, but maybe it's the same... they also reported using CB2S (not: CB3S and not any other device).

    edit: 6h almost
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Helpful post? Buy me a coffee.
  • #130 20149929
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    edit: 6h almost

    Is it CB3S device?
  • #131 20150001
    p.kaczmarek2
    Moderator Smart Home
    p.kaczmarek2 wrote:

    Flashed it to CB3S:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    CB3S (not CB2S). Device sits next to me powered by my notebook USB and TC1264 LDO 3.3V
    I must admit that I am confused with all those strange issues, but I will try my best to resolve them for you.

    I might try to backport some things from T SDK to N SDK and see if it works better, or update N SDK to newer version...


    @SFMax out of curiousity, which USB to TTL converter did you use for flashing? Have you made sure that it's using 3.3V voltage levels on TX/RX lines?

    Dodano po 41 [minuty]:

    I looked at the other CB2S user errors and supposedly it hangs with UART log:
    Quote:

    Info:MAIN:Time 23435, free 78688, MQTT 1, bWifi 1, secondsWithNoPing 1, socks 2/38

    sm_disassoc_handler
    sm_disassoc_handler reason=2,vif=0
    sm_disconnect_process
    me_set_ps_disable:840 0 0 1 0 11
    SM_DISCONNECT_IND
    bad_channel vif_idx=0
    bad_channel vif_idx=0

    the sm_disassoc_handler seems to come from librwnx.a
    Quote:

    .text.sm_disassoc_handler
    0x0007fc78 0x8c ./beken378/lib/\librwnx.a(sm.o)
    0x0007fc78 sm_disassoc_handler

    then I looked into the config:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    GIT\OpenBK7231N\platforms\bk7231n\bk7231n_os\beken378\app\config\sys_config.h
    GIT\OpenBK7231T\platforms\bk7231t\bk7231t_os\beken378\app\config\sys_config.h

    The N SDK has CFG_LESS_MEMERY_IN_RWNX enabled but T don't

    in the end, I found some other changes in the sys_config.h files and ported T variables to N
    I am not sure if I should test it myself because it would mean losing 7h rest results from CB3S, so can you check out this binary and see how it behaves?
    Helpful post? Buy me a coffee.
  • #132 20150164
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    @SFMax out of curiousity, which USB to TTL converter did you use for flashing? Have you made sure that it's using 3.3V voltage levels on TX/RX lines?

    I use CP2102 USB to TTL converter. Level of TX/RX lines is 3.3V.

    p.kaczmarek2 wrote:
    I am not sure if I should test it myself because it would mean losing 7h rest results from CB3S, so can you check out this binary and see how it behaves?

    I flashed your binary. At first boot (with uart connected) it was ok. I set name, made pin configuration. But when I connect to 220V power supply and open logs page after 2-3 minutes it began rebooting repeatedly 2-3 times until I powered off my device. So I have same results but with less time.

    UPD: I've checked pin voltage level when usb converter is connected to CB2S. I have 3.8 V in TX pin and 4.3 V in RX. Without connection level of TX/RX on USB to TTL converter is 3.3V on both of them. I think it is caused by CB2S module location with soldered pins on circuit scheme.
  • #133 20150253
    p.kaczmarek2
    Moderator Smart Home
    SFMax wrote:

    I flashed your binary. At first boot (with uart connected) it was ok. I set name, made pin configuration. But when I connect to 220V power supply and open logs page after 2-3 minutes it began rebooting repeatedly 2-3 times until I powered off my device. So I have same results but with less time.

    My BK7231N is almost at 10h uptime mark:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    So maybe let's try another way....
    1. does your device works if you power it from external reliable 3.3V or 5V (but of course through LDO 3.3V) supply?
    2. by any chance, don't you have a faulty capacitor like me in this topic (use google translate):
    https://www.elektroda.pl/rtvforum/topic3898805.html
    basically, the device described in the topic above, was only several weeks old and had a faulty capacitor that made it randomly reset and emit strange sounds from the coil
    Helpful post? Buy me a coffee.
  • #134 20150416
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    1. does your device works if you power it from external reliable 3.3V or 5V (but of course through LDO 3.3V) supply?

    I need some more time for testing. Till this moment device (powered by uart 3.3 V) worked for 25 minutes with log showing and some my actions by http without any problem.
    p.kaczmarek2 wrote:
    2. by any chance, don't you have a faulty capacitor like me in this topic (use google translate):

    Hyncdz capacitor 16V 1000 uF is the hottest of all components (big enough to touch with my fingers) but it looks normal. It is used to power both relay (12 V) and CB2S module (3.3V).
    If it is bad one it means that I have 5 smart switch devices with bad capacitors. May be it must be changed by other one with higher parameters.
  • ADVERTISEMENT
  • #135 20150689
    p.kaczmarek2
    Moderator Smart Home
    Do you have an ESR meter?

    O my side, the BK7231N stability test is still going well:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Helpful post? Buy me a coffee.
  • #136 20151348
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    Do you have an ESR meter?

    No, I don't.
    I soldered 35v 1000uF capacitor on wires instead 16V 1000 uF and behavior is much better. After about half an hour of testing there is no reboots.
    What about MAC address problem? Have you commited changes in any releases?
    What can you tell about MQTT TLS/SSL? I could not connect to MQTT by secured prorocol?

    UPD: Everything was ok before I connected device to my WiFi. With WiFi connected it began to reboot again after some time of work. With MQTT enabled rebooting is more often than with empty fields in config.
  • #137 20155072
    p.kaczmarek2
    Moderator Smart Home
    Right now I have bought a new CB2S device and I can confirm there is indeed some kind of issue like @00svd00 has.
    The solution posted by @00svd00 worked - it solved everything, and I could easily change the MAC address back to correct one.
    The device in client mode works only for short time and does not reply to HTTP, because it basically stucks in handling HTTP request. This also means that buffers allocated for each HTTP request stay in memory so it runs out of memory.
    This only happens on new CB2S devices which seem to have new format of WiFi calibration/something, my old CB2S still works well, and clearing whole mem fixes it.
    Here is the log:
    
    
    V:BK7231N_1.0.1
    
    REG:cpsr     spsr     r13      r14
    
    SVC:000000D3          00401C1C 000033AC
    
    IRQ:000000d2 00000010 00401e0c 01d42004 
    
    FIR:000000d1 00000010 00401ffc 20889404 
    
    SYS:000000df          0040192c 00000158 
    
    ST:00000000
    
    J 0x10000
    
    bk_misc_init_start_type 0 0
    prvHeapInit-start addr:0x4113c0, size:126016
    [Flash]id:0x1c7015
    sctrl_sta_ps_init
    cset:0 0 0 0
    Entering init log...
    Init log done!
    Commands registered!
    bandgap_calm_in_efuse=0x29
    [load]bandgap_calm=0x29->0x29,vddig=4->4
    [FUNC]rwnxl_init
    [bk]tx_txdesc_flush
    [FUNC]intc_init
    [FUNC]calibration_main
    gpio_level=1,txpwr_state=15
    user define rfcali mode:1 
    get rfcali_mode:1
    calibration_main over
    flash txpwr table:0xf
    dif g and n20 ID in flash:4
    dif g and n40 ID in flash:4
    read txpwr tab from flash success
    temp in flash is:331
    xtal in flash is:40
    xtal_cali:40
    --init_xtal = 40
    [FUNC]ps_init
    [FUNC]func_init_extended OVER!!!
    
    start_type:0
    Version:
    Initializing TCP/IP stack
    tcp_port:62642
    app_init finished
    Debug:CMD:Adding command loglevel
    Debug:CMD:Adding command logfeature
    Debug:CMD:Adding command logtype
    Debug:CMD:Adding command logdelay
    Debug:CFG:flash vars not initialised - reading
    Debug:CFG:new offset after read 516, boot_count 8, success count 8
    Info:CFG:####### Boot Count 9 #######
    Debug:CFG:new offset 548, boot_count 9, success count 8
    Debug:CFG:new offset after read 548, boot_count 9, success count 8
    Debug:CFG:re-read - offset 548, boot count 9, boot success 8, bootfailures 1
    Debug:CFG:HAL_Configuration_ReadConfigMemory: read 2016 bytes to 1904640
    Debug:CFG:CFG_CalcChecksum: header size 4, total size 2016, rem size 2012
    
    Warn:CFG:CFG_InitAndLoad: Correct config has been loaded with 1 changes count.
    Info:MAIN:Using SSID [Full_Power_5G]
    
    Info:MAIN:Using Pass [P@ssw0rd]
    
    Debug:MAIN:Started http tcp server
    
    Debug:CMD:Adding command startDriver
    Debug:CMD:Adding command addRepeatingEvent
    Debug:CMD:Adding command showgpi
    Debug:CMD:Adding command setChannelType
    Debug:CMD:Adding command showChannelValues
    Debug:MAIN:Initialised pins
    
    Info:MQTT:MQTT_RegisterCallback called for bT obk12AEB56F/ subT obk12AEB56F/+/set
    Info:MQTT:MQTT_RegisterCallback called for bT cmnd/obk12AEB56F/ subT cmnd/obk12AEB56F/+
    Debug:CMD:Adding command publish
    Debug:MAIN:Initialised other callbacks
    
    Debug:CMD:Adding command power
    Debug:CMD:Adding command powerStateOnly
    Debug:CMD:Adding command powerAll
    Debug:CMD:Adding command color
    Debug:CMD:Adding command backlog
    Debug:CMD:Adding command exec
    Debug:CMD:Adding command addcmd
    Debug:CMD:Adding command led_dimmer
    Debug:CMD:Adding command led_enableAll
    Debug:CMD:Adding command led_basecolor_rgb
    Debug:CMD:Adding command led_basecolor_rgbcw
    Debug:CMD:Adding command led_temperature
    Debug:CMD:Adding command led_brightnessMult
    Debug:CMD:Adding command led_colorMult
    Debug:CMD:Adding command led_saturation
    Debug:CMD:Adding command led_hue
    Debug:CMD:Adding command sendGet
    Debug:CMD:Adding command SetChannel
    Debug:CMD:Adding command AddChannel
    Debug:CMD:Adding command ClampChannel
    Debug:CMD:Adding command SetPinRole
    Debug:CMD:Adding command SetPinChannel
    Debug:CMD:Adding command GetChannel
    Debug:CMD:Adding command GetReadings
    Debug:CMD:Adding command ShortName
    Debug:CMD:Adding command AddEventHandler
    Debug:CMD:Adding command AddChangeHandler
    Debug:CMD:Adding command listEvents
    Debug:CMD:Adding command restart
    Debug:CMD:Adding command clearConfig
    Debug:CMD:cmd [exec autoexec.bat]
    Debug:CMD:exec autoexec.bat
    Error:CMD:lfs is absent
    Info:GEN:PIN_SetupPins pins have been set up.
    
    Debug:MAIN:started timer
    
    Info:MAIN:Time 1, free 94664, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    cal_bias!
    cal dpll!
    temperature_type=2
    temp_code:46 - adc_code:288 - adc_trend:[13]:331->[17]:291
    Info:MAIN:Time 2, free 94664, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 3, free 94664, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 4, free 94664, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    supplicant_main_exiting
    supplicant_exit_done
    Info:MAIN:Time 5, free 94664, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    [sa_sta]MM_RESET_REQ
    [bk]tx_txdesc_flush
    [sa_sta]ME_CONFIG_REQ
    [sa_sta]ME_CHAN_CONFIG_REQ
    [sa_sta]MM_START_REQ
    bssid 48-ee-0c-48-93-12
    security2cipher 2 3 24 8 security=6
    cipher2security 2 3 24 8
    hapd_intf_add_vif,type:2, s:0, id:0
    wpa_dInit
    wpa_supplicant_req_scan
    Setting scan[retry16] request: 0.100000 sec
    MANUAL_SCAN_REQ
    enter low level!
    mac d8:1f:12:ae:b5:6f
    leave low level!
    net_wlan_add_netif done!, vif_idx:0
    aready open
    aready open
    Debug:MAIN:Registered for wifi changes
    
    Info:MAIN:Time 6, free 90680, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 7, free 90680, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 8, free 90680, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    wpa_supplicant_scan
    Cancelling scan request
    wpa_driver_associate
    ssid:Full_Power_5G, 1
    ht in scan
    scan_start_req_handler
    Info:MAIN:wl_status 3
    
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING
    
    SM_DISCONNECTING status=1
    ---------SM_CONNECT_IND_fail
    Info:MAIN:Time 9, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    sta: 0, softap: 0, b/g/n
    Info:MAIN:Time 10, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=d8:1f:12:ae:b5:6f 
    
    Info:MQTT:mqtt_userName homeassistant
    mqtt_pass qqqqqqqqqq
    mqtt_clientID obk12AEB56F
    mqtt_host 192.168.0.113:1883
    
    Info:MQTT:Connect error in mqtt_client_connect - code: -4
    
    Info:MAIN:Time 11, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 12, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 13, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 14, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 15, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 16, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 17, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 18, free 90504, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    wpa_supplicant_req_scan
    Setting scan[retry15] request: 0.100000 sec
    wpa_supplicant_req_scan
    Ignore new scan request for 10.000000 sec since an earlier request is scheduled to trigger sooner
    wpa_supplicant_req_scan
    Ignore new scan request for 1.000000 sec since an earlier request is scheduled to trigger sooner
    Info:MAIN:wl_status 9
    
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_AUTH_FAILED
    
    wpa_supplicant_scan
    wpa_drv_scan
    wpa_send_scan_req
    ht in scan
    scan_start_req_handler
    Info:MAIN:Time 19, free 89224, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    sta: 0, softap: 0, b/g/n
    Info:MAIN:Time 20, free 89216, MQTT 0, bWifi 0, secondsWithNoPing 0, socks 2/38
    
    Info:GEN:dhcp=0 ip=0.0.0.0 gate=0.0.0.0 mask=0.0.0.0 mac=d8:1f:12:ae:b5:6f 
    
    wpa_driver_scan_cb
    wpa_get_scan_rst:1
    wpa_supplicant_connect
    Cancelling scan request
    wpa_driver_associate
    ssid:Full_Power_5G, 1
    found scan rst rssi -42 > -50
    ht in scan
    scan_start_req_handler
    Info:MAIN:wl_status 3
    
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTING
    
    me_set_ps_disable:840 0 0 1 0 3
    sm_auth_send:1
    sm_auth_handler
    ht in assoc req
    sm_assoc_rsp_handler
    rc_init: station_id=0 format_mod=2 pre_type=0 short_gi=1 max_bw=0
    rc_init: nss_max=0 mcs_max=7 r_idx_min=0 r_idx_max=3 no_samples=10
    ---------SM_CONNECT_IND_ok
    wpa_driver_assoc_cb
    Cancelling scan request
    __l2_packet_send: ret 0
    __l2_packet_send: ret 0
    hapd_intf_add_key CCMP
    add sta_mgmt_get_sta
    sta:0, vif:0, key:0
    sta_mgmt_add_key
    add hw key idx:24
    hapd_intf_add_key CCMP
    add is_broadcast_ether_addr
    sta:255, vif:0, key:1
    add hw key idx:1
    ctrl_port_hdl:1
    me_set_ps_disable:840 0 0 0 0 3
    sta_ip_start
    
    configuring interface mlan (with DHCP client)dhcp_check_status_init_timer:20000
    Info:MAIN:wl_status 10
    
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED
    
    
    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 : 7 
    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 
    
    ip_addr: 7100a8c0
    Info:MAIN:wl_status 11
    
    Info:MAIN:Main_OnWiFiStatusChange - WIFI_STA_CONNECTED
    
    Info:MAIN:Time 21, free 89808, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MQTT:mqtt_userName homeassistant
    mqtt_pass qqqqqqqqqq
    mqtt_clientID obk12AEB56F
    mqtt_host 192.168.0.113:1883
    
    Info:MAIN:Time 22, free 89848, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 23, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 24, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 25, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 26, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 27, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 28, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 29, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    sta: 1, softap: 0, b/g/n
    sta:rssi=-41,ssid=Full_Power_5G,bssid=30:b5:c2:5d:70:72 ,channel=7,cipher_type:MIXED
    Info:MAIN:Time 30, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:GEN:dhcp=0 ip=192.168.0.113 gate=192.168.0.1 mask=255.255.255.0 mac=d8:1f:12:ae:b5:6f 
    
    Info:MAIN:Time 31, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Boot complete time reached (30 seconds)
    
    Info:CFG:####### Set Boot Complete #######
    Debug:CFG:new offset 580, boot_count 9, success count 9
    Debug:CFG:new offset after read 580, boot_count 9, success count 9
    Debug:CFG:re-read - offset 580, boot count 9, boot success 9, bootfailures 0
    Info:MAIN:Time 32, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MQTT:mqtt_userName homeassistant
    mqtt_pass qqqqqqqqqq
    mqtt_clientID obk12AEB56F
    mqtt_host 192.168.0.113:1883
    
    Info:MQTT:Connect error in mqtt_client_connect - code: -10
    
    Info:MAIN:Time 33, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 34, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 35, free 89856, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 2/38
    
    Info:MAIN:Time 36, free 76176, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 3/38
    
    Info:MAIN:Time 37, free 76176, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 3/38
    
    Info:MAIN:Time 38, free 76176, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 3/38
    
    Info:MAIN:Time 39, free 76176, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 3/38
    
    sta: 1, softap: 0, b/g/n
    sta:rssi=-42,ssid=Full_Power_5G,bssid=30:b5:c2:5d:70:72 ,channel=7,cipher_type:MIXED
    Info:MAIN:Time 40, free 76176, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 3/38
    
    Info:GEN:dhcp=0 ip=192.168.0.113 gate=192.168.0.1 mask=255.255.255.0 mac=d8:1f:12:ae:b5:6f 
    
    Info:MAIN:Time 41, free 76176, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 3/38
    
    Info:MAIN:Time 42, free 76176, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 3/38
    
    Info:MAIN:Time 43, free 44304, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 7/38
    
    Error:HTTP:TCP Client failed to malloc buffer
    Info:MQTT:mqtt_userName homeassistant
    mqtt_pass qqqqqqqqqq
    mqtt_clientID obk12AEB56F
    mqtt_host 192.168.0.113:1883
    
    Info:MQTT:Connect error in mqtt_client_connect - code: -10
    
    Info:MAIN:Time 44, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    Error:HTTP:TCP Client failed to malloc buffer
    Error:HTTP:TCP Client failed to malloc buffer
    Error:HTTP:TCP Client failed to malloc buffer
    Error:HTTP:TCP Client failed to malloc buffer
    Info:MAIN:Time 45, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    Error:HTTP:TCP Client failed to malloc buffer
    Info:MAIN:Time 46, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    Error:HTTP:TCP Client failed to malloc buffer
    Error:HTTP:TCP Client failed to malloc buffer
    Error:HTTP:TCP Client failed to malloc buffer
    Info:MAIN:Time 47, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    Error:HTTP:TCP Client failed to malloc buffer
    Error:HTTP:TCP Client failed to malloc buffer
    Info:MAIN:Time 48, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    Error:HTTP:TCP Client failed to malloc buffer
    Info:MAIN:Time 49, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    Error:HTTP:TCP Client failed to malloc buffer
    sta: 1, softap: 0, b/g/n
    sta:rssi=-40,ssid=Full_Power_5G,bssid=30:b5:c2:5d:70:72 ,channel=7,cipher_type:MIXED
    Info:MAIN:Time 50, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    Info:GEN:dhcp=0 ip=192.168.0.113 gate=192.168.0.1 mask=255.255.255.0 mac=d8:1f:12:ae:b5:6f 
    
    Error:HTTP:TCP Client failed to malloc buffer
    Info:MAIN:Time 51, free 3264, MQTT 0, bWifi 1, secondsWithNoPing 0, socks 10/38
    
    
    


    notice at the log how free memory goes down with each request... this is because HTTP server allocs buffers and they are not fried... something must be stuck on recv or send call in HTTP code.
    Here is the original Tuya dump from problematic CB2S:
    CB2S_2MB_d...server.zip Download (1.02 MB)
    cb2s_backu...s0_2mb.zip Download (1.02 MB)
    (one from bkWriter second from hid_download_py)

    I will investigate it later when I get some more free time, but the current solution is to flash bin file posted by @00svd00 , then reset device power 6 times, connect to AP, change MAC and just configure it like always.
    FullFW_tem...roblem.zip Download (843.29 kB)


    this is all very strange because I had users with CB2S using them flawlessly, like the Jennifer with her Fan Qiachip controls, something must have changed very recently.

    If anyone wants to help - get CB2S or other N device and flash the attached Tuya flash, then flash over with latest OBK and try to fix OBK, but most likely it will require work in the OpenBK7231N repository (the SDK one, not an App)


    PS: the interesting thing is that Tuya also updated their BK7231N SDK on their repository... would that mean porting OBK to new SDK (and removing Tuya additions) would fix the problem?
    Helpful post? Buy me a coffee.
  • #138 20156407
    p.kaczmarek2
    Moderator Smart Home
    It seems that case is related to device not liking the large TCP packets sent by HTTP server. I will most likely reduce TCP buffer and send packets buffered up to 1024 bytes. It seems to be resolving the issue for me. The "firmware hack" should not be needed now.

    The root cause is still under investigation. Maybe it's running out of PBUFs in LWIP library, or maybe there is a buffer overrun error elsewhere.
    Helpful post? Buy me a coffee.
  • #139 20156690
    SFMax
    Level 8  
    I made some tests with power measurements. With original firmware device consumes 0,4 to 1,0 W with relay switched off state depending on strength of wifi signal from router and 1,4 W with relay switched on state. With OpenBeken firmware consumption is 1,1 - 1,4 W with relay switched off state and 2,1 W with relay switched on state. It causes strong heat of components under shell and rebooting of device (device has linear voltage regulator with overheating protection). In my case I changed low voltage capacitor (16 V, 1000 uF) by other one new capacitor with the same characteristics but bigger size and longer connection contacts, don't use cover of shell. Temperature of device is not so hot now and there is no rebooting. But it is necessary to do more tests with different scenarios. Unfortunately firmware is too resource intensive for my device (in photo below).
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    Added after 9 [minutes]:

    p.kaczmarek2 wrote:
    I will investigate it later when I get some more free time, but the current solution is to flash bin file posted by @00svd00 , then reset device power 6 times, connect to AP, change MAC and just configure it like always.

    In my case device behavior is the same with these steps. But power consumption of device with OBK firmware makes me think that it is OBK firmware problem. Does this firmware have such optimization like
    p.kaczmarek2 wrote:
    new CB2S devices which seem to have new format of WiFi calibration/something
    ?
  • #140 20156750
    p.kaczmarek2
    Moderator Smart Home
    I think that the power consumption can be easily improved. I will look into that.

    The only problem is that there is no documentation at all for BK chips so I will have to look through the SDK...

    Can you do some tests, for example, check power consumption in AP mode?

    If I were to send you some test cases, would you measure power consumption for them?


    Regarding new CB2S devices - my CB2S from this topic worked flawlessly, it's @00svd00 who discovered that new device flash contents breaks OBK... idk why it happens yet.

    EDIT: potential power saving mechanism in N sdk:
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Helpful post? Buy me a coffee.
  • #141 20156797
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    If I were to send you some test cases, would you measure power consumption for them?

    What test cases do you mean? If it will be something like OTA releases for WiFi update (without flashing by UART) I can investigate them.
  • #142 20156799
    p.kaczmarek2
    Moderator Smart Home
    Do you still have UART connected to at least one of the devices? Or does it have to be OTA-compatible bin?

    I could try OTA only, I will check that

    EDIT: I have made futher tests with my CB2S board. CB2S is powered from AMS1117 3.3V. The current meter is before 1117
    At 5V, it consumes 60mA up to 80mA, so it's (0.08*5)W = 0.4W
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Helpful post? Buy me a coffee.
  • #143 20156850
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    Do you still have UART connected to at least one of the devices? Or does it have to be OTA-compatible bin?

    No, I've unsoldered all my devices. Only OTA is possible.
  • ADVERTISEMENT
  • #144 20156868
    p.kaczmarek2
    Moderator Smart Home
    I'm on it right now.
    Current consumption is between 60mA and 80mA at 5V, most of the time 80mA.
    I am testing:
    
    /*section 23 ----- support reduce nomal power*/
    #define CFG_SYS_REDUCE_NORMAL_POWER                0
    

    but it makes seemingly no difference right now, despite me recompiling whole SDK
    I wonder how did you get to 1.4W. I am measuring at 5V, so the power supply loses are not included....

    ah, and I am testing without MQTT right now.

    I will try to lower this 80mA active current
    Helpful post? Buy me a coffee.
  • #145 20156874
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    I wonder how did you get to 1.4W

    I use internal device's power supply to 220V connected not external one.

    I use 220V power meter. It shows full consumption of device (CB2S, relay and other components). There is also asm1117 regulator in scheme is used.
  • #146 20158432
    p.kaczmarek2
    Moderator Smart Home
    @SFMax would you be able to check the consumption at 5V with AMS1117? Just to make sure you're also getting 60-80mA at 5V...
    Helpful post? Buy me a coffee.
  • #147 20159573
    00svd00
    Level 8  
    I have a strange idea. Can you check voltage on realy switching pin on stock FW and on OpenBK FW? Because ralay holding power is much less than switching power. And stock FW can have some optimisations - FE switching relay with one pin, which opens mosfet with full 5V and after that holding it with another pin, which opens 3v3 mosfet.
  • #148 20160016
    SFMax
    Level 8  
    p.kaczmarek2 wrote:
    EDIT: I have made futher tests with my CB2S board. CB2S is powered from AMS1117 3.3V. The current meter is before 1117
    At 5V, it consumes 60mA up to 80mA, so it's (0.08*5)W = 0.4W

    Can you find out what IC power controller is used in your schema please?
    p.kaczmarek2 wrote:
    @SFMax would you be able to check the consumption at 5V with AMS1117? Just to make sure you're also getting 60-80mA at 5V...

    My multimeter's function of current strength measurement is broken now. I try to find another way and inform you then.
  • #149 20160062
    00svd00
    Level 8  
    SFMax wrote:
    p.kaczmarek2 wrote:
    EDIT: I have made futher tests with my CB2S board. CB2S is powered from AMS1117 3.3V. The current meter is before 1117
    At 5V, it consumes 60mA up to 80mA, so it's (0.08*5)W = 0.4W

    Can you find out what IC power controller is used in your schema please?
    p.kaczmarek2 wrote:
    @SFMax would you be able to check the consumption at 5V with AMS1117? Just to make sure you're also getting 60-80mA at 5V...

    My multimeter's function of current strength measurement is broken now. I try to find another way and inform you then.

    Voltage will be enough. With constant resistance current will be proportional to voltage
  • #150 20180581
    p.kaczmarek2
    Moderator Smart Home
    @00svd00 some time passed already, is your device stable after that "2MB flash wipe" that you did? Did it solve your problem?

    I've tried to test some things with a BK7231N lamp that I have (but no CB2S) but sadly it's stable for almost 2 weeks now (usually I turn off the power while leaving, but this time I left in on purpose):
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the Qiachip Smart Switch utilizing the BK7231N chip and the CB2S module, focusing on programming, firmware flashing, and integration with Home Assistant. Users share experiences with flashing the device using various tools like hid_download_py and uartprogram, troubleshooting issues such as connection problems, firmware compatibility, and device reboots. Key challenges include configuring WiFi settings, handling relay operations, and ensuring stable operation with different firmware versions. The community provides insights on soldering techniques, pin configurations, and the importance of power supply stability. Additionally, there are discussions about integrating DHT sensors and the need for improved firmware features.
Summary generated by the language model.
ADVERTISEMENT