Rebuild v1.2.0

From iagent
Jump to: navigation, search

Rebuild is a complete Linux image for Recore 3D printer controller boards. Rebuild comes with Klipper installed and the choice of either Mainsail, Fluidd or OctoPrint.

What is new in v1.2.0

Rebuild's own files are Debian packages

Everything Rebuild adds to the base system is now installed from two packages, rather than copied into the image by the build scripts:

  • rebuild-recore, on every image including barebone: the board tools (get-serial-number, get-recore-revision and friends), the USB-C serial console, and the Wi-Fi hotspot fallback.
  • rebuild-printer, on the Fluidd, Mainsail and OctoPrint images: the tools that flash the AR100, STM32 and RP2040 firmware, the configurations that firmware is built from, first boot, SSH auto-disable, the boot splash, and the system settings the printer images share.

This means that a fix to any of these files can reach a board through apt upgrade, instead of requiring a new image and a reflash.

The tools have moved from /usr/local/bin to /usr/bin. On a board that is upgraded in place, the old paths keep working: they become links to the new ones. The files the old image had copied in are kept in /var/backups/rebuild-legacy.

System updates

Rebuild v1.2.0 can be updated in place, without reflashing. Updates appear under System in the update section of Fluidd and Mainsail, and install from there:

  • Updates to Debian, including security fixes.
  • Updates to Rebuild's own packages (rebuild-recore and rebuild-printer).
  • New versions of the Linux kernel and device trees, once they have been tested on Recore hardware. The kernel, device trees, U-Boot and the other Armbian packages are pinned to tested versions by the package rebuild-armbian-tested. A newer version of that package releases a newer kernel.

A kernel release arrives in two steps: the first update installs the new rebuild-armbian-tested, and the next one shows the kernel and its companion packages. Reboot after a kernel update.

The bootloader (U-Boot) is not updated this way. It stays as it was when the board was installed.

Klipper, Moonraker, Fluidd, Mainsail and KlipperScreen are updated in the same place as before, each with its own entry.

Security

  • The printer account is now a service account. It has no password, is not in the sudo group, and cannot log in over SSH. Klipper, Moonraker and KlipperScreen keep working: the rights they need are given to them explicitly. Log in as debian, and use sudo -u printer -i to work in Klipper's files, as before.

Klipper and the AR100

  • Klipper is updated to v0.13.0-786. This version includes the AR100 improvements made for this release, which are now part of Klipper itself: the timer and message handling rework from Klipper's maintainer, faster serial handling, and building at -O2 with a correct size check. The AR100 firmware is built from an unmodified Klipper.
  • The AR100 compiler is updated from GCC 15.1.0 to GCC 16.1.0, which includes fixes for code generation errors on OpenRISC (64-bit and 16-bit shifts, and branch placement).
  • Each firmware file in /opt/firmware now has the exact configuration it was built with next to it (ar100.config, stm32.config, stm32-32KB.config, rp2040.config), and klipper-version records the Klipper version they were built from.

How fast the AR100 can step

The AR100 drives the X/Y (A/B) steppers, and the rate at which it can produce step pulses limits the top speed for a given microstep setting. With the improvements above it can step two steppers at the same time about 3.4 times faster than before: one step every 247 AR100 clock cycles per stepper instead of every 836, or about 1.2 million steps per second per stepper instead of 360,000.

What that means for speed depends on the number of steps per mm. The figures below are for a Voron 2.4 (CoreXY, 1.8° motors, 20-tooth GT2 pulleys, rotation_distance: 40, so 5 full steps per mm). On CoreXY the worst direction is a 45° diagonal, where one motor turns √2 times faster than the toolhead moves, so the speed column is the top speed in any direction.

Microsteps Steps per mm Top speed, any direction, before Top speed, any direction, now Now, with 30% margin
16 80 3,200 mm/s 10,700 mm/s 7,500 mm/s
32 160 1,600 mm/s 5,400 mm/s 3,800 mm/s
64 320 790 mm/s 2,700 mm/s 1,900 mm/s
128 640 400 mm/s 1,300 mm/s 940 mm/s
256 1,280 200 mm/s 670 mm/s 470 mm/s
  • Use the column with margin when choosing settings: the limit is where the AR100 shuts down with Timer too close, and a real print adds work the measurement does not.
  • For another printer, scale by its steps per mm: halving the steps per mm doubles the top speed.
  • Speed is rarely the only limit. On the Voron 2.4 used for these measurements, the mechanics stopped at 20,000 mm/s² acceleration (25,000 stalled the motors at 2.0 A), well before the AR100 did.
  • TMC drivers interpolate to 256 microsteps internally (interpolate: True, the default), so 32 or 64 microsteps still run smoothly.

Measured on the Voron 2.4 with the same AR100 changes on test firmware, before they were merged into Klipper, using a load test that streams commands while stepping. With them, the Voron completed 5 of 5 homings at 256 microsteps (upstream failed 2 of 3) and a dry-run Benchy at 32 microsteps, 800 mm/s and 20,000 mm/s² with no retransmissions. The figures will be checked again on the released image.

Fixes

  • A reboot shortly after the board has started no longer hangs for 90 seconds. Moonraker is given 10 seconds to stop.

