logo elektroda
logo elektroda
X
logo elektroda

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

blacksun2 624 12
ADVERTISEMENT
  • #1 21649170
    blacksun2
    Level 8  
    Posts: 59
    Rate: 1
    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 38  
    Posts: 4859
    Help: 424
    Rate: 860
    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 31  
    Posts: 1353
    Help: 160
    Rate: 425
    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 38  
    Posts: 4859
    Help: 424
    Rate: 860
    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 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21649349
    cleario in early.bat, not in autoexec.bat
  • ADVERTISEMENT
  • #6 21649361
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    oops.

    Screenshot of an editor showing editing of early.bat file with a typo in the word clear.

    no joy still
  • #7 21649376
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    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
    
  • #8 21649377
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    .bats as above. 3.3v boot

    Code: Text
    Log in, to see the code
  • #10 21649439
    blacksun2
    Level 8  
    Posts: 59
    Rate: 1
    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.
  • ADVERTISEMENT
  • #11 21649447
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>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  
    Posts: 59
    Rate: 1
    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 38  
    Posts: 4859
    Help: 424
    Rate: 860
    insmod wrote:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1782

    works for me. no autoexec now


    Screenshot of the OpenBL602 device interface showing OFF status and detailed device statistics.

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.
Generated by the language model.

FAQ

TL;DR: BL602 smart plugs with energy metering may fail to boot after OpenBL602_1.18.159+ when using the shown BL0937 pin map; Safe Mode requires 5 power cycles; “It is reproducable.” [Elektroda, blacksun2, post #21649170]

Why it matters:** This FAQ helps OBK/OpenBL602 users quickly recover bricked BL602 smart plugs and apply the confirmed fix.

Quick Facts

What exactly is the BL602 smart plug boot issue after 1.18.159?

When OpenBL602_1.18.159 or newer is used with a BL0937 energy-meter pin map (2,3,14,20,21), the plug fails to boot. The device recovers only after clearing I/O settings and reverting to an earlier build. “It is reproducable.” [Elektroda, blacksun2, post #21649170]

How do I safely recover a BL602 plug stuck in a boot loop?

Use Safe Mode and clear pin settings, then downgrade. 1) Power the plug on and off five times to enter Safe Mode. 2) Manually remove stored PIN settings. 3) Flash 1.18.158 or older, reboot. Reconfigure pins afterwards. [Elektroda, blacksun2, post #21649170]

Is there a permanent fix so I can stay on newer firmware?

Yes. A code patch submitted as PR #1782 resolved the crash on real hardware; the reporter confirmed, “works for me,” with no custom autoexec needed. Upgrade to a build that includes this PR. [Elektroda, divadiow, post #21649473]

Does the issue show up during OTA from 1.18.158 to 1.18.163?

Yes. A test device updated OTA to 1.18.163 became inaccessible until the owner used Safe Mode for diagnosis. This confirmed the regression window and reproduced the failure. [Elektroda, divadiow, post #21649218]

Where should I use the cleario command—early.bat or autoexec.bat?

Use cleario in early.bat. early.bat runs before pin initialization and driver startup, so it clears conflicting pin roles before they apply. Placing it in autoexec.bat is too late. [Elektroda, insmod, post #21649447]

I tried cleario in early.bat, but it still crashes—what then?

Some units still hit an “Instruction access fault” on 1.18.163, even with scripts adjusted. In this edge case, apply the patched build (PR #1782) or temporarily downgrade, then reconfigure pins. [Elektroda, divadiow, post #21649377]

What log symptoms indicate this firmware regression?

Serial logs show repeated reboots with “mcause 30000001” and “Instruction access fault.” Another clue is the device becoming unreachable after OTA, despite valid Wi‑Fi init messages. [Elektroda, divadiow, post #21649377]

What is early.bat and how is it different from autoexec.bat?

early.bat executes before pins and drivers initialize; autoexec.bat runs after. early.bat uses exec, autoexec uses startScript. Use early.bat to clear or set prerequisites that must precede pin roles or driver start. [Elektroda, insmod, post #21649447]

What does the HTTP error “http_fn_cmd_tool: len 0” mean on BL602?

It appears when you open /cmd_tool or press Submit on that page with an empty input field. It’s not firmware‑fatal and may show even if you didn’t intend to use the page. [Elektroda, insmod, post #21649447]

Can I reproduce the failure without an attached BL0937?

Importing the config without an actual BL0937 did not reproduce the boot failure on a tester’s board. The hardware interaction matters, so tests without the meter may pass. [Elektroda, insmod, post #21649335]

What is OpenBeken/OpenBL602 in this context?

OpenBeken (OpenBL602 is its BL602 build) is community firmware used to control smart plugs and sensors across BK, BL, and Lightning chips, often via MQTT and Home Assistant. [Elektroda, blacksun2, post #21649439]

Do I need an autoexec.bat after the fix?

The user who validated PR #1782 reported the plug works without any custom autoexec. This suggests the core regression was inside the HAL/interrupt path, now patched. [Elektroda, divadiow, post #21649473]

What’s a quick way to verify the device fully boots?

Watch the serial log for “Boot complete time reached (5 seconds)” and for Wi‑Fi state transitions to idle or connecting. Repeated faults indicate regression remains. [Elektroda, divadiow, post #21649377]

How do I set pins and start BL0937 reliably after recovery?

After flashing a fixed or older build, set pin roles, then start the BL0937 driver. Example roles: 2=Rel;1, 3=BL0937CF1;0, 14=BL0937CF;0, 20=LED_n;1, 21=BL0937SEL;0. Start driver last. [Elektroda, blacksun2, post #21649170]

Is there an expert recommendation on triage order?

Yes. “Early.bat should act like autoexec, but it is executed earlier…” Prioritize early.bat for cleanup, then confirm logs, then upgrade to the patched build. [Elektroda, insmod, post #21649447]

Does the fix relate to interrupts/HAL changes?

The regression aligned with interrupt HAL refactors around 1.18.159; the fix landed via PR #1782 and restored stability on real hardware. “works for me.” [Elektroda, divadiow, post #21649473]
Generated by the language model.
ADVERTISEMENT