Skip to content

About

Reproduce, fix and regression-test open bugs in the Snapmaker U1 firmware, with no printer

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

61 Commits

Folders and files

Repository files navigation

U1 Fix Pack

Reproduce, fix and regression-test open bugs in Snapmaker's U1 firmware (Snapmaker/u1-klipper), on the real firmware code, with no printer on the desk.

Entered in the Snapmaker Innovation Fund, Phase 2: U1 Fix Pack on the Snapmaker forum. If you try a patch on a physical U1, please report it there or in an issue here, either way.

Demo video, 2.5 minutes (real firmware output from docs/evidence/, synthetic voice; script in video/demo.json): https://designmaster-solutions.github.io/u1-fixpack/demo.mp4

Each bug in this pack gets three things:

  1. A reproduction that fails on the shipped firmware. The test runs Snapmaker's own u1-klipper (pinned commit 93cb12f, firmware 2.0.0) in Klipper batch mode with the U1's shipped printer.cfg and fluidd.cfg, and asserts what the firmware actually does, from its own output.
  2. The smallest patch that fixes it, as a .patch file against 93cb12f.
  3. The same test passing with the patch, in CI on every push.

The patches are offered upstream as pull requests, and are small enough to apply on top of custom firmware builds.

Bugs in scope

Issue What U1 owners see Status
u1-klipper#22 Skip an object, then pause or change tool: the next E-only move carries the skipped object's XY, so Resume fails with "Move out of range" or the prime in the chute drags the head across the bed patched; red on 93cb12f and 7ac453b, green with the patch, 3 mutants red, in a full print with the real Pause/Resume macros and with the U1 tool-change sequence (tests/test_issue22.py, 4 cases; the tool-change one is abehrman's report of two failed prints on stock 2.0.0.205); the two print files he lost replayed unmodified through the firmware (tests/issue22/replay_real.py, docs/evidence/issue-22/real-print-*.txt): stock reproduces both faults on 93cb12f and 7ac453b, the same Y 337.635 rejection and the same stray target X28.113 Y202.421, patched prints both to the end; upstream draft PR #24
found with U1 Dry Run on the second #22 file, no upstream issue yet Skip an object: the first travel after it starts from where the head really is, and the slicer's 0.4 mm ramped lift is stretched over the whole distance, so the nozzle crosses finished parts almost at print height (8 such travels on that file, with or without the #22 patch) patched by patches/0022b-exclude-object-lift-before-travel.patch on top of the #22 patch: lift where the head is, then travel; tests/test_issue22travel.py red on stock and with the #22 patch alone, green with it, 2 mutants red, on 93cb12f and 7ac453b; the real file through U1 Dry Run with both patches: no drag, no scar (docs/evidence/issue-22/dryrun-real-print-B-patched-0022b-2.1.0.txt); offline only, not printed
u1-klipper#18 Part cooling fan switches 2-4 s before the toolhead reaches the M106/M107 patch and red/green/mutant proof for both edges (M106 on and M107 off PWM clocks, plus fan status timed to the PWM and the speed a tool change restores; 6 mutants red); see STATUS.md for CI; upstream draft PR #25
u1-klipper#30 With heads of different nozzle sizes, a file whose per-tool nozzle list matches the heads is refused at start (nozzle diameter mismatch, code 14): every used head is compared with the list's first entry patched by patches/0030-nozzle-diameter-per-tool.patch: each used file tool is compared with its own entry, on the head it is mapped to; tests/test_issue30.py starts the job as Moonraker does (SDCARD_PRINT_FILE_WITH_PARAMETERS), red on stock 2.1.0 (3 of 6), green with the patch, 3 mutants red (docs/evidence/2.1.0/issue-30/); offline only, not run on a printer with mixed nozzles; upstream draft PR #31
u1-klipper#14 (side finding) On a 0.2 mm nozzle PCTG is refused (print start code 25, filament info cleared when the head is set to 0.2): the PC prefix test meant for polycarbonate blends also matches PCTG patched by patches/0014-pctg-allowed-on-02-nozzle.patch (+3/-1); tests/test_issue14pc.py calls the firmware's own is_allow_to_print, red on stock 2.1.0 (1 of 5), green with the patch, 2 mutants red (docs/evidence/2.1.0/issue-14pc/); function level only, not run on a printer; upstream draft PR #32
u1-klipper#8 Runout + resume replaces the head's measured flow calibration with the default patched; red on 2.0.0 and 2.1.0 (factor 0.023951 becomes 0.020000, live and in flow_calibrator.json, when the spool is fed back), green with the patch, 3 mutants red, in a full print with the real runout, reload and Resume path (tests/test_issue8.py); upstream draft PR #27

Credit for finding and describing each bug goes to the people who filed the issues: alternativniy (#18, who also traced the root cause and pointed to the mainline fix), SwineFlew931 (#22, who also proposed the fix the patch implements), abehrman (#22, two prints lost on a stock U1 through the tool-change path, replayed offline to the exact bad targets) and mmunchinski (#8, whose 5-second poll of the live and stored factor located the wipe and whose minimum policy the patch implements). Both patches are proven on 93cb12f (2.0.0) and on 7ac453b (2.1.0, released 4 November 2026, now upstream main), which does not touch these files: on stock 2.1.0 #22 still stops with the same Move out of range on Y axis: 53.641 445.274 7.000 and #18 still switches the fan 4366 ms (on) and 4266 ms (off) early; with the patches both pass, and every mutant fails (evidence). CI runs every check on both releases. This project adds the printer-free reproduction, the patch and the regression test.

Releases: https://github.com/DesignMaster-Solutions/u1-fixpack/releases (zip with the four .patch files, tools/fan_m400.py, the tests and this documentation; on a u1-klipper checkout, git apply patches/<file>.patch). Project site: https://designmaster-solutions.github.io/u1-fixpack/.

#18 on stock firmware, until the patch ships

tools/fan_m400.py puts an M400 before every part-fan M106/M107 (fans with a P index, like the auxiliary and exhaust fans, are left alone; running it twice adds nothing). In Snapmaker Orca or OrcaSlicer, add python3 /path/to/fan_m400.py under Others > Post-processing scripts: the slicer passes the G-code file and it is edited in place.

Why it works, from the stock code at 93cb12f: M106/M107 schedule the fan at the MCU's current time (klippy/extras/fan.py, set_speed_from_command, line 85), not at the move the slicer put them in front of, which is the bug. M400 (toolhead.wait_moves) holds the next command until the queued moves are done, so "now" is then the end of that move.

Measured on the stock firmware, 2.0.0 and 2.1.0, no patch (tests/run_fan_m400.py, in CI):

#18 fixture fan on fan off
as sliced 4566 ms early 4466 ms early
after fan_m400.py 240 ms early 240 ms early

The 240 ms is the firmware's restart buffer before the next move after a full stop. One caveat on the method: in Klipper's batch mode M400 does not wait (klippy/toolhead.py line 556, if not self.can_pause: break), so both runs enable DRYRUN_WAIT_MODEL in tests/firmware/dryrun_tracer.py, which lets the MCU clock catch up with the drained queue after each wait, the exit condition of that loop on the printer. Without the model the harness shows the same 4366 ms either way. Not tried on a physical U1 yet: if you do, please say in the forum topic or an issue whether the fan now switches where the slicer put it, either way.

Cost: the toolhead stops for a moment at every part-fan change: 73, 45 and 37 stops in the three example prints of u1-dryrun. On a print with many overhang fan changes that can leave small marks where it stops. The patch has no such cost.

Start line refused on some toolheads (forum 44046)

In topic 44046 prints stop right at the start with Move out of range on Y axis: 84.9 -0.09 2.0 (error 0003-0522-0001-0013) on toolheads 1, 3 and 4, never on 2. There is no firmware bug to patch here, only a 1 mm margin. The firmware sets each head's offset to its calibrated base position minus the midpoint of the four heads' range (get_center_base_position in klippy/kinematics/extruder.py), so the lowest head always sits at minus half the Y spread, and the stock machine start G-code draws its purge line at G0 X85 Y1. With a Y spread over 2 mm, a head more than 1 mm below the midpoint is sent under position_min: 0 whenever it is the print's first tool, which is why recalibrating did not help: it measures the same spread again.

tests/run_start_line.py gives T0 the offset (-0.10, -1.09) on the real firmware and gets the reporter's exact error, 84.900 -0.090 2.000; the same head passes with the line at Y5 (toolhead Y 3.91), and the high head (+1.09) passes at Y1, on 2.0.0 and 2.1.0 (evidence). To check your own heads, ask Moonraker for /printer/objects/query?extruder=extruder_offset&extruder1=extruder_offset&extruder2=extruder_offset&extruder3=extruder_offset: a Y below -1.0 means the stock line fails when that head starts the print. Moving the line to Y5 in the machine start G-code, as the reporter did, covers offsets down to -5 mm.

Confirmed on the reporter's physical U1 (firmware 2.1.0, post 5, 5 November 2026): Moonraker gave Y offsets of -1.129, +1.129, -1.055 and -1.010 for heads 1 to 4. The three below -1.0 are the ones that failed, and head 2 never did. The profile change is proposed upstream in Snapmaker/snapmaker-profiles#5 (the line at Y5 in the four U1 nozzle profiles, for Snapmaker/OrcaSlicer#1143).

A saved preset that only works in one project (OrcaSlicer#1207)

Snapmaker Orca 2.4.1 saves a user preset as the keys that differ from its parent plus "inherits": "<parent>". When the parent is a "Project-inside preset", it only exists inside that .3mf, so the saved file is skipped in every other project (import_json_presets: "can not find inherit preset for user preset"). tools/flatten_preset.py reads the parent chain from the .3mf and writes one preset with every key and no parent:

python3 tools/flatten_preset.py project.3mf                       # lists the presets inside
python3 tools/flatten_preset.py project.3mf saved_preset.json     # the partial file from AppData
python3 tools/flatten_preset.py --system <slicer>/system/Snapmaker/process saved_preset.json   # parent is a system preset: full copy that survives a rename

Then File > Import > Import Configs. compatible_printers is set to the project's printer, because a converted parent often still lists the printers it came from and would be hidden on the U1 (--printer changes it). Checked on the project attached to the issue: 7 keys in, 335 out, and the 2.4.1 command line slices with it (0.24 mm, 10% infill, 1 wall from the parent; no brim, no tower from the child). Not checked: the import dialog itself, and Windows. For the command line the file also needs "type": "process", and that project's wipe_tower_filament = 0 had to be removed (the 2.4.1 CLI exits 139 with it; the desktop app opens the same project fine).

A project written by a converter (U1convert) or an older slicer has no process_settings_N.config, only the merged project_settings.config. The slicer builds the Project-inside preset from it and names it <print_settings_id>(<file name>); the tool does the same, taking the process keys (Preset::print_options() of 2.4.1), and accepts the project under a new file name. Checked on the second project from the issue: 316 keys out. A key the project does not carry takes the slicer default on import. A preset whose parent is a system preset needs none of this: that parent ships with the slicer.

Fixes offered in u1-moonraker

The U1 also ships Snapmaker's fork of Moonraker. Three defects there are offered as pull requests on Snapmaker/u1-moonraker, each with the test in the PR. None was run on a printer.

Pull request What U1 owners see Proof
u1-moonraker#11 (fixes #4) The shipped moonraker.conf trusts 192.0.0.0/8, sixteen million addresses that are mostly public, where the private range 192.168.0.0/16 was meant one-line config change
u1-moonraker#12 (fixes #2) A filament type with a space, such as "PLA Matte";PLA, is stored as PLA Matte";PLA: quotes were stripped from the ends of the whole value, not from each entry the firmware's own metadata.py on the issue's value, before and after; 7 test cases, 3 red on main, 7 green
u1-moonraker#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 keys added to SUPPORTED_DATA only have a parser in the PrusaSlicer class, so the script dies with AttributeError a Cura file on main exits 255 with no JSON, on the branch exits 0 with metadata; 37 test cases, 7 red on main, 37 green

Read from the source, no patch

Two open firmware issues had no answer and can be settled by reading the code. No patch is offered for them; each note says what the firmware does, where, and what is still unknown.

Issue What the source says
u1-klipper#14 PCTG calibrates flow at 220 C because PCTG is in none of the filament tables and the print file's temperature is dropped when any other file parameter fails one combined check. Note. Waiting for the reporter's klippy.log before writing a patch.
u1-klipper#15 The PSU fan table's columns 3 and 4 are numbers of heads, not speeds. Stock asks for 60 % while a head is set above 45 and 100 % only with three heads on and one above 260; both tables proposed in the issue never reach their second row. Note, pinned by tests/test_power_fan_table.py on the firmware's own heater_fan.py (1.6.0, 2.0.0, 2.1.0).

On the Extended firmware

The community Extended firmware builds stock 2.1.0 plus its own Klipper patches (overlays/firmware-extended/11-patch-klipper, 01 to 08) and still has both bugs. Measured on its develop at 601e196 (4 November 2026):

Tree #18 fan on #18 fan off #22 (3 cases)
Extended as built (2.1.0 + 01..08) 4366 ms early 4266 ms early 3/3 fail, Move out of range on Y axis: 35.000 450.500 1.200
Extended + both patches as 09 and 10 10 ms after the step 10 ms after the step 3/3 pass

The 10 patches apply in order with the command the Extended build uses (patch -F 0 --no-backup-if-mismatch -p1), and that tree is byte-identical to the one tested (evidence). Checked on the u1-klipper 2.1.0 source, not on the firmware image's rootfs. Reproduce: tests/extended/fetch.sh, then apply.sh and format.sh in the image (commands in each file), then python3 tests/extended/prove_extended.py. For #18 on the Extended firmware, use pull request #787 by @alternativniy: the same motion-queue approach, opened there on 15 October and tested on a U1. The #22 patch is offered there as 10 in the Klipper overlay, in pull request #869, so a U1 owner can flash a test build from it; it touches only exclude_object.py and, applied without the fan patch, test_issue22 still goes from 3/3 fail to 3/3 pass (5 November).

How it works

The firmware runner comes from U1 Dry Run (same author): it builds u1-klipper at the pinned commit, generates the data dictionaries for the U1's boards from the Kconfig files in lava/, and runs Klipper in batch mode. A bug counts as reproduced only when the firmware's own output shows it (an error it raises, a position it reports, the time a command is scheduled at), never when a mock says so.

The #18 regression decodes the e0 MCU output with Klipper's parsedump.py and the U1 at32f415_config.dict. It compares the fan PWM clock with the first extruder step clock in the move after M106; the 12 ms tolerance is two 5 ms PWM cycles plus 2 ms for step and scheduling quantization. A second fixture (issue18-m107.gcode) does the same for the off edge: fan on and settled, then M107 queued behind travel moves. On 2.0.0 the fan stops 4266 ms before the next extrusion; with the patch, 10 ms after it. A mutant that leaves M107 immediate (tests/mutants/18-m107-immediate.patch) must fail. It also checks the fan status the firmware reports: with the patch, status still shows the old speed while the move is queued, and the new one after M400. Two mutants that keep the PWM on time but get the status wrong (never updated, updated at parse time) must fail those checks.

The status changes when the PWM does, not when it is scheduled. alternativniy found this reviewing upstream PR #25: the lookahead callback runs when the move is planned, so a status set there shows the new speed before the fan changes, by up to the queued move time, and his users saw the screen and Fluidd run ahead on hardware. The fix is his idea from Extended PR #787, written for this patch: set_speed() records (print_time, value) once the final print time is known (after FAN_MIN_TIME spacing and kick-start), and get_status() reports a value only when estimated_print_time() reaches it, dropping the pairs it consumed. tests/run_fan_status.py (in CI) proves it on the real firmware: M106 S255 queued behind a 5 s extrusion, the lookahead flushed so the PWM is scheduled at print time 1.025931 s (e0 PWM clock 147,734,025 at 144 MHz), and the status read with the batch-mode MCU clock modeled by DRYRUN_WAIT_MODEL (the file-output MCU otherwise reports 0): 0.0 at 0.350 s and 1 ms before the PWM, 1.0 at the PWM and after M400, on 2.0.0 and 2.1.0. The previous version of this patch (tests/mutants/18-status-at-schedule.patch) shows 1.0 from 0.350 s and fails (evidence, 2.1.0).

A tool change right after M106 restores the last requested speed on the new head (tests/run_toolchange_fan.py, in CI). alternativniy asked this on Extended PR #787: could T1 right after two quick M106 save a stale value? Since the status now lags the request, the U1 tool change (_cmd_SWITCH_EXTRUDER in klippy/kinematics/extruder.py) restores get_requested_speed() instead of reading the status, as #787 does. Measured from the PWM the new head's e1 MCU receives, on 2.0.0 and 2.1.0, with the MCU clock modeled: M106 S255 then T1, and M106 S64 settled then M106 S128 + M106 S255 then T1, restore 1.0 on stock and patched firmware. A mutant that restores the status (tests/mutants/18-toolchange-reads-status.patch) restores 0.502 (S128) in the second case: after wait_moves() the S255 PWM, 100 ms (FAN_MIN_TIME) after S128, is still ahead of the MCU clock. A mutant that reads the status before wait_moves() (tests/mutants/18-toolchange-status-before-flush.patch) restores 0.0 in both. Both fail (evidence, 2.1.0).

tests/firmware/prep_cfg.py and tests/firmware/dryrun_tracer.py are derived from U1 Dry Run under the same GPL-3.0 license. The issue #22 fixture exercises the stock EXCLUDE_OBJECT, pause park, and E-only resume paths. Because batch mode has no print lifecycle, DRYRUN_PRINT_START calls Klipper's real print_stats.note_start(); hardware-only sensor sections are omitted by the config preparer. The emitted position and range error still come from the real firmware code.

Limits

  • Batch mode has no physics and no real sensors. Anything that depends on them is simulated at the firmware's own boundary and says so in the test.
  • A fix proven here is a fix of the firmware logic. Each patch still needs a run on a physical U1, and that is asked for openly in each pull request.
  • Built with AI coding assistance.

License

GPL-3.0, the same license as u1-klipper.

About

Reproduce, fix and regression-test open bugs in the Snapmaker U1 firmware, with no printer

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages