logo elektroda
logo elektroda
X
logo elektroda

OpenLN882H upgrade from 1.17.506 to 1.17.515 makes LSPA9 Smart Plug unresponsive

silvestro_gatto 5961 66
Best answers

Why does upgrading OpenLN882H from 1.17.506 to 1.17.515 make my LSPA9 smart plug become unresponsive, and how can I fix it?

The freeze is caused by the NTP/time conversion code on LN882H, not by the plug template or the LED drivers: starting NTP on affected builds leads to bad `gmtime()` usage with a `g_ntpTime` value that is the wrong type/size for platforms where `time_t` is 64-bit, which can make the device behave erratically or hang [#21018282] [#21019583] A temporary workaround was to cast through a real `time_t` variable before calling `gmtime()`, and that immediately stopped the freeze in testing [#21018282] The proper fix was then merged by changing the NTP time handling to use `time_t` consistently, including related NTP event and JSON/httpserver paths [#21020171] After that fix, the reporter confirmed OpenLN882H_1.17.521 was stable again and settings were preserved [#21020355]
Generated by the language model.
ADVERTISEMENT
  • #61 21020825
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14506
    Help: 651
    Rate: 12506
    Nice, since you'r at it, maybe also change ntp_eventsTime type to time_t?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #62 21021083
    max4elektroda
    Level 24  
    Posts: 746
    Help: 48
    Rate: 184
    O.k., I added a second version of drv_ntp_events.c.
    No more casting for "gmtime", but now for the calculations ;-)

    Please note, since I don't use NTP, I could only test, if it compiles...
  • ADVERTISEMENT
  • #63 21021118
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14506
    Help: 651
    Rate: 12506
    The W800 does not compile:
    
    ./bin/build/w800/lib/libuser.a(json_interface.o): In function `$t':
    (.text.JSON_ProcessCommandReply+0x916): undefined reference to `NTP_IsTimeSynced'
    ./bin/build/w800/lib/libuser.a(json_interface.o): In function `$t':
    (.text.JSON_ProcessCommandReply+0x916): relocation truncated to fit: R_CKCORE_PCREL_IMM26BY2 against undefined symbol `NTP_IsTimeSynced'
    

    I guess this may be because you need to respect OBK_DISABLE_ALL_DRIVERS define which, if enabled, means that NTP_IsTimeSynced is not present in the build.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #64 21021199
    max4elektroda
    Level 24  
    Posts: 746
    Help: 48
    Rate: 184
    I will fix it tomorrow, thanks for the advice!
  • #65 21021966
    max4elektroda
    Level 24  
    Posts: 746
    Help: 48
    Rate: 184

    Uploaded fixed version, it compiles now for all platforms.
  • ADVERTISEMENT
  • #66 21021980
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14506
    Help: 651
    Rate: 12506
    Nice, but I am not sure about the if conditional for StartupUTC - what happens with Tasmota control if that field is missing from JSON?
    Maybe change if to work in such a way that if value negative would be to happen, then plug 0 so it prints 1970-01-01 etc etc? So just a clamp, but still add JSON key.
    Helpful post? Buy me a coffee.
  • #67 21022036
    max4elektroda
    Level 24  
    Posts: 746
    Help: 48
    Rate: 184
    Sure, fair point. Just changed this code once more.

    I was already asking myself why there are so many "fake entries" in this code (always reporting fixed strings but actual values ...) ;-)

Topic summary

✨ The discussion revolves around the Elivo LSPA9 Smart Plug, which became unresponsive after an upgrade from OpenLN882H version 1.17.506 to 1.17.515. Users reported that the device initially functioned well with energy monitoring but encountered issues post-update, including slow web interface access and eventual unresponsiveness. Serial logs indicated recurring hardware errors. Various users suggested testing intermediate firmware versions to identify the problematic update, leading to the discovery that version 1.17.513 caused the issues. A workaround was proposed by disabling certain drivers, and a fix was implemented in subsequent versions, restoring functionality and stability to the device. The final resolution involved modifying the handling of time synchronization to prevent the device from freezing.
Generated by the language model.

FAQ

TL;DR: For OpenLN882H users with LN882H/WL2S plugs, the freeze after 20–30 seconds was traced to NTP, not the plug hardware. As one developer concluded, "this is the solution": a time_t/gmtime mismatch broke LN882H and BL602 builds from 1.17.513 onward until the fix landed in 1.17.521. [#21019532]

Why it matters: This thread shows how to isolate a firmware regression quickly, avoid false leads like flash size or LED support, and restore stable NTP, web UI, and saved settings on LN882H smart plugs.

Version / build Observed result on affected LN882H plugs Notes
1.17.506–1.17.512 Stable No reported serial errors
1.17.513 First failing release Device loses settings and freezes
1.17.517 Still failing Stack-size change did not solve it
PR 1141 test build Working workaround NTP no longer froze device
1.17.521 Stable fix confirmed Settings restored, no serial errors

Key insight: The visible trigger was startDriver NTP, but the root cause was a cross-platform time bug: LN882H and BL602 used 64-bit time_t, while code treated NTP time like a 32-bit integer pointer. [#21020355]

Quick Facts

  • The affected plug used an LN882HKI on a WL2S module with a BL0937 energy-monitor chip, and its startup command was backlog startDriver NTP; ntp_setServer 216.239.35.8; ntp_timeZoneOfs 1. [#21017596]
  • Regression testing narrowed the break to OpenLN882H 1.17.513, built Mar 19 2024 09:10:15; versions 1.17.507 through 1.17.512 stayed fully functional on the same hardware. [#21017325]
  • On one failing unit, free memory dropped from about 90,912 bytes to 1,200 bytes immediately after NTP logged local time, which matched the hang window. [#21018244]
  • The thread established a platform split: BK7231 used 32-bit time_t, while LN882H and BL602 used 64-bit time_t, explaining why BK7231 kept working with the same code path. [#21019583]

Why does upgrading an Elivo LSPA9 smart plug with LN882HKI from OpenLN882H 1.17.506 to 1.17.513 or later make the device unresponsive after 20 to 30 seconds?

Because 1.17.513 exposed an NTP time-handling bug on LN882H, not a template or hardware fault. The affected plug booted, then froze after about 20–30 seconds, often after starting NTP, while 1.17.506 through 1.17.512 stayed stable on the same WL2S module. The final diagnosis was a time_t size mismatch in code that passed NTP time to gmtime, which corrupted behavior on LN882H. [#21019532]

How can I narrow down which OpenLN882H release introduced instability on a WL2S-based LN882H smart plug?

Use sequential downgrade or upgrade testing until one version fails. 1. Flash known-good firmware, such as 1.17.506 or 1.17.512. 2. Test each release in order, checking web UI, saved template, and serial log. 3. Stop at the first build that shows freezes or [WLIB_E] errors. In this case, versions 1.17.507 to 1.17.512 worked, and 1.17.513 was the first failing release. [#21017325]

What do the serial log errors "[WLIB_E]HwEr:EC = 16" and "[WLIB_E]HwEr:EC = 12" mean on OpenLN882H devices?

They indicate low-level Wi-Fi or system error conditions seen during the freeze, but the thread did not assign them a final standalone meaning. On affected LN882H builds, they appeared repeatedly with rsp wait timeout messages and loss of responsiveness. After the NTP time fix was tested, those errors disappeared on the same hardware, so they were treated as symptoms of the deeper time bug rather than the root cause. [#21018252]

How does starting the NTP driver trigger freezes on some LN882H plugs running OpenLN882H 1.17.513 to 1.17.517?

Starting NTP triggers the buggy code path that converts NTP time to local time. Users reproduced the hang with startDriver NTP, and one log showed the device becoming unresponsive right after Info:NTP:Local Time, with free memory collapsing to 1,200 bytes. The plug could still sometimes ping or print temperature logs, but the normal web interface stalled or froze. [#21018244]

Which change in OpenLN882H 1.17.513 was linked to the LSPA9 smart plug freeze: LED, WEMO, HUE, or something else?

The first suspicious change was the 1.17.513 commit that enabled LED, WEMO, and HUE support, but that was not the true root cause. Tests showed that enabling LED-related code correlated with the crash, while WEMO and HUE alone did not. Later debugging proved the real issue was time handling in NTP on 64-bit time_t platforms, so the driver change only exposed the bug. [#21018282]

What is the WL2S module in LN882H smart plugs, and how is it used for UART debugging and reflashing?

"WL2S" is a Wi-Fi module board that carries the LN882H chip, exposes serial access, and lets developers remove it from the mains plug for safer bench testing, UART logging, and reflashing. In this thread, the module was desoldered from the plug, connected to a UART-to-TTL adapter, and used to capture boot logs and test multiple firmware versions. [#21016559]

What is the BL0937 energy monitor chip, and how does OpenLN882H use it in smart plugs like the Elivo LSPA9?

"BL0937" is an energy-monitoring IC that measures mains parameters for smart plugs, using dedicated CF, CF1, and SEL signal pins so firmware can calculate values like voltage, current, and power. The shared LSPA9 template mapped BL0937 functions to pins 7, 12, and 19, and the plug reported energy data correctly on stable firmware. [#21016933]

How do I test whether NTP, SSDP, WEMO, HUE, or LED drivers are causing crashes on an LN882H device?

Disable or isolate one feature at a time and test with the same startup flow. 1. Boot with an empty StartupCommand. 2. Start one driver manually, such as startDriver NTP. 3. Compare behavior across custom builds that enable only LED, only WEMO/HUE, or none. In this thread, NTP consistently triggered the freeze, LED-related code initially looked guilty, and later testing traced the failure to time conversion, not WEMO or HUE. [#21017655]

Why did a gmtime and time_t mismatch break NTP on LN882H and BL602 while BK7231 kept working?

Because LN882H and BL602 used 64-bit time_t, but the code passed a 32-bit global integer as if it were a time_t*. That meant gmtime read extra, undefined bytes from RAM on those platforms. BK7231 kept working because its time_t was still 32-bit, so the bad cast did not immediately corrupt the value. [#21019583]

What does the TimeSize command show on LN882H, BL602, and BK7231, and how can it help diagnose time_t-related bugs?

It shows the platform-dependent size of time-related types, which helps confirm whether pointer casts are unsafe. The thread used TimeSize to verify that LN882H and BL602 had 64-bit time_t, while BK7231 had 32-bit time_t. That one command explained why the same NTP code failed on LN882H and BL602 but initially behaved on BK7231. [#21019555]

OpenLN882H on 1MB vs 2MB LN882H flash: how do flash size differences affect config storage offsets and stability?

Flash size was investigated, but this thread did not prove it caused the LSPA9 freeze. One developer noted the config offset sat above the 1 MB mark, which could break saves on true 1 MB devices, while the reported chip marking LN882HKI suggested 2 MB flash. Later tests solved the freeze with a time fix, so flash size remained a separate edge case, not the confirmed cause here. [#21017584]

How can I safely capture serial logs from a mains-powered smart plug without risking contact with live wiring?

Remove the Wi-Fi module and debug it on the bench instead of probing a live plug. One participant explicitly avoided serial investigation on a powered plug because plug ground could connect to a live wire. In this thread, the safer method was to desolder the WL2S module, connect it to a UART-to-TTL adapter, and test firmware off-board. [#21017013]

What startup command should I use to enable NTP on OpenLN882H, and how can I verify it is not causing hangs?

Use backlog startDriver NTP; ntp_setServer 216.239.35.8; ntp_timeZoneOfs 1 and then watch logs for stable time sync. A healthy run prints NTP initialization, Unix time, and a normal local date like 2024/03/24 22:18:36 without freezing. If the web UI hangs or [WLIB_E] errors appear immediately after NTP starts, your build still has the bug. [#21018404]

Why would the web interface freeze while ping and some log output still continue after starting NTP on an LN882H plug?

Because the failure did not always hard-crash the whole device. In one reproduced case, after NTP started via wget, the plug still answered ping and kept printing TEMP lines, but regular Info:MAIN logging stopped and the normal web interface became unusable. That pattern pointed to severe runtime corruption or starvation in specific code paths, not a total power loss. [#21018147]

Did anyone get OpenLN882H working reliably on a 1MB LN882H device, and what flash partition or config changes are needed?

No confirmed working 1 MB LN882H setup was documented in this thread. The discussion only raised the concern that the current config-save offset sits beyond 1 MB, which could overlap or wrap on smaller flash parts. The tested LSPA9 hardware used LN882HKI, was treated as 2 MB, and was fully stable again on 1.17.521 after the time fix. [#21020355]
Generated by the language model.
ADVERTISEMENT