logo elektroda
logo elektroda
X
logo elektroda

BL602 Smart Plug Boot Issue with OpenBL602_1.18.159+ and Specific Pin Configuration

blacksun2 126 12
ADVERTISEMENT
  • #1 21649170
    blacksun2
    Level 8  
    Hello,

    i found a Problem with Smart Plugs with BL602-Chip and Energy Metering.

    If you install OpenBL602_1.18.159 or any version after this version, the plug doesnt boot any more with this PIN-Config:

      "chip": "BL602",
      "board": "TODO",
      "flags": "134743044",
      "keywords": [
        "TODO",
        "TODO",
        "TODO"
      ],
      "pins": {
        "2": "Rel;1",
        "3": "BL0937CF1;0",
        "4": "Btn;1",
        "14": "BL0937CF;0",
        "20": "LED_n;1",
        "21": "BL0937SEL;0"
      },
    


    You have to boot into Safe-Mode of OBK by powering plug 5 times. Then you have to delete PIN-Settings manually. Command "clearIO" seems to be unknown in safe-mode.
    After that, device will boot again normally.
    You have to downgrade to 158 or below. Then you can re-config PIN-settings and the plug is working normally.
    I tested it with an empty autoexec.bat.

    It is reproducable.
  • ADVERTISEMENT
  • #2 21649218
    divadiow
    Level 35  
    That's troubling. 159 was the interrupt hal part1 merge

    Code: Text
    Log in, to see the code


    I can check with BL602 energy metering plug when home. It is currently on a version prior to that release

    Added after 1 [hours] 45 [minutes]:

    OK. I flashed plug to 1.18.95 earlier remotely for another test, but now I just OTAd to 1.18.158 - successful. OTA again to 1.18.163 and now the plug is not accessible :(

    I will go into safe mode when home then see if I can get more info about the issue safely from boot log on 3.3v. Or maybe it can be replicated on dev board.
  • ADVERTISEMENT
  • #3 21649335
    insmod
    Level 27  
    I imported your config onto a BL602 with 1.18.163 firmware, but without BL0937.
    It boots normally.
    As a temporary workaround, i would suggest "cleario" in early.bat, and then set up pins in autoexec and "startdriver bl0937".
    Not sure if it would work though.
  • #4 21649349
    divadiow
    Level 35  
    1.18.163 - with this autoexec on real plug it is not happy

    Code: Text
    Log in, to see the code
  • #5 21649352
    insmod
    Level 27  
    >>21649349
    cleario in early.bat, not in autoexec.bat
  • #7 21649376
    insmod
    Level 27  
    I tried counter_f on P14 - got
    [     14805][INFO: bl_irq.c: 352] Current task sp data:
    [     14805][INFO: bl_irq.c: 354] RA:2302f2d8, mstatus:80007800
    [     14805][INFO: bl_irq.c: 357] A0:420208e8 A1:00000001 A2:00000001 A3:8000003c A4:080823a0 A5:a5a5a5a5 A6:a5a5a5a5 A7:a5a5a5a5
    [     14805][INFO: bl_irq.c: 361] T0:80000000 T1:80000007 T2:a5a5a5a5 T3:a5a5a5a5 T4:a5a5a5a5 T5:a5a5a5a5 T6:a5a5a5a5
    [     14805][INFO: bl_irq.c: 364] S0:420208e8 S1:00000001 S2:40000000 S3:4200f79c S4:42010d0c S5:00000001 S6:00000002 S7:42010a28
    [     14805][INFO: bl_irq.c: 368] S8:42020898 S9:a5a5a5a5 S10:a5a5a5a5 S11:a5a5a5a5
    Exception Entry--->>>
    [     14805][INFO: bl_irq.c: 388] mcause 30000001, mepc deadbeee, mtval 00000000
    [     14805][INFO: bl_irq.c: 202] Exception code: 1
      msg: Instruction access fault
    
  • ADVERTISEMENT
  • #8 21649377
    divadiow
    Level 35  
    .bats as above. 3.3v boot

    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • #10 21649439
    blacksun2
    Level 8  
    insmod wrote:
    >>21649349
    cleario in early.bat


    This is an opportunity to ask something I've been wanting to ask for a long time. I've read about early.bat several times. The name suggests that it's executed earlier than autoexec.bat.
    Is there documentation for this early.bat? In the script examples, I've only ever found things for autoexec.bat. For an outsider who isn't directly involved in OBK development, it's difficult to understand what it can be used for.



    Regarding the actual problem:
    I also happened to notice this line in the logs:
    "Error:HTTP:http_fn_cmd_tool: len 0"

    I also only found this line on devices with BL602.
    I can't say whether it's related to the problem or whether the line indicates another issue.
    Since I have smart plugs with BL937, BK7231N, BL602, and LN881HKI, which, apart from the PIN configuration, aren't much different, I can't imagine where the message is coming from.
    All of my OBK devices serve only as sensors and actuators for HomeAssistant, integrated via MQTT.
  • #11 21649447
    insmod
    Level 27  
    >>21649439
    Early.bat should act like autoexec, but it is executed earlier that pins initialization and driver startup (autoexec is after).
    Plus, looking at the code, they are executed differently. autoexec is started using "startScript", while early using "exec". Don't remember what the differences are.
    "Error:HTTP:http_fn_cmd_tool: len 0" occurs when opening "/cmd_tool" or when pressing "Submit" on the same page when input string is empty.
  • #12 21649462
    blacksun2
    Level 8  
    insmod wrote:
    >>21649439
    ...looking at the code...Don't remember what the differences are.


    That's exactly what I meant. Without documentation, normal OBK users are better off staying away.

    insmod wrote:
    >>21649439
    when opening "/cmd_tool" or when pressing "Submit" on the same page when input string is empty.


    I'm not aware that I'd done either of these things.
    It can't really be caused by the blank lines in the autoexec.bat, since it's structured the same way regardless of whether the device uses a Beken, BL, or Lightning chip.
  • #13 21649473
    divadiow
    Level 35  
    insmod wrote:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1782

    works for me. no autoexec now


    BL602 Smart Plug Boot Issue with OpenBL602_1.18.159+ and Specific Pin Configuration

Topic summary

Smart plugs using the BL602 chip with energy metering experience boot failures when running OpenBL602 firmware version 1.18.159 or later with a specific pin configuration involving BL0937 components. The device fails to boot normally and requires entering OBK safe mode by power cycling the plug five times, followed by manual deletion of pin settings, as the "clearIO" command is unavailable in safe mode. Attempts to replicate and diagnose the issue revealed that firmware updates beyond 1.18.158 cause the plug to become inaccessible. A temporary workaround involves using "cleario" in early.bat before setting pin roles and starting the BL0937 driver in autoexec.bat, though this is not fully reliable. Debug logs indicate interrupt handling issues related to recent HAL interrupt code changes merged in version 1.18.159. A pull request addressing the problem has been submitted. The discussion also clarifies that early.bat executes before pin initialization and driver startup, unlike autoexec.bat, and that certain HTTP errors seen in logs are unrelated to the boot issue. The problem is specific to the BL602 platform and its interaction with BL0937 energy metering components under the new firmware interrupt handling scheme.
Summary generated by the language model.
ADVERTISEMENT