U1 Fix Pack: firmware fixes for “Move out of range” after skipping an object, and the part fan switching early

I have read and understood all rules of the Innovation Fund Phase 2

on

I consent to my project information (username, project cover, summary, etc.) being publicly displayed for review and showcase

on

Username (for public display)

alandebortolo

Project name

U1 Fix Pack

Project URL

Project cover

Project Category

Firmware

Project Summary

U1 Fix Pack takes bugs that U1 owners reported on Snapmaker’s firmware repository and still open, reproduces each one on the real firmware code with no printer on the desk, fixes it with the smallest patch I could write, and keeps a regression test that fails on firmware 2.0.0 and passes with the patch, in CI on every push.

Demo video, 2.5 minutes. The terminal output is real, taken from the evidence files in the repo; the voice is synthetic.

https://designmaster-solutions.github.io/u1-fixpack/demo.mp4

How it reaches the U1. The tests build Snapmaker’s own u1-klipper at the commit of firmware 2.0.0 (93cb12f), with the data dictionaries of the U1’s boards, and run it in Klipper batch mode with the shipped printer.cfg and fluidd.cfg. A bug counts as reproduced only when the firmware’s own output shows it: an error it raises, a position it reports, the clock of a command it sends to the MCU. Patches are plain .patch files against 93cb12f, small enough to apply on a custom firmware build.

u1-klipper#22: skip an object, Pause, and Resume fails with “Move out of range”. The test prints a file through the firmware’s own virtual_sdcard and presses Pause and Resume through the same webhook handlers Moonraker calls, with the shipped INNER_PAUSE/INNER_RESUME macros. On 2.0.0 all 3 cases fail: Resume and the end-of-print G1 E30 stop with the error from the report (Move out of range on Y axis), and after a park inside the skipped object the firmware’s own position says X33 while the head is at X45, off by the skipped object’s offset. With the patch, 3 of 3 finish and the print ends complete. Three deliberately wrong versions of the patch fail the test, including my own first version, which survived a single-leg park but not the U1’s multi-leg one.

u1-klipper#18: the part fan switches 2 to 4 seconds before the head gets to the M106/M107. The test decodes the MCU command stream of the e0 board with Klipper’s parsedump.py and compares the clock of the fan PWM command with the clock of the first extruder step of the move that follows the command. On 2.0.0, M106 turns the fan on 4,366 ms before that step, and M107 turns it off 4,266 ms before it. With the patch, both land 10 ms after it, inside a 12 ms tolerance (two 5 ms PWM periods plus 2 ms for step and scheduling quantization). The fix is the one the reporter pointed to: G-code fan changes ride the motion queue, as in mainline Klipper, and the fan speed the firmware reports (what Fluidd shows) changes when the PWM is scheduled, not when the line is read. Three deliberately wrong versions fail the test: one that leaves M107 immediate, one whose reported speed never updates, and one whose reported speed jumps ahead of the queued move.

Credit. The people who filed the issues found and described these bugs: alternativniy on #18, who also traced the root cause and pointed to the fix mainline Klipper uses, and SwineFlew931 on #22. This project adds the printer-free reproduction, the patch and the regression test, and offers each patch upstream as a draft pull request on u1-klipper (#24 for #22 and #25 for #18, linked from the project README).

