logo elektroda
logo elektroda
X
logo elektroda

[BL602/BL0937] Yet another Smart Socket 20A (but 16A)

flobuljeedom 13734 116
ADVERTISEMENT
  • #61 21025455
    miegapele
    Level 15  
    I have bl602 with wires soldered, so will be able to test. Probably need some command to trigger infinite loop or something like that for proper testing.
  • ADVERTISEMENT
  • #62 21025472
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • #63 21025481
    miegapele
    Level 15  
    I mean proper test by crashing socket somehow.

    Added after 1 [minutes]:

    Although I remembered one way, calibrating power to zero once made it freeze for me 😂. That also I should fix
  • #64 21025549
    p.kaczmarek2
    Moderator Smart Home
    I know, I was referring to compilation error.

    I think I can add a "Freeze" driver that will put infinite loops in both "every second timer" and "quick tick". Usage will be:
    
    startDriver Freeze
    
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #65 21025795
    Raufaser
    Level 10  
    >>21025444

    I can join testing with a LF686. I am hooking it up to uart at the moment.
  • #66 21025937
    p.kaczmarek2
    Moderator Smart Home
    Here is PR to download binaries from:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1158
    It enables watchdog so it should just work. In order to test the watchdog, you need to start the freeze driver that just does:
    Example of source code in the drv_freeze.c file.
    So, once you confirm it just runs, you can do:
    
    startDriver freeze
    

    and it should just reboot with watchdog reason (unless I missed something, @miegapele can double check)
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #67 21025951
    miegapele
    Level 15  
    Does not seem to work, unfortunately. It boots, acts all normally, and even OTA works, but the freeze driver freezes everything and no reboot.
    Might be you need to init timer too after all, will test
  • #68 21025971
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #69 21025997
    epolet
    Level 5  
    Hello guys,
    I have such smart socket and successfully uploaded OpenBeken software. I was able to connect to it via web over wifi
    But when I soldered out wires through which it was reprogrammed, assembled it back and put to the socket, I found it doesn't work. Led seemed to sigh and go out. Neither short nor long pressing of button did not help. Soldering up two wires just to CB2S board and connecting to PC brings it to life and to wifi again. So obviously, there some trouble with power on the socket board happened. Strange - it is totally new socket. But ok, as is now.
    I suspect chip between two big capacitors (marked by red question mark on a picture (I took it from previous page, thanks)). But it is impossible to recognize it because of totally unreadable its marking.
    So, maybe anyone could advise me something to bring socket to life? Or, at least, help to recognize that chip.
    Thanks.
    [BL602/BL0937] Yet another Smart Socket 20A (but 16A)
  • #70 21025998
    Raufaser
    Level 10  
    After
    startDriver freeze
    I get this on UARL log
    Info:MAIN:Started freeze.
    Info:CMD:[WebApp Cmd-----------------> AABA Request:
        A-MSDU: Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 64
    -----------------> AABA Response:
        A-MSDU: Not Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 8
    -----------------> AABA Request:
        A-MSDU: Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 64
    -----------------> AABA Response:
        A-MSDU: Not Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 8


    Loops infinitely ...

    I don't know if it is important
  • #71 21025999
    miegapele
    Level 15  
    I made same change on my branch, seems the same. everything looks frozen, but something still works. I tried forcing disconnection from the wifi, UART log then shows it trying to connect but failing.
    I will try to remove wdt_feed call, seems like something is not correct.
  • #72 21026020
    p.kaczmarek2
    Moderator Smart Home
    This is suprising @miegapele because wdt_feet is at the end of OnEverySecond call:
    Screenshot of code in Microsoft Visual Studio highlighting the function wdt_feed in the editor.
    So, with infinite loop in driver EverySecond, it should not be reached.
    Helpful post? Buy me a coffee.
  • #73 21026021
    Raufaser
    Level 10  
    Hi.

    epolet wrote:
    I suspect chip between two big capacitors (marked by red question mark on a picture (I took it from previous page, thanks)). But it is impossible to recognize it because of totally unreadable its marking.


    BP2525

    epolet wrote:
    Soldering up two wires just to CB2S


    There shouldn't be an CB2S in this socket. It should be SM-028_V1.3
  • #74 21026036
    miegapele
    Level 15  
    Removing wdt_feet makes it properly boot loop, after it boots in safe mode fine, so maybe worth keeping, it might help with some crashes.
    ALSO that timer init code speeds up time counting by 2 so that part should not be merged.
    there is slightly different time initialization in new sdk, might try that later
  • #75 21026208
    epolet
    Level 5  
    Raufaser wrote:
    BP2525

    Yep! Thank you.
    I checked it and found it works well - 365V on input and 5.2V on output.
    So the next stop is LM1117. It has 1.8V on input and 0.8V on output.
    Strange. Between BP2525 and LM1117 there is almost nothing.
    According to typical application schematic of BP2525 (let me put it here just in case) the only diode is under suspection
    Application circuit diagram of the BP2525X for power rectification and regulation.
    Ok. Will check it.

    Raufaser wrote:
    There shouldn't be an CB2S in this socket. It should be SM-028_V1.3

    Maybe it is a little bit different version of the socket. It has CB2S :
    CB2S module on a circuit board with visible components. Close-up of a circuit board with a mounted CB2S module marked with RX2, TX2, and a serial number.
  • #76 21026358
    Raufaser
    Level 10  
    OK. But then you are either in the wrong thread, or you flashed the wrong firmware.
    CB2S has a BK7231N. This thread is about the BL602. That is a different chip.
  • #77 21026359
    miegapele
    Level 15  
    >>21026020
    Yes, strange, I see there is mutex taken on driver code, maybe it runs in parallel somehow if first one is stuck. I wonder how to test this
  • #78 21026489
    zdzihu123
    Level 11  
    miegapele wrote:
    Could you try without ssdp driver? ssdp generates quite a lot of traffic, might be some problems with that part.

    I tried to run without SSDP driver but no joy. The device froze after circa 11-12 hours. One thing I noticed is that sometimes when it's frozen the button still works and relay can be switched manually. So it's quite inconsistent and there is no repeatable pattern.

    Great work with watchdog everyone. If there are any other troubleshooting steps I could help with, please let me know.
  • #79 21026582
    p.kaczmarek2
    Moderator Smart Home
    @miegapele can you check is it ok to merge?
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1158
    I disabled extra timer

    @zdzihu123 well, if button is still working then I don't think that watchdog can help much... buttons are handled in the quick tick update. Hmm.
    @miegapele what do you think?
    I've seen similiar issue once or twice. It was caused by a strange TCP socket lock causing memory leak. The free memory amount was going down and memory was not freed. Finally the HTTP server code was not able to alloc new buffers for TCP connections, here:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/httpserver/http_tcp_server.c
    If HTTP GET malloc is failing ,then device will not be reachable via HTTP but will still work when you press physical button.
    See this fragment:
    HTTP server code snippet highlighting memory allocation.
    Maybe we could change the server behaviour to be more bulletproof? Maybe we could prealloc, let's say, 4 buffers and keep shuffling them? But that means we will be able to only handle 4 TCP connections at all... removing the "malloc" call per HTTP packet would make HTTP server immune to "malloc returns 0" problem.
    There are of course some problems with that. For example, this code is shared between all platforms (well, except windows simulator), so any change there would require extensive testing. Unless we #ifdef that just for BL602...
    Thoughts?
    Helpful post? Buy me a coffee.
  • #80 21027067
    miegapele
    Level 15  
    I did a lot of playing with watchdog, and it does work in the end, so should be merged.
    I tested the pull request branch, it works, and OTA after that works too, so should be same to merge.
    Issue was our Freeze driver was too aggressive so that it made even wdt timer not work somehow. I removed infinite loop code from Freeze_RunFrame, and modified to Freeze_OnEverySecond to do some useless calculations in infinite loop, and then it reboots as expected, and after reboot reason is shown as software watchdog.

    As for freezes, I saw one while playing with wifi networks to tests one bug, but that socket runs older version.
    It's also possible to freeze socket by DDOSing it with lots of http requests, but memory does not appear to be an issue to me, as far as I saw it rarely decreased much, something else looks to cause crash.
    Also trying to use ping watchdog might be useful in case physical button works, but socket is not reachable through http. the same trying to disconnect socket from router if it's there. If it recovers, might indicate connection issue
  • #81 21027150
    p.kaczmarek2
    Moderator Smart Home
    Thank you, sure, so it's merged now:
    https://github.com/openshwprojects/OpenBK7231...mmit/e0f7506bf2455653c51af8b5d19d59c7876ebe42
    Can you submit your new "freeze" functions? Thanks!
    Helpful post? Buy me a coffee.
  • #82 21027185
    zdzihu123
    Level 11  
    Thank you guys, I installed .528 and will give it a shot tomorrow.

    EDIT: Just out of curiosity, is that amount or events registered by BL0937 (17390 changes in 20 min) normal? Or may it be the source of my problem?
    User interface monitoring energy data with information on skipped changes.
  • #83 21027408
    miegapele
    Level 15  
    That counter is fine, it records big numbers
  • #84 21029399
    zdzihu123
    Level 11  
    miegapele wrote:
    As for freezes, I saw one while playing with wifi networks to tests one bug, but that socket runs older version.
    It's also possible to freeze socket by DDOSing it with lots of http requests, but memory does not appear to be an issue to me, as far as I saw it rarely decreased much, something else looks to cause crash.
    Also trying to use ping watchdog might be useful in case physical button works, but socket is not reachable through http. the same trying to disconnect socket from router if it's there. If it recovers, might indicate connection issue

    As soon as I stopped messing with both settings page and webapp I was able to reach 48 hours uptime (and still counting). All I did was fully reflash the latest fw and stop interacting with the socket.

    If the crash happens again I'll investigate further.
  • #85 21029456
    p.kaczmarek2
    Moderator Smart Home
    That counter could be hidden, it's mostly only for developers and for testing. It's related to the system of MQTT publish data culling (so the same data is not send too often).
    Helpful post? Buy me a coffee.
  • #86 21030199
    zdzihu123
    Level 11  
    Today at 05:00 plug was properly restarted by watchdog:

    Quote:
    Reboot reason: BL_RST_SOFTWARE_WATCHDOG


    The only thing that's still off with BL602 seems to be internal temperature reported at 65-71c.
  • #87 21030314
    p.kaczmarek2
    Moderator Smart Home
    So we have a progress and watchdog works, that's very good! Now we still need to figure out what goes wrong... maybe we can try publishing the free memory size via MQTT to determine whether the issue is related to that?

    @zdzihu123 that internal temperature is not even calibrated, I am not sure if we can use it as a reliable measurement...
    Helpful post? Buy me a coffee.
  • #88 21032468
    flobuljeedom
    Level 7  
    Same here : Reboot reason: BL_RST_SOFTWARE_WATCHDOG
    All 5 devices are still available. Nice!
  • #89 21064323
    Raufaser
    Level 10  
    @p.kaczmarek2 From time to time the Watchdog triggers a reboot. When it does, the relay switches off. That is pretty annoying. Is there a way to retain the relay state when rebooting the socket?
  • #90 21064535
    p.kaczmarek2
    Moderator Smart Home
    Have you tried the classic retain approach, just setting -1 start state in Startup tab of OpenBeken?
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the BL602/BL0937 smart socket, specifically a model identified as SM-028_V1.3. Users share experiences related to flashing firmware, troubleshooting connectivity issues, and implementing features like energy monitoring. Key challenges include OTA (Over-The-Air) update reliability, GPIO pin configuration, and device freezing after extended use. Solutions discussed include the implementation of a watchdog timer to prevent device freezes, adjustments to the BL0937 driver, and various methods to retain relay states during reboots. Users also explore the physical disassembly of the socket for flashing and the differences between Zigbee and WiFi models.
Summary generated by the language model.
ADVERTISEMENT