A smaller image

  • Input shaper graphs are no longer drawn on the printer by default. python3-matplotlib is not installed, which saves 242 MB. Klipper itself never used it. See Input shaper graphs below.
  • The ARM compiler no longer carries libraries for Cortex-A and Cortex-R processors, which Klipper never builds for, and the firmware package no longer carries firmware for Qualcomm processors. Together these save about 630 MB. Every Cortex-M variant is kept, so firmware for any microcontroller Klipper supports can still be built on the printer, with any options (CAN bus, USB to CAN bridge, and so on).

Image sizes

Image Download (compressed), v1.1.0 Download, v1.2.0 Image unpacked, v1.1.0 Image unpacked, v1.2.0 Used on the Recore, v1.1.0 Used on the Recore, v1.2.0
Barebone 332 MB 224 MB (−33%) 1.84 GB 1.45 GB 1.34 GB 1.02 GB (−24%)
Fluidd 1.01 GB 751 MB (−25%) 6.09 GB 4.67 GB 4.83 GB 3.66 GB (−24%)
Mainsail 997 MB 755 MB (−24%) 6.09 GB 4.67 GB 4.83 GB 3.66 GB (−24%)
OctoPrint 1.01 GB 751 MB (−25%) 5.96 GB 4.53 GB 4.73 GB 3.56 GB (−25%)
  • Download is the .img.xz file that Reflash fetches and writes.
  • Image unpacked is the size of the image once decompressed. Reflash writes it to the eMMC and then grows the root partition to fill it, so this is not the space taken on the board.
  • Used on the Recore is the space the installed system takes on the eMMC: the boot and root file systems together, as built. The rest of the 8 GB eMMC is free for your files, logs and G-code. A board shows slightly less in df, which leaves out file system overhead, and slightly more after first boot.
  • v1.2.0 figures are from the development build v1.1.0-26-g2334760, and may change before release.

Getting started

Install with Reflash v1.2.0 or newer

Install Rebuild v1.2.0 with Reflash v1.2.0 or newer; older versions of Reflash are not supported for it. They select the board's device tree with a link that kernel updates replace, and a board on the generic device tree can lose parts of the hardware - on an A6, Klipper could no longer reach the STM32. Rebuild v1.2.0 converts such a board when a kernel update arrives, but only installs from Reflash v1.2.0 are tested.

To check how a board selects its device tree, log in as debian and run:

grep fdtfile /boot/armbianEnv.txt

If nothing is printed, set the device tree for the board's revision once:

sudo update-recore-revision

Building firmware on the printer

The configurations Rebuild uses for its own firmware are installed with the image, in /usr/share/rebuild/firmware. To rebuild the STM32 firmware for a Recore A8 (32 KB flash):

sudo -u printer -i
cd ~/klipper
cp /usr/share/rebuild/firmware/stm32f031-32KB-serial.config .config
make olddefconfig
make
exit

The same directory has stm32f031-serial.config, for the 16 KB STM32 on earlier boards, and ar100.config. Flashing works as described in v1.1.0.

Use one or two build jobs

A Recore without a fan can reach its critical temperature with all four cores compiling, and it then powers itself off. Build with make -j2 or plain make, not make -j4.


AR100 toolchain

The AR100 firmware is compiled with an OpenRISC GCC toolchain installed in /opt/or1k-elf. v1.2.0 uses GCC 16.1.0, binutils 2.46 and newlib 4.6, built for the Recore from OpenRISC's own build scripts. The build and the changes made for Rebuild are in intelligent-agent/or1k-toolchain-build (branch rebuild), and the toolchain is downloaded from http://feeds.iagent.no/toolchains/.

Input shaper graphs

Klipper's resonance measurement does not need anything extra. SHAPER_CALIBRATE runs inside Klipper, measures both axes, recommends a shaper for each and saves it with SAVE_CONFIG. That works on v1.2.0 exactly as before.

The graphs are optional. They are drawn by Klipper's scripts (scripts/calibrate_shaper.py, scripts/graph_accelerometer.py), which need the Python plotting library matplotlib. v1.2.0 no longer installs it. There are two ways to get graphs.

Draw the graphs on your computer (recommended)

The picture is looked at on a computer anyway, so draw it there. First measure on the printer, from the console in Fluidd or Mainsail:

TEST_RESONANCES AXIS=X
TEST_RESONANCES AXIS=Y

Klipper writes the measurements to /tmp/resonances_x_*.csv and /tmp/resonances_y_*.csv on the printer. Copy them to your computer:

scp debian@recore.local:/tmp/resonances_*.csv .

Then, on the computer, with Python 3 installed:

git clone https://github.com/Klipper3d/klipper
python3 -m pip install numpy matplotlib
python3 klipper/scripts/calibrate_shaper.py resonances_x_*.csv -o shaper_calibrate_x.png
python3 klipper/scripts/calibrate_shaper.py resonances_y_*.csv -o shaper_calibrate_y.png

Install matplotlib on the printer

If you would rather draw the graphs on the printer, as described in Klipper's documentation, install matplotlib first, logged in as debian:

sudo apt update
sudo apt install python3-matplotlib

This takes about 240 MB. Klipper's scripts then work as described in its documentation.

Plugins that draw these graphs themselves, such as Shake&Tune, install their own copy of matplotlib and do not need either step.