Still needed on 2.1.0. The 2.1.0 release Snapmaker opened on November 3 (u1-klipper #23, head 7e565c8) does not touch the four files these patches change, and both patches apply cleanly to it.

Limits, stated up front. Batch mode has no physics and no real sensors, so a patch proven here is a fix of the firmware logic, not yet a print. #8 (runout and resume replaces the measured flow calibration) is not in the pack: it needs a real runout sensor event, and faking that would prove nothing. I built it with AI coding assistance.

If you have a U1 and hit either bug, please try the patch on a custom firmware build and tell me what happens, right or wrong. A run on a physical U1 is the one thing I cannot do from here.

Open Source Status

Open Source

Please specify the open source license used by this project

GPL-3.0

Cash Fund or U1 Hardware Sponsorship

Cash Fund

Originality

Improvement / optimization based on an existing project

If based on an existing project — your independent contribution

Based on Snapmaker’s u1-klipper (GPL-3.0). My contribution: the printer-free reproductions on the shipped firmware, the patches, and the regression tests with red/green/mutant evidence and CI. The firmware runner is reused from my own U1 Dry Run (topic 43986).

Is it a paid project?

No

Update for firmware 2.1.0. Snapmaker released 2.1.0 on November 4 (u1-klipper 7ac453b). It does not touch the files these patches change, so I re-ran every check on it. On stock 2.1.0 both bugs are still there, with the same numbers as on 2.0.0: #22 stops with the same Move out of range on Y axis, and #18 still switches the fan on 4,366 ms and off 4,266 ms early. With the patches both pass, every deliberately wrong version still fails, and CI now runs everything on 2.0.0 and 2.1.0 (2.1.0 evidence). The same note is on the upstream PRs #24 and #25.

On the Extended firmware (corrected 5 November). For #18 on Extended, use #787 by alternativniy: the same motion-queue approach, opened there on 15 October and tested on printers by its author and other users. I missed it when I first offered both of my patches there, so I took my fan patch out: #869 now carries only the #22 fix. It touches only exclude_object.py, and on 2.1.0 plus the Extended patches the #22 test still goes from 3/3 fail to 3/3 pass. Its CI builds an installable 2.1.0-paxx12-pr869 image, so a U1 owner on Extended can try the #22 fix on the real printer.

Fan status and tool change (5 November). alternativniy reviewed the #18 patch on #25 and found what my PWM test could not see: the fan speed on the screen and in Fluidd changed when the move was planned, up to the queued move time before the fan itself. Fixed with his approach from #787: the status now reports a speed only once the printer clock reaches its PWM time, and the tool change restores the last requested speed, so a tool change right after two quick M106 still restores the last one. On the real firmware (2.0.0 and 2.1.0) the status reads 0.0 up to 1 ms before the PWM and 1.0 from it on; the previous version, and a tool change that reads the status, both fail the tests (test and evidence, commit on #25).

Update: for the fan on stock firmware, until the patch ships, tools/fan_m400.py adds an M400 before every part-fan M106/M107, as a slicer post-processing script. Measured on stock 2.0.0 and 2.1.0, with no patch: the fan now switches 240 ms before the move instead of 4,566 ms. Batch mode does not wait on M400, so the harness models the wait the printer does (the README explains how). The cost is a short stop at every part-fan change (37 to 73 in three example prints). I have not tried it on a real U1: if you do, please tell me whether the fan now switches where the slicer put it, either way.

Start line refused on some heads, confirmed on a physical U1 (5 November, topic 44046). Prints stopped at the first move with Move out of range on Y axis: 84.9 -0.09 2.0 (0003-0522-0001-0013) on heads 1, 3 and 4, never on 2. There is no firmware bug here, only a 1 mm margin: the firmware sets each head’s offset from the midpoint of the four calibrated base positions (get_center_base_position() in klippy/kinematics/extruder.py), so the lowest head sits at minus half the Y spread, and the stock start G-code draws the purge line at G0 X85 Y1, 1 mm above position_min: 0: a head more than 1 mm below the midpoint is sent under zero whenever it starts the print. On the real firmware code (2.0.0 and 2.1.0), a first head at Y -1.09 gives the reporter’s exact error and passes with the line at Y5 (test and evidence). The reporter then read the four offsets from Moonraker on the printer: Y -1.129, +1.129, -1.055 and -1.010. The three below -1.0 are exactly the heads that failed, and their Y5 edit has printed normally on all heads since (post 5). The profile change is proposed to Snapmaker as snapmaker-profiles#5 (the line at Y5 in the four U1 nozzle profiles), for OrcaSlicer#1143.

Continuation of the update comment above, which the forum no longer lets me edit.

Third bug in the pack: runout and resume wipe the measured flow factor (7 November, u1-klipper#8). mmunchinski polled the live and stored flow factor every 5 seconds through a runout: the detection changes nothing, and the moment the same spool is fed back the head’s measured 0.023951 becomes the default 0.02, live and in flow_calibrator.json, so it stays wrong for the rest of that print and for the next ones. On the firmware code the wipe happens twice: the RFID reader’s answer to the switch reading “present” again runs FLOW_RESET_K (an untagged spool reads as the empty card), and for an untagged spool Resume’s reload of the backed-up filament resets once more. The patch keeps the factor while paused when the spool is untagged or its tag matches the backed-up filament; a different filament’s tag, and a filament declared on the screen, still reset. On 2.0.0 and 2.1.0, through the firmware’s own runout, reload and Resume path: stock goes 0.023951 to 0.020000 at the feed, patched keeps 0.023951, a PETG tag still resets to 0.05, and three deliberately wrong versions fail (test and evidence, upstream draft #27). Not yet tried on a physical U1: the reporter’s 5-second poll is the check, and I have asked for it on the issue.

Hardware confirmation for the exclude_object fix (8 November, u1-klipper#22). abehrman, on a stock U1 (firmware 2.0.0.205), lost two prints to the same bug with no pause involved: after an object had been skipped, the tool change’s prime in the purge chute moved the head past Y max on one print and 222 mm across the part while extruding on the other, and his offline replay of the unmodified firmware predicts both bad targets. The offset exclude_object keeps is per extruder, so the stale one at a swap is the incoming tool’s, from the last time it printed the skipped object; the tool change and the chute park are manual_moves like the pause park, which is why the one check in the patch covers both. I added that path as the fourth regression case (a two-colour file with the U1 Orca profile’s tool-change G-code plus the chute prime, one of the second tool’s objects skipped): on stock 2.0.0 and 2.1.0 the fifth swap primes with gcode X82.7 Y230.5 while the head is at X92.7 Y300.5 and drags the head 70 mm in Y while extruding; with the patch all seven swaps stay in the chute and the print completes (test and evidence, upstream draft #24). Still not run on a physical U1 with the patch: I have asked him for the two files to replay them, and for a run if he ever builds the patched firmware.

Release v1.0.0 is up: Release v1.0.0 · DesignMaster-Solutions/u1-fixpack · GitHub (zip with the three .patch files, tools/fan_m400.py, the tests and the docs). From that zip, git apply patches/<file>.patch applies cleanly on a u1-klipper checkout of 2.0.0 (93cb12f) and of 2.1.0 (7ac453b), checked today. Project site: https://designmaster-solutions.github.io/u1-fixpack/. The first post can no longer be edited, so the links go here.

Update, 11 November: fourth patch, the lost prints replayed, release v1.1.0.

The two prints abehrman lost now run through the firmware as they were printed. He shared both G-code files in u1-klipper#22, unmodified, from a stock U1 on 2.0.0.205. Replayed on the firmware code of 2.0.0 and 2.1.0, with the Skips where his klippy.log puts them: stock reproduces both faults, the Move out of range on Y on one and the stray move across the part on the other; with the #22 patch both files print to the end. The replay is tests/issue22/replay_real.py, and its output for each run is in docs/evidence/issue-22/.

A second defect showed up on his 1 November file, and it has its own patch. With the drag fixed, U1 Dry Run still flagged 8 travels after a Skip that cross finished parts almost at print height: the first travel after a skipped object starts from where the head really is, so the slicer’s 0.4 mm ramped lift gets stretched over the whole distance. patches/0022b-exclude-object-lift-before-travel.patch goes on top of the #22 patch and lifts where the head is before it travels. On that file: 8 such travels on stock and with the #22 patch alone, 0 with both. Its test fails on stock and with the #22 patch alone, passes with it, and two deliberately wrong versions fail, on 2.0.0 and 2.1.0. Offered upstream as draft PR #28. This one is offline only: nobody has printed with it yet.

Release v1.1.0: Release v1.1.0 · DesignMaster-Solutions/u1-fixpack · GitHub (four .patch files; checked from the zip, all four apply with git apply on 2.0.0 93cb12f and 2.1.0 7ac453b, 0022 before 0022b). The project site now has a one-page summary with the video and the apply commands: U1 Fix Pack | u1-fixpack (the link in my previous post went to an empty page until today, sorry about that).

If you skip objects on multi-tool prints and can try a build with the two exclude_object patches on a U1, I would like to hear how it goes, either way.

Hi, could you also help me understand the difference between the following two projects of yours?

Hi Zoe, thanks for asking. Short version: Dry Run checks a print file and does not change the firmware; Fix Pack changes the firmware.

U1 Dry Run (Software, topic 43986) is a tool for anyone who slices for the U1. You give it a sliced .gcode or .gcode.3mf and it runs the file through Snapmaker’s unmodified u1-klipper code on a laptop, in CI, or by attaching the file to a GitHub issue. It answers two questions about that file: would the firmware stop the print (for example “Move out of range”), and would the nozzle travel across a surface that is already finished. The output is a report and an exit code. It fixes nothing; it tells you before you print.

U1 Fix Pack (Firmware, this topic) is a set of patches to u1-klipper itself, for bugs U1 owners reported on Snapmaker’s repository: the stale position after skipping an object (#22), the travel without lift after a skip, the part fan switching early (#18), and runout plus resume wiping the measured flow factor (#8). Each one comes with a test that fails on stock 2.0.0 and 2.1.0 and passes with the patch, and each is offered upstream as a pull request (#24, #28, #25, #27). What it delivers is .patch files for the firmware team and for people who build custom firmware. It does not check print files for users.

What they share: both run the real firmware in Klipper batch mode with the U1’s shipped config, so the way of running the firmware with no printer is the same. Fix Pack’s tests are built on it. They are separate repositories and each works without the other.

How they meet in practice: Dry Run finds, Fix Pack fixes. The fourth patch in this pack is the example: when I replayed abehrman’s lost print, Dry Run flagged 8 travels crossing finished parts after a Skip, and that became the lift-before-travel patch here.

Update, 16 November: five more fixes offered upstream since the last post.

Firmware (u1-klipper), both as draft pull requests with the patch and test in this repository:

  • Mixed nozzle sizes (#30, PR #31). With heads of different nozzle sizes, a file whose per-tool nozzle list matches the heads is refused at start with “nozzle diameter mismatch”: every used head is compared with the first entry of the list. The patch compares each used tool with its own entry. The test starts the job the way Moonraker does: 3 of 7 cases fail on stock 2.1.0, all pass with the patch, 4 deliberately wrong versions fail.
  • PCTG on the 0.2 nozzle (PR #32). PCTG is refused on a 0.2 mm nozzle because the PC prefix test meant for polycarbonate blends also matches PCTG. Three lines changed; the test calls the firmware’s own check, red on stock 2.1.0, green with the patch.

Moonraker on the U1 (u1-moonraker), three pull requests:

  • #11 (fixes #4): the shipped moonraker.conf trusts 192.0.0.0/8 where the private range 192.168.0.0/16 was meant.
  • #12 (fixes #2, open since August): a filament type with a space, such as "PLA Matte";PLA, was stored as PLA Matte";PLA. Quotes are now removed from each entry.
  • #13: since firmware 1.6.0, a file sliced by Cura or by any slicer outside the Orca family gets no metadata at all. Five new metadata keys only have a parser for Orca-style files, so the script stops with an error. On a Cura file: no metadata on main, metadata with the fix.

Limits. None of the five was run on a printer: I do not have a U1 with mixed nozzles, and the Moonraker fixes are checked on the firmware’s own scripts, not on the touchscreen. I do not know how the screen shows a file without metadata. All five are waiting for review.

The README lists every fix with its evidence: GitHub - DesignMaster-Solutions/u1-fixpack: Reproduce, fix and regression-test open bugs in the Snapmaker U1 firmware, with no printer · GitHub

Update, 18 November: three fixes offered to Snapmaker Orca this week.

These are on the slicer side, not the firmware. All three came from reports on this forum or on GitHub that had no answer yet.

  • Login loop on the Device tab with OctoPrint (#1088, PR #1218). When the printer has an API key set, the Device tab adds that key to every request of the page, including the login request itself. OctoPrint then does not keep the session, so the page goes back to the login screen. The fix leaves the key out of the login request only. Reproduced with OctoPrint 1.10.3, 1.11.7 and 2.0.1 in a WebKit view that injects the same script the slicer uses on macOS: the current script returns to the login screen on all three, the fixed one loads the interface on all three.
  • Printer on a non-default port (#1099, PR #1217). The connection test joins host and port without the :, so 203.0.113.7 with port 4410 becomes 203.0.113.74410. One line changed.
  • “Support interface speed setting is missing” (forum topic, PR #1213). The setting is hidden while supports are off, so it cannot be set in the profile beforehand. Regular Orca stopped hiding it; the PR does the same here.

Limits. I did not build the slicer for any of the three. The OctoPrint fix was run on macOS only, with a local OctoPrint and no printer attached; Windows and Linux use the same script but were not run. The port fix does not add the port field that was asked for in #1099, it only repairs the code that already accepts a port. All three are waiting for review.