Repository navigation
Conversation
A host stall can leave a pin, fan or PWM LED update too close to or behind the MCU clock. Clamp the request time before sending it, including asynchronous fan updates and repeated requests. Preserve file-output timing and leave step scheduling unchanged. Based on djvalic's Kiln OS patch for issue Klipper3d#40, extended to cover GCodeRequestQueue.send_async_request(). djvalic/kiln-os#40 https://github.com/djvalic/kiln-os/blob/5a87445f9436467d54d20724fe367d5cfddde9e0/buildroot/package/klipper/0003-led-output_pin-send-late-after-a-host-stall.patch Reported and tested on AD5X by DIEHARDave (Kiln OS issue Klipper3d#40). Co-authored-by: djvalic <djvalic@users.noreply.github.com> Signed-off-by: Sergei Rozhkov <zmod@zmod.link>
738fefb to
5fc7411
Compare
|
As far as I understand, this moves any late request into the future, including requests that have an explicit -Maksim |
|
klipper-pr7447-ad5x-fan-diagnostics.zip Klipper already allows some deviation from the requested timestamps:
These adjustments serve different purposes from the proposed change, but they demonstrate that the original timestamp is not always an absolute execution deadline. Furthermore, an explicit klipper/klippy/extras/temperature_fan.py Lines 60 to 63 in e6c3e65 fan.set_speed().
I have personally encountered multiple "Timer too close" shutdowns on my AD5X during prints with frequent part cooling fan speed changes. I recovered the original logs and attached an archive containing two actual shutdowns, a separate diagnostic test, and a detailed explanation. During the investigation, we deliberately executed a sequence of M106 commands followed by M112 to obtain MCU queue dumps and identify the fan's OID. This allowed us to correlate the PWM commands with the requested fan speeds. In one of the original shutdowns, a fan PWM command was already approximately 25 ms overdue before it was sent to the MCU. Eliminating every possible source of host latency is difficult, particularly on resource-constrained hardware. Even if motion scheduling remains valid, a late fan update can currently cause an MCU shutdown. I understand the concern about preserving synchronization for generic output pins. However, for a part cooling fan or an LED, I believe that a slightly delayed update is preferable to an MCU shutdown and the loss of an otherwise valid print. The proposed change does not directly adjust timestamps with sufficient scheduling margin or modify step scheduling. Would restricting this behavior to fans and PWM LEDs be acceptable if changing the behavior of generic output pins is considered undesirable? |
A host scheduling stall can cause fan, output pin, and PWM LED commands to be sent with timestamps that are too close to or already behind the MCU clock, resulting in a "Timer too close" shutdown.
This issue was observed on real AD5X hardware:
djvalic/kiln-os#40
Clamp the scheduled time to the estimated MCU print time plus the minimum scheduling interval.
This change covers:
Requests with sufficient scheduling margin, explicit file-output timestamps, and step scheduling remain unchanged.
Based on the original Kiln OS patch by @djvalic, extended in Z-Mod to cover asynchronous requests.
Thanks to @DIEHARDave for reporting the issue and testing on real hardware.