Fix ESP8266 Exception crash-loop on PZEM/Modbus energy monitors (regression from 15.5.0)#24886
Open
gionag wants to merge 1 commit into
Open
Fix ESP8266 Exception crash-loop on PZEM/Modbus energy monitors (regression from 15.5.0)#24886gionag wants to merge 1 commit into
gionag wants to merge 1 commit into
Conversation
Collaborator
|
Thanks, good for me. @arendst ok to merge? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since v15.5.0, ESP8266 devices with a PZEM (PZEM-004T v3 / PZEM-016) or any Modbus energy monitor crash-loop a few seconds after boot with
Exception (9)(load/store alignment) once the driver starts transmitting. It reboots roughly every ~10s (right at the end of the PZEM stabilize window), BootCount keeps climbing, and it never reads. 15.4.0 is fine.Bisected to #24726 ("Add RX Enable GPIO support for Modbus", commit 0c85dbc) in
TasmotaModbus.cpp. That change added an RX-enable block toSend(). ThedigitalWrites are guarded byif (mb_rx_enable_pin > -1), but thedelay(10)was left outside the guard:So every Modbus transmit now hits an unconditional
delay(10), even though almost nobody has an RX-enable pin configured. On ESP8266 thatdelay()yields into the SDK mid-send and faults — the crash EPC (0x40105f68) is in IRAM. It's ESP8266-only (ESP32 is unaffected) and reproduces with no PZEM even attached, just by assigning aPZEM0XX Txpin (confirmed by a second user in #24883).Fix
Move the
delay(10)inside the existingmb_rx_enable_pin > -1guard. For any setup without an RX-enable pin — i.e. every current PZEM/Modbus user — this makesSend()byte-for-byte identical to 15.4.0. RX-enable timing for people who do set that pin is unchanged.Verified
Built the standard
tasmotaenv (ESP8266 core 2.7.8) with this change and OTA-flashed it to two boards that crash-loop on stock 15.5.0:Both went from Exception crash-loops (uptime never past ~10s) to fully stable — uptime climbing for minutes, RestartReason "Software/System restart", reading voltage/current/power normally (~232 V / ~900 W / addr 1). No change to RX-enable behaviour for setups that use it.
Related issue: fixes #24883
Checklist: