Skip to content

Test performance optimisations - #1

Closed
paxx12 wants to merge 92 commits into
developfrom
performance-optimisation
Closed

paxx12 wants to merge 92 commits into
developfrom
performance-optimisation

Conversation

@paxx12

@paxx12 paxx12 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

No description provided.

suchmememanyskill and others added 30 commits May 10, 2026 17:16
Fixes paxx12-snapmaker-u1#430. According to specification the `alpha` is a byte hex.

```
2026-05-02 19:32:36 ERROR tag_processor:openspool_tag_processor: OpenSpool payload parsing failed: invalid literal for int() with base 10: 'FF'
Traceback (most recent call last):
  File "/usr/local/share/openrfid/tag/openspool/processor.py", line 47, in __openspool_parse_payload
    alpha = max(0x00, min(0xFF, int(data.get('alpha', 255))))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'FF'
```
Adds `hidden: true` flag to settings items, settings options, actions,
and status sections. Hidden entries are omitted from the UI unless
`?hidden` or `#hidden` is present in the URL, in which case a notice
banner is shown. Hidden options within a setting are also shown if
they are the currently active value.

The `hidden: true` is available for `status: hidden: true`, `actions: items:`, `settings:` and `settings: options:`
…a-ai-mpp`) paxx12-snapmaker-u1#316

Introduces an experimental overlay that runs custom implementation of the RKNN
AI detection pipeline on the U1's internal MIPI camera, exposed through the
standard firmware-config UI.

## Changes

### `68-app-camera-ai-mpp` overlay (new)

- **`S99detect-rknn`** — init.d script that starts four processes when
  `camera internal=paxx12-ai`:
  - `detect-rknn-yolo11.py` × 3 (bed-check, print-check, noodle-verify)
    using the stock RKNN model files from `/etc/unisrv/camera_service/model/`
  - `detect-http.py` — HTTP visualisation server on port 8091 (proxied via
    nginx at `/detect-http/`)
  - `fake-camera-agent.py` — MQTT bridge imported from Snapmaker firmware;
    implements the `camera_service` JSON-RPC protocol over MQTT so lmd's
    AI consumers work unchanged => This does not support Snapmaker Cloud features
- **`16_settings_camera_ai.yaml`** — adds a hidden `Paxx12 AI (Experimental)`
  option to the `camera-internal` firmware-config setting; toggling it
  stops `S90lmd`, restarts `S99detect-rknn` and `S99v4l2-mpp-mipi`, and
  shows an AI Detection link in the sidebar
- **`detect-http.conf`** — nginx location block proxying `/detect-http/`
  to `127.0.0.1:8091`
- **`01-check-apps.sh`** — validates the `sha256` of
  `/etc/unisrv/config.json` to confirm required stock apps are present
- **`02-install-rknn.sh`** — installs RKNN Toolkit Lite2 v2.3.2,
  `opencv-python-headless`, `numpy<2`, and `paho-mqtt` into the rootfs

### `60-app-camera` changes

- **`02-disable-native-camera.patch`** — extends `S90lmd` start logic:
  - `camera internal=paxx12` → start lmd with `v4l2-imposter` (existing
    paxx12 mode)
  - `camera internal=paxx12-ai` → skip lmd entirely (AI pipeline owns
    the camera)
  - anything else → normal snapmaker lmd start
  - Removes the redundant lmd logic that was previously in
    `S99v4l2-mpp-mipi`
- **`01-v4l2-mpp.sh`** — bumps `v4l2-mpp` to commit `1cb2b9c` which fixes
  a relative path used by the AI visualisation output

## Notes

- The overlay is opt-in and hidden behind a confirmation dialog warning about
  experimental / potentially false-positive AI output.
- The RKNN models are stock Snapmaker firmware files; `01-check-apps.sh`
  gates installation on their presence via sha256 check.
- `fake-camera-agent.py` is imported verbatim from Snapmaker firmware to
  maintain protocol compatibility with lmd's camera consumers.
…hooks to `fluidd.cfg` (paxx12-snapmaker-u1#444)

Patches `origin_printer_data/config/fluidd.cfg` to iterate
`printer.configfile.config` at runtime and call every `gcode_macro`
whose name matches `_PRINT_START_*`, `_PRINT_END_*`, or
`_CANCEL_PRINT_*`.

Hooks run after `PRINT_START` and before `PRINT_END`/`CANCEL_PRINT`,
allowing features to register lifecycle callbacks without touching
any stock macro.

Adds `docs/klipper_hooks.md` with usage examples and links it from
`index.md`, `firmware_config.md`, and `klipper_includes.md`.
…#452)

Ensure that kernel modules being built are matching what is shipped in the firmware.
Extends `firmware-config` to allow settings options to declare named form fields rendered in the confirm modal.  Each input is validated client-side before the user can confirm, and its value is injected as a named environment variable into the option `cmd`.

On the server side, only keys declared in `inputs` are admitted into the env (allow list), each value is validated against the input's `regex`, and missing or non-matching values result in a 400 before the command is ever executed.

YAML definition example:

```yaml
options:
  enabled:
    label: Enabled
    confirm: "Enable integration? Enter the server URL below."
    inputs:
      - name: SERVER_URL
        label: Server URL
        placeholder: "http://192.168.1.100:7912"
        regex: "^https?://.+"
    cmd:
      - bash
      - -c
      - |
        echo "Connecting to ${SERVER_URL}..."
```

The `cmd` receives each `name` as an env var (`SERVER_URL` above). Multiple inputs are supported; all must pass regex validation before the confirm button becomes active.
…LOR_NUMS` (paxx12-snapmaker-u1#442)

`FILAMENT_INFO_STRUCT` includes `MULTI_MODE` and `RGB_2`..`RGB_5` bytes
but the `filament_detect/set` webhook handler never accepted them, making
it impossible to write these fields to an RFID tag via the API.

Accept an optional `MULTI_MODE` parameter (0-255) stored directly in
`filament_info`. Accept optional `RGB_2`..`RGB_5` parameters and derive
`COLOR_NUMS` automatically from the count of `RGB_x` fields provided
(minimum 1), so callers do not need to compute it themselves.
paxx12-snapmaker-u1#459)

- Add `print_preferences` section
- Move `object_processing` tweak from `32-feature-klipper-tweaks` to `35-feature-print-preferences` — it belongs alongside adaptive bed mesh
- Move AFC Lite from `tweaks` to `snapmaker_components` section; rename YAML file to `23_settings_afc.yaml`
- Extend adaptive mesh confirm text to explain that `Exclude Object` must be enabled in the slicer for adaptive mode to take effect
- Update force-timelapse description to "Forces timelapse regardless if configured in the Snapmaker app"
…axx12-snapmaker-u1#460)

`SET_PRINT_PREFERENCES` rejects `BED_LEVEL` and `TIME_LAPSE_CAMERA`
only when `main_state` is `PRINTING`. The overrides previously switched
to `IDLE` unconditionally; now the switch, preference set, restore, and
validate call are skipped entirely outside of a print.

`bed_leveling_adaptive_force.cfg` also skips injecting `ADAPTIVE=1`
when the caller already passes the `ADAPTIVE` parameter explicitly.
…-u1#461)

Consolidates two separate promo blocks (one per discount code) into a
single, cleaner entry. Clarifies that ordering via the referral link
alone supports the project; `PAXX12CUSTOM` ($20 off) is optional.
Switches `pre_release.yaml` from `prerelease: true` to `draft: true`
so new releases are created as drafts rather than marked as pre-releases. [ci skip]
The `has <cfg_file> <section>` checks whether a section exists in a
Klipper config file. Exits 0 and prints "yes" if found, exits 1 and
prints "no" otherwise.
Moves the overlay from `34-feature-panda-breath` to `37-feature-panda-breath`.

Adds `panda_breath_cli.py` — a standalone CLI tool that communicates with the
Panda Breath device over WebSocket using stdlib `socket` and `struct` only, with
no external dependencies. Supports `version`, `bind-klipper`, and `unbind`
commands.

Both `auto` and `manual` firmware-config options run `panda_breath_cli.py
bind-klipper` before writing config, validating firmware version `V1.0.3` and
binding the printer IP resolved from `eth0` then `wlan0`. Shell commands run
under `-ec` so a failed bind aborts before any config files are written, and
each step prints a user-facing status message.

The `disabled` option reads the stored host with `extended-config.py get` and
calls `panda_breath_cli.py unbind` before removing the config file, so the
device is left cleanly disconnected. Unbind failure is non-fatal — config
removal and Klipper restart still proceed.

Confirm dialogs for `auto` and `manual` now present a numbered checklist:
ensure firmware v1.0.3 is installed; configure a static DHCP lease for both
the printer and the Panda Breath device on the router; power-cycle the Panda
Breath device and wait at least 5 seconds; enter the Panda Breath IP address.

Panda Breath is placed under `snapmaker_components` (was `tweaks`). Option
labels are "Auto (Recommended)" and "Manual (Advanced)".
New features:
- Added Traditional Chinese and Russian language support.
- Added `LED Off After Print` option in `Settings` > `Print Preferences`.

Bug fixes:
- Fixed an issue where the number of objects was not fully displayed in
  the `Skip Object` feature.
- Fixed an issue where an excessively long extrusion occasionally
  occurred after using the `Skip Object` feature.

Improvements:
- Increased the maximum number of supported objects in the `Skip Object`
  feature to 64.
- Updated the AI defect detection model to improve detection workflow
  and user experience.
- Improved system performance and stability, and reduced MCU control
  timeout issues.
`filament_detect.py` in `lava-1.4.0` dropped `copy` and `filament_feed`
from its imports.  Patch 02 hunk #1 matched the old `import logging, copy,
os` context line and failed to apply.  Update the hunk to match the current
`import logging, os` and drop the now-absent `from . import filament_feed`
context line; adjust the second hunk's `@@ -124` offset to `@@ -123`
accordingly.

Also fix a bug in `filament_protocol_ndef.py`: iterating
`additional_color_hexes[:5]` with `COLOR_NUMS` starting at 1 can produce
`COLOR_NUMS = 6` and write `RGB_6`, which is not in `FILAMENT_INFO_STRUCT`
and exceeds `FILAMENT_PROTO_COLOR_NUMS_MAX = 5`.  Cap the slice to
`FILAMENT_PROTO_COLOR_NUMS_MAX - 1` (i.e. 4) and remove the now-redundant
zero-fill loop whose upper bound was also off-by-one.
Drops `light_spot` from `BED_CHECK_LABELS` in `S99detect-rknn` and
updates the `config.json` checksum in `01-check-apps.sh` to match the
new `v1.4.0` firmware bundle.
Patches `print_task_config.py` to accept a `FORCE` parameter on
`SET_PRINT_PREFERENCES`: when `FORCE=1` is passed the printing-state
guard is skipped, allowing `BED_LEVEL`, `TIME_LAPSE_CAMERA` and similar
preferences to be updated mid-print.

Rewrites the force-variant Klipper macros (`bed_leveling_force.cfg`,
`bed_leveling_adaptive_force.cfg`, `timelapse_force.cfg`) to use
`print_stats.state` instead of the old `machine_state_manager` approach,
dropping the now-unnecessary `_*_FORCE_VALIDATE` helper macros.
Replace `copy.deepcopy()` and `copy.copy()` with `dict()` to match
how upstream `filament_detect.py` copies `FILAMENT_INFO_STRUCT`, and
drop the now-unused `import copy` from `filament_protocol_ndef.py`.

Also change the error path in patch 05 to use `set_error()` so the
webhooks response type is `"error"` rather than a successful result.
…maker-u1#481

Moves `[tigertag_tag_processor]` from opt-in comment in `openrfid_user.cfg`
to always-present section in `openrfid_u1_base.cfg`, enabling tigertag
processing out of the box without requiring manual user configuration.
- Adds `docs/panda_breath.md` covering the BIQU Panda Breath integration:
  setup prerequisites, enabling via Firmware Config (auto vs manual mode),
  configuration file location, G-code usage, and troubleshooting.
- Includes a dedicated Risks and Warranty section warning about insufficient
  motherboard thermal headroom, RK3562 throttling at 85°C, documented
  overheating failures, and warranty implications. Links two MakerWorld
  cooling solutions and a community fan mod thread.
- Enabling requires explicit user acknowledgement.
* Link to documentation in `firmware-config` confirm modal

When a setting has a `help_url`, the confirm dialog now shows a
"View documentation" link below the title. Passes `help_url` via
`data-help-url` on the `<select>` element and threads it through
`updateSetting` into `showConfirmModal`. Also strips the `↗` anchor
text from the label extracted for the modal title, so it reads
cleanly when there is no link on the title itself.

* Widen `.links-grid` minmax to `300px` in `firmware-config`

Increases the minimum column width from `200px` to `300px` so link
items don't become too narrow on mid-range viewport widths.
…napmaker-u1#478)

- `04_status_mmc.yaml`: New combined "eMMC & Performance" card with
  uptime, load average, CPU frequency, CPU temperature, eMMC pre-EOL
  info, and life time (A/B) from `/sys/bus/mmc/devices/mmc0:*`
- `01_status_system.yaml`: Merge firmware info into system card,
  shorten label names
)

Moves the print preferences feature overlay from `35` to `36` to
accommodate a new overlay inserted before it in the load order.
…u1#506)

Each WebSocket connection starts with a settings frame from the device,
so opening a fresh connection per operation means every step sees the
current printer state. This lets `disconnect_printer` skip when already
disconnected, `set_printer_type` skip when already correct, and
`unbind_klipper` skip on `PRINTER_STATE_INVALID_INFO` — all based on
live state rather than stale globals.
Upstream changelog:

- Fixed an issue where filament runout detection failed to trigger
  an automatic print pause under certain conditions. This could
  occur when a new print was started after canceling the previous
  one. If filament ran out during the new print, the printer might
  not pause automatically.
- Fixed an issue where AI defect detection did not function
  properly when the camera was obstructed.
- Fixed an issue where filament information was occasionally not
  recognized after a device restart. This could occur if
  "Auto Loading" was disabled and the filament status was
  "Loaded" before restarting the device.
paxx12 and others added 27 commits July 19, 2026 14:30
…-u1#575)

Patches `printer.cfg` to set `cycle_time: 0.003333` (300Hz) on
`[led cavity_led]`, up from Klipper's default of `cycle_time: 0.010`
(100Hz).

100Hz doesn't divide evenly into the paxx12 camera's 25fps/30fps
capture rates, so each frame samples the LED's software PWM duty
cycle at a different phase, producing a slow flicker/beat pattern in
recordings. 300Hz divides evenly into both (12 cycles per frame at
25fps, 10 at 30fps), so every frame sees the same duty cycle and the
flicker goes away.
…x12-snapmaker-u1#598) (paxx12-snapmaker-u1#600)

`tailscale-pkg` and `octoeverywhere-pkg` were near copies of each other:
fetch a pinned archive, verify its SHA256, unpack it into
`$APP_DIR/<prefix>-<version>` and repoint `$APP_DIR/latest`. Only the
version, URL, checksum and a couple of paths differed, and the copies had
drifted (`ln -sf` vs `ln -sfn`, silent vs progress `curl`).

Move the lifecycle into `extended-pkg <name> <command>` in
`01-system-utils`, and reduce each app to a definition file at
`/usr/local/share/extended-pkg/<name>` that it sources, shipped by the
overlay owning the app. Definitions set `PKG_VERSION`, `PKG_URL` and
`PKG_SHA256`, and may override `PKG_LABEL`, `PKG_APP_DIR`, `PKG_PREFIX`,
`PKG_BINARIES`, `PKG_CLEAN_PATHS` and `PKG_LEGACY_DIR`. OctoEverywhere's
virtualenv step becomes a `pkg_post_install` hook run against the
unpacked staging directory before it is moved into place.

The `tailscale` and `tailscaled` symlinks dispatched on `basename $0`,
which a shared driver cannot do, so `extended-pkg` grows an `exec`
command and they become two-line shims onto it.
Bumps `PKG_VERSION` and `PKG_SHA256` in the `extended-pkg` definition.
…1#602)

Replaces `docs/rfid_support.md` with `docs/design/rfid.md`, which holds the
reader capability matrix, the community app list, and the OpenRFID setup
instructions. The `Readers` table records what each reader detects
(Snapmaker built-in, OpenRFID, and the wasikuss and baze external readers),
including a `SpoolLink` column for whether a reader reports a tag UID when it
cannot parse the tag contents. External readers are folded into the same table
via a `Hardware` column rather than kept in a separate section.

Splits the OpenSpool payload format and field reference into
`docs/design/openspool.md` so the wire format is documented independently of
the readers that consume it.

Adds an `Apps` section to `docs/spoolman.md` covering apps that implement
SpoolLink (the SpoolLink reference apps, SpoolPainter, SpoolKid, SpoolTagger,
and 3DMRP) with a `Legacy Spools` column for apps that convert older tag links
to the current convention, plus an `External Readers` section describing each
reader's SpoolLink behaviour.

App and reader capabilities were verified against each project's source code
where available. Store links, source links with licences, and donation links
are included so users can find and support each project.
Records the external contributions in this release: `.zip` firmware
upload support in `firmware-config` (@Tareku99), Panda Breath `V1.0.4`
bind support (@plastikman), and the investigation that root-caused the
`cavity_led` PWM camera flicker (@djgringoboy2003).
Snapmaker republished V1.5.2 with a new build: `1.5.2.13_20260722102206`
replaces `1.5.2.12_20260715211532`. The wiki version string and changelog
are unchanged, so only `FIRMWARE_FILE` and `FIRMWARE_SHA256` move.

Upstream changelog:

- Fixed an issue introduced in V1.5.0 that could cause the first layer
  to be overly squished when Heated Bed Leveling was not enabled before
  printing.
- Fixed false nozzle diameter mismatch warnings that could prevent
  prints from starting.
- Fixed an issue where nozzle heating remained on after filament
  loading or unloading.
…ker-u1#612)

`.modal` had `max-height: 80vh` with no overflow handling, and sits
inside a `position: fixed` overlay that doesn't scroll the page. On
short screens, a long `confirm:` message plus `inputs:` fields (e.g.
Panda Breath's enable flow) could push the inputs and Confirm button
past the modal's box, making them unreachable.

Adds `overflow-y: auto` to `.modal` so it scrolls internally instead.
…12-snapmaker-u1#613)

* Document Spool Studio and the pre-SpoolLink macro conflict in `docs/spoolman.md`

Adds `GeorgHo/SpoolStudio` to the community apps table now that its
v3 beta supports the SpoolLink UID flow, tested against
`v1.5.2-paxx12-21` (paxx12-snapmaker-u1#567).

Also adds a `Known Conflicts` note: a leftover hand-wired Spoolman
Klipper include (e.g. a `spoolman_multi_tool`-style macro file from
before SpoolLink existed) can make Klipper fail to start with a
`variables.cfg` not-found error. Documents the rename/remove
workaround, per the remarks paxx12 promised in paxx12-snapmaker-u1#567
(issuecomment-5120004375) after convicte root-caused the conflict.

* Add `Reads` and `Support` columns and update SpoolLink app links in `docs/spoolman.md`

Adds a `Reads` column to the Apps table listing which tag formats
each SpoolLink app can parse (OpenSpool, vendor formats, UID-only
fallback), sourced from each project's own README/release notes.

Updates `paxx12-snapmaker-u1/proof-of-concept-spool-link-apps` links
to the renamed `spool-link-apps` repo, and points the SpoolLink
Android/iOS entries at its `v0.1.0` release assets instead of
build-from-source only.

Links GitHub/Codeberg releases for SpoolTagger and 3DMRP in the
Platform column, and adds a `Support the author` column to the
External Readers table for consistency with the Apps table (neither
reader author has a donation link currently, so both show `—`).
…ing correctly in fluidd/mainsail (paxx12-snapmaker-u1#614)

* Adding moonraker patches
- Cherrypicking mainline mookraker commit b8b28bc through 5b92e52 for metadata.py file
to bring in the new parsing gcode to support AFC features like displaying number of toolchanges,
weight, etc so AFC print dialog can be used.

* Fixing thumbnail generation so they display correctly in fluidd/mainsail
- Thumbnail generation was changed by snapmaker to show on their screen correctly,
this commit updates the thumbnail generation so they are generated correctly to show
in fluidd/mainsail and is still generates the thumbnails in the correct location to
still show on the screen.
* Adding CAN bus rules to always enable CAN bus upon starup

* Adding documentation for canbus

* Moving canbus to afc mods overlay directory
…ip] (paxx12-snapmaker-u1#641)

Adds `workflow_dispatch` alongside the existing `push` trigger so the
docs deploy can be re-run manually from the Actions tab, without
needing a new commit to `docs/**`.
…er-u1#624)

`SET_SPOOL_ID` is part of the Spoolman integration, but it lived in the
AFC-Lite tweak `afc.cfg`, so it only existed when AFC-Lite was enabled.
The filament UI calls it with `LANE=E<channel>` for any channel, and the
macro is useless without SpoolLink's `spoollink_resolve_spool` remote
method, so define it next to `[spoollink]` in
`/usr/local/share/spoollink/klipper.cfg` instead. That file is symlinked
into the extended Klipper config only when `[spoolman] host` is set, so
the macro now appears exactly when Spoolman is enabled, with or without
AFC-Lite.

Generalise channel resolution accordingly: use `CHANNEL` when given,
fall back to the `AFC_lane` object when AFC-Lite is loaded, and
otherwise derive the index from the lane name (`E0` -> 0). An
unrecognised lane now raises an error instead of silently resolving to
channel 0.
…2-snapmaker-u1#657)

`SpoolLink`'s `_handle_filament_detect_channel` only re-resolved a
channel when `CARD_UID` changed. Per paxx12-snapmaker-u1#628/paxx12-snapmaker-u1#622, the firmware wipes a
channel's `filament_detect` record (and `print_task_config.filament_spool_id`
with it) on every `openrfid` rescan, including rescans that read the
same physical card. Since the UID never changes on those rescans, the
existing trigger never fired and the wipe went unrepaired until the
card was physically removed and reinserted.
Bumps `FIRMWARE_FILE`, `FIRMWARE_VERSION`, and `FIRMWARE_SHA256` in
`vars.mk` to `U1_1.6.0.267_20260815150420_upgrade.bin`.

Ran `make build PROFILE=extended-afc-devel-paxx12-qemu` against the
extracted 1.6.0 rootfs to validate every overlay still applies, and
fixed the four that broke:

- `firmware-extended/35-feature-klipper-hooks`: Snapmaker reordered
  `PRINT_START`/`PRINT_END`/`CANCEL_PRINT` in `fluidd.cfg` around a
  new `AUTO_FEEDING_BATCH` macro and renamed the old `PRINT_STRAT`
  compat alias to `PRINT_PRESTART_CHECK`. Rebased the hook injection
  points to the same semantic position (end of `PRINT_START`, start
  of `PRINT_END`/`CANCEL_PRINT`).
- `firmware-extended/60-app-camera`: dropped
  `03-cavity-led-pwm-frequency.patch` (paxx12-snapmaker-u1#575) — 1.6.0 stock now ships
  the identical `cycle_time: 0.003333` value for `cavity_led`.
- `mods/afc/02-patch-moonraker`: Snapmaker's own `metadata.py`
  independently gained overlapping fields this release (filament
  volume type/process flow support/print sequence, a reworked
  `parse_filament_type`, a `check_identity` signature change).
  Rebuilt both patches via a three-way merge (`git merge-file`,
  common ancestor = 1.5.2's stock `metadata.py`) instead of hand
  patching, so the AFC-side changes (thumbnail handling, printer
  vendor/model metadata) combine with Snapmaker's additions instead
  of clobbering them.
- `mods/paxx12/60-camera-ai-mpp`: refreshed
  `02-extended2-cfg-comment.patch` context after
  `firmware-extended/02-firmware-config` gained an extra comment
  line in `extended2.cfg`.

Also switches the rootfs squashfs compressor in
`scripts/create_firmware.sh` from `gzip` to `zstd`: `1.6.0`'s kernel
dropped `CONFIG_SQUASHFS_ZLIB` (confirmed via the kernel `.config`
baked into `/info/config-6.1`, and cross-checked against
`/info/System.map-6.1` — the `zlib_init`/`zlib_uncompress`/
`zlib_free` glue from `fs/squashfs/zlib_wrapper.c` is gone from
`1.6.0`'s symbol table), so a `gzip`-compressed `rootfs.img` would be
unbootable on this kernel. `lz4` was tried first, matching Snapmaker's
own `1.6.0` `rootfs.img`, but overflows the 300 MiB `system_a`/
`system_b` partition on the heavier `extended-paxx12` profile
(336.0 MiB, -36.0 MiB headroom); `zstd` at its default level fits
comfortably (280.3 MiB, 19.7 MiB headroom) for meaningfully less
build/decompress CPU than `-Xcompression-level 22` (278.1 MiB).
…r-u1#658)

* Fix Moonraker zeroconf mDNS responder not surviving boot-time network race

Moonraker's zeroconf component initializes its AsyncZeroconf responder
during component_init(), which runs before machine.py's network state
has been populated with a real interface address (machine.component_init
does its first _parse_network_interfaces() call with notify=False, so
zeroconf never observes that first update). The responder ends up
registered with an empty address list.

The intended recovery path is _update_service(), triggered later by
machine:net_state_changed once an interface actually gets an IP. It
unconditionally calls unregister_services() first, on the assumption a
responder was already registered by component_init(). When that isn't
true yet, the unregister call operates on a runner whose aiozc is still
None, which raises and aborts _update_service() before it reaches the
register_services() call further down that would have fixed things.

Confirmed on-device: zeroconf.py's own logs show a props update with the
correct IP once the network comes up, but `U1-<serial>.local` remained
unresolvable via python-zeroconf service lookups, and only started
resolving after manually restarting Moonraker post-boot.

Fix: only call unregister_services() if something has actually been
registered (self.runner.aiozc is not None). This lets _update_service()
succeed the first time it fires after boot, performing the initial
registration instead of aborting on an unregister of nothing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Fix _update_service() silently re-registering with a stale address list

The crash guard from the previous commit (only call unregister_services()
if something was actually registered) fixed the exception, but on-device
testing after a real reboot showed the mDNS responder still didn't
resolve: the PTR record was visible via a python-zeroconf browse, but
get_service_info() for it kept returning None.

Root cause: _update_service() computes a fresh `addresses` list from the
current network state, but only ever assigned it onto the old, about
to be discarded service_info object (`self.service_info.addresses =
addresses`) rather than onto `self.addresses`. The replacement
AsyncServiceInfo built two lines later reads `addresses=self.addresses`,
which was still whatever component_init() saw at startup - empty, since
the network wasn't up yet. So the "fixed" re-registration was still
being registered with no address, just without crashing this time.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
…-snapmaker-u1#659)

[Problem]
Filament manager doesn't work if force_logins is set to true, since the
websocket connection isn't authenticated.

[Solution]
Copy the `getJWT` function into script.js and pass the access token to
websocket if available.
…#664)

Patches every originally-authored source, script, and config file with
a three-line SPDX header: `SPDX-License-Identifier: GPL-3.0-or-later`,
`SPDX-PackageHomePage` pointing at this repo, and
`SPDX-FileCopyrightText` listing the GitHub handle of every contributor
who has touched that file, in chronological order.

Contributor handles were resolved per-commit via the GitHub API
(`gh api repos/.../commits/<sha>` `.author.login`), not guessed from git
display names, since several contributors commit under a different
display name/email than their actual GitHub account (e.g.
`horzadome@gmail.com` resolves to the `horzadome` handle despite
appearing as both "Davor Grubisa" and "horza" in `git log`).

Excludes `docs/` (Jekyll site), `tools/rk2918_tools/` (a vendored fork
of an external Rockchip tool), `tools/resource_tool/resource_tool.c`
(already carries its own vendor SPDX tag), `.patch` diffs, `.md` docs,
and binary/non-source files.
…axx12-snapmaker-u1#666)

Adds `overlays/firmware-extended/37-feature-chamber-heater/`, bringing in
`plastikman`'s DragonBreath open-firmware support.

This change was originally made by @plastikman in PR paxx12-snapmaker-u1#626
(paxx12-snapmaker-u1#626).

Co-authored-by: plastikman <plastikman@gmail.com>
…Fi (paxx12-snapmaker-u1#667)

Adds a "Migrate to DragonBreath" quick action to the chamber-heater
overlay, shown only while `panda_breath.cfg` is configured and
`dragonbreath.cfg` is not. It flashes `plastikman`'s DragonBreath open
firmware to the Panda Breath board over the LAN
(`dragonbreath_migrate.py`, adapted from PR paxx12-snapmaker-u1#626), then swaps the
Klipper config from Panda Breath to DragonBreath and restarts klippy.

Unlike PR paxx12-snapmaker-u1#626, this never runs automatically: no first-boot guard, no
forced migration, no removal of the Panda Klipper module. It is purely
a convenience for a user who already has Panda Breath configured and
wants to switch to DragonBreath without doing the flash and config swap
by hand. Declining leaves Panda Breath untouched.

Also bundles the pinned DragonBreath device firmware into the image at
build time (`03-bundle-dragonbreath-firmware.sh`, from paxx12-snapmaker-u1#626) so the
migrate step needs no internet access on the printer or the Panda —
only the build host does.

Co-authored-by: plastikman <plastikman@gmail.com>
…x12-snapmaker-u1#668)

- Bumps the `v4l2-mpp` pinned commit
- Bumps the `deps/screen-apps` submodule
- Make `cache_pip.sh` to accept a `-r <file>` argument like `pip`
  itself: it stages the file inside the chroot and passes `-r` through
  to `pip3 install`/`pip3 download`, so pip does the real
  requirements-file parsing instead of the shell
Adds `limits-helper.sh` (under `03-extended-runtime`), sourced by each
extended-firmware service's init script to place it into a dedicated
cgroup v2 under `/sys/fs/cgroup/ext/<name>` with an aggressive
`memory.max` cap. The stock OS already confines moonraker/`lmd` to the
`apps` cgroup via `S05cgroup_setup`, but extended services previously
ran unconstrained in the root cgroup - measured at ~200 MB PSS
combined on the 1 GB device.

The init script joins the cgroup via `echo $$ > cgroup.procs` before spawning,
so `start-stop-daemon`/`fake-service` children inherit membership
race-free. Caps are ~2x measured idle RSS: `octoeverywhere`/`vpn` 80M
(`vpn` also gets `GOMEMLIMIT=64MiB` so Go's GC engages below the cap),
`camera-mipi`/`camera-usb` 64M, `camera-ai` 320M (provisional,
unmeasured), `openrfid`/`fb-http`/`firmware-config` 48M, `monitoring`
32M. Also exports `PYTHONMALLOC=malloc`, `MALLOC_ARENA_MAX=1`, and
malloc trim/mmap thresholds so freed heap is actually returned to the
OS instead of sitting in glibc/pymalloc pools.

Also flips each `ext/*` cgroup's `memory.swap.max` from 0 to `max`,
and the stock `apps` cgroup's too (scoped to moonraker/nginx/unisrv/
gui/wpa_supplicant - klipper lives in its own `rt` cgroup, confirmed
via `/proc/<pid>/cgroup`, so it's never swap-eligible). Since
swap.max is only a permission ceiling, `apps_swap_enable` also forces
a one-time `memory.reclaim` the first time it flips swap.max.

`memory-report` walks the whole cgroup hierarchy from `/sys/fs/cgroup`
down, printing `memory.current`/`memory.peak`/`memory.max`/
`memory.swap.current` per cgroup plus `/proc/swaps`, for tuning the
caps after a real-world soak.
@paxx12
paxx12 force-pushed the performance-optimisation branch from 8411f19 to 89a2128 Compare August 26, 2026 08:02
@paxx12 paxx12 closed this Aug 26, 2026
@github-actions

Copy link
Copy Markdown

✅ Build Artifacts

Version: 1.6.0-paxx12-test-pr-1
Build: 846b4b7 (merge of 89a2128 into develop)
Duration: 6m 25s

Artifact Size
extended-build 212.95 MB

View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.