Repository navigation
Description
Firmware version
v1.6.0-paxx12-22 (also reported on 2.0.0 Extended in comments below)
Firmware source
Third-party provider
Third-party firmware source
https://github.com/paxx12-snapmaker-u1/SnapmakerU1-Extended-Firmware
Was the configuration modified?
Yes
What configuration changes were made?
Settings enabled via paxx12 Extended Firmware "Tweaks":
- TMC AutoTune: enabled (TMC2240 driver tuning)
- TMC Reduced Current: enabled (X/Y run current lowered from 1.2A to 1.0A)
- Reduced Z axis acceleration (max_z_accel) to 200
None of these touch fan or G-code timing logic. The bug is in the stock klippy/extras/fan.py code, which is identical in Snapmaker/u1-klipper main.
Was the source code modified?
No
What source code changes were made?
N/A — no changes by me.
Note: the Extended firmware applies upstream Klipper backport patches (toolhead.py, resonance_tester.py, aht10.py, temperature_combined.py). None of them modify fan.py, fan_generic.py, gcode_move.py or virtual_sdcard.py.
How can the issue be reproduced?
- Run this G-code (minimal test, no extrusion). The fan should be OFF on the X10,Y10 → X140,Y10 edge and ON on the other two edges:
G28
G90
G1 F2000
M106 S0
G1 X10 Y10
G1 X140 Y10 ; fan should be OFF on this edge
M106 S255
G1 X140 Y140 ; fan should be ON from here
G1 X10 Y140 ; fan ON
; repeat block several times- Watch where the part cooling fan actually switches on and off, and the fan value on the printer screen.
Inserting M400 before each M106 makes the fan switch at the correct position, which confirms it is a timing issue (unusable for real prints because motion stalls).
Root cause: klippy/extras/fan.py, Fan.set_speed_from_command():
def set_speed_from_command(self, value, control_enable=True):
system_time = self.reactor.monotonic()
system_time += FAN_MIN_TIME
print_time = self.get_mcu().estimated_print_time(system_time)
self.set_speed(print_time, value, control_enable)M106/M107 (and SET_FAN_SPEED in fan_generic.py) schedule the fan change at "now + 100 ms", i.e. when the G-code line is parsed, not at the print time of the preceding move. Klipper keeps up to BUFFER_TIME_HIGH = 2.0 s of moves queued, so the fan switches 2–4 s before the toolhead reaches the command. At F2000 (~33 mm/s) that is roughly one full 130 mm edge.
Upstream Klipper schedules G-code fan changes through the motion queue (toolhead.register_lookahead_callback()); in this repo the same pattern is still used by output_pin.py (SET_PIN), led.py and pwm_tool.py.
What a fix needs to cover (simply changing set_speed_from_command() is not enough and is risky):
- Only the G-code commands (
M106,M107,SET_FAN_SPEED) should go throughregister_lookahead_callback().set_speed_from_command()is also used by webhooks and bySWITCH_EXTRUDER(kinematics/extruder.py), which drives the fan PWM to detect toolhead gripping; those callers should keep the immediate timing. SAVE_GCODE_STATE(gcode_move.py, used byPAUSE) and the power loss fan record (virtual_sdcard.py,record_pl_print_fan_env) read the fan speed. With a queued fan change they can save a stale value (e.g.PAUSEright afterM106→ fan not restored on resume), so they should read the requested speed including queued changes.Fan.get_status()['speed']should report a speed only once its print time is reached; otherwise the fan value on the printer screen and in Fluidd runs ahead of the real fan.
Fix tested on hardware (applies to stock fan.py, fan_generic.py, virtual_sdcard.py):
paxx12-snapmaker-u1/SnapmakerU1-Extended-Firmware#787
Patch file: overlays/firmware-extended/11-patch-klipper/patches/home/lava/klipper/09_fan_gcode_sync.patch
Core of the change:
def set_speed_from_gcode(self, value):
# Apply at the print time of the last queued move so the change
# happens when the toolhead reaches the command
self.pending_values.append(value)
def apply_speed(print_time):
self.pending_values.pop(0)
self.set_speed(print_time, value)
toolhead = self.printer.lookup_object('toolhead')
toolhead.register_lookahead_callback(apply_speed)Tested on U1: square test above, tool changes T0→T1→T0 with fan on/off, M106 P2 / SET_FAN_SPEED FAN=cavity_fan, pause/resume, printer screen fan value.
What was the actual result?
The part cooling fan turns ON roughly one edge too early (at the X10,Y10 corner instead of X140,Y10) and turns OFF too early as well. The fan value on the printer screen changes early too. In real prints, cooling changes (first layers, bridges, overhangs, per-feature fan speeds from the slicer) are applied 2–4 seconds before the corresponding moves.
What was the expected result?
The fan speed change takes effect exactly when the toolhead reaches the M106/M107 command in the G-code stream, as in upstream Klipper (synchronized with the motion queue), and the printer screen shows the speed the fan actually has.
Log files
Test G-code is included in "How can the issue be reproduced?". The issue is a timing/design bug, so klippy.log shows no errors; I can attach it on request.
Activity
new-indy commentedon Oct 15, 2026
The same problem.
QuakerQ commentedon Oct 15, 2026
I have the same problem. Paxx2.0
paxx12 commentedon Oct 17, 2026
@alternativniy Is this present in Stock 2.0.0 firmware?
alternativniy commentedon Oct 17, 2026
Yes, this present in all firmware versions
alternativniy commentedon Oct 17, 2026
I'll just point out that my AI-based analysis showed that this issue is present in all versions. Also, people in the Russian U1 chat reported this to everyone—they were the first to notice the bug there.
alandebortolo commentedon Nov 4, 2026
I put the motion-queue approach from mainline Klipper into draft PR #25: G-code M106/M107 and SET_FAN_SPEED are scheduled with the move that follows, while webhook and tool-change fan calls stay immediate. It comes with a printer-free test that decodes the e0 MCU stream on 93cb12f. Stock: the fan PWM goes out 4,366 ms (on) and 4,266 ms (off) before the first extruder step of the following move. With the patch: 10 ms after it, on both edges.
I don't have a U1, so this hasn't run on hardware yet. If anyone here builds custom firmware and can try it, I'd like to know whether the fan now switches where the M106/M107 is. It applies cleanly on 2.0.0 and on the 2.1.0 PR (#23).
alandebortolo commentedon Nov 4, 2026
For anyone on the Extended firmware: the same patch is now proposed there as
09in its Klipper overlay, in paxx12-snapmaker-u1/SnapmakerU1-Extended-Firmware#869, and that pull request's build attaches a flashable firmware.On the Extended
developbuild (2.1.0 plus its own Klipper patches) my batch-mode test still shows the fan switching on 4366 ms and off 4266 ms before the move, and 10 ms after the step with the patch. If you can run the minimal G-code from the top of this issue on that build, please say whether the fan now switches at the right edge, right or wrong.alternativniy commentedon Nov 5, 2026
@alandebortolo I deliberately didn't open a PR here so that the developers at Snapmaker could fix this bug themselves and test it on their own.
As I understand it, this is also pointless, since this repository isn't moderated. It's just a mirror of their private Git repository—nothing more.
alandebortolo commentedon Nov 5, 2026
@alternativniy Thanks, that makes sense; I didn't know this repository is only a mirror. I'll leave #25 as a draft for reference and won't push it further. For the Extended firmware I now point people to your paxx12-snapmaker-u1/SnapmakerU1-Extended-Firmware#787, which came first and was tested on a U1, and I took the fan patch out of my pull request there.
alternativniy commentedon Nov 5, 2026
@alandebortolo As for the idea that this repository is just a mirror, that's just my guess. I might be wrong)