Difference between revisions of "Refactor"

From iagent
Jump to: navigation, search
(Upgrading Refactor from the command line)
 
(21 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
</div>
 
</div>
  
Refactor is the next generation of controller board software stack installation.
+
Refactor is a complete Linux image for Recore 3D printer controller boards. It comes with Klipper installed and the choice of either MainSail or OctoPrint.  
  
It is meant to simplify the lives of new users when they begin using a Thing-Printer controller board. Pre-built images of Refactor are available for users who want to get up and running quickly with Recore.
+
These instructions are for version v3.2. For older versions of Refactor:
 
+
* [[Refactor_v3.1.3]]
Refactor is available in two verisons: Recore OctoPrint and Recore Mainsail, with updates being propagated simultaneously for both images. Refactor v3.0.3 has support for Replicape and only Recore with OctoPrint.
 
 
 
These instructions are for version v3.1.1. For older versions of Refactor:
 
 
* [[Refactor_v3.0.3]]
 
* [[Refactor_v3.0.3]]
* [[Refactor_v3.0.2]]
 
  
 
=Installing an image=
 
=Installing an image=
 
For instructions on making a flasher image, have a look at [[Reflash]]
 
For instructions on making a flasher image, have a look at [[Reflash]]
 +
<div class="alert alert-warning">
 +
===='''Note'''====
 +
In order to install Refactor v3.2.x, you need to use Reflash v0.1.2 or newer.
 +
</div>
  
 
=Latest images=
 
=Latest images=
Line 20: Line 20:
  
 
=Installed software=
 
=Installed software=
 +
The Recore version is based on Armbian, Debian Buster. On top of that, Refactor comes preinstalled
 +
with a stack of programs to simplify setting up a new controller board.
 +
* Klipper (v0.12.0-13-g795ce490) https://github.com/Klipper3d/klipper
 +
* Ustreamer (master)  https://github.com/pikvm/ustreamer
 +
* Linux (5.15.113-sunxi64) https://github.com/armbian/build
 +
* u-boot (2022.10) https://github.com/armbian/build
 +
 
==Recore OctoPrint==
 
==Recore OctoPrint==
The Recore version is based on Armbian, Debian Buster. On top of that, Refactor comes preinstalled
+
* OctoPrint (1.9.3) https://github.com/OctoPrint/OctoPrint
with a stack of programs to simplify setting up a new controller board.
+
** Octoprint Klipper (0.3.9.5) https://github.com/thelastWallE/OctoprintKlipperPlugin
* OctoPrint (1.7.3) https://github.com/OctoPrint/OctoPrint
 
** Octoprint Klipper (master) https://github.com/thelastWallE/OctoprintKlipperPlugin
 
 
** Octoprint Refactor (main) https://github.com/intelligent-agent/octoprint_refactor
 
** Octoprint Refactor (main) https://github.com/intelligent-agent/octoprint_refactor
 
** OctoPrint Toggle (master) https://github.com/intelligent-agent/octoprint_toggle
 
** OctoPrint Toggle (master) https://github.com/intelligent-agent/octoprint_toggle
 
** OctoPrint Top Temp (master) https://github.com/LazeMSS/OctoPrint-TopTemp.git
 
** OctoPrint Top Temp (master) https://github.com/LazeMSS/OctoPrint-TopTemp.git
* Klipper (v0.10.0) https://github.com/intelligent-agent/klipper
 
 
* Toggle (v1.4.1) https://github.com/intelligent-agent/toggle
 
* Toggle (v1.4.1) https://github.com/intelligent-agent/toggle
* Mjpeg streamer (master)  https://github.com/xeno14/mjpg-streamer
 
* Linux (5.15.25) https://github.com/intelligent-agent/build
 
* u-boot (v2020.10) https://github.com/intelligent-agent/u-boot
 
  
 
==Recore Mainsail==
 
==Recore Mainsail==
 
The Recore version is based on Armbian, Debian Buster. On top of that, Refactor comes preinstalled  
 
The Recore version is based on Armbian, Debian Buster. On top of that, Refactor comes preinstalled  
 
with a stack of programs to simplify setting up a new controller board.  
 
with a stack of programs to simplify setting up a new controller board.  
* Mainsail  (v2.1.2) https://github.com/mainsail-crew/mainsail
+
* Mainsail  (v2.6.0) https://github.com/intelligent-agent/mainsail
* Moonraker (master) https://github.com/Arksine/moonraker
+
* Moonraker (v0.8.0) https://github.com/Arksine/moonraker
* Klipper (v0.10.0) https://github.com/intelligent-agent/klipper
+
* KlipperScreen (v0.3.2-22) https://github.com/intelligent-agent/KlipperScreen
* KlipperScreen (3b4555b) https://github.com/intelligent-agent/KlipperScreen
 
* Mjpeg streamer (master)  https://github.com/xeno14/mjpg-streamer
 
* Linux (5.15.25) https://github.com/intelligent-agent/build
 
* u-boot (v2020.10) https://github.com/intelligent-agent/u-boot
 
  
 
=Getting started=
 
=Getting started=
Line 56: Line 53:
 
After the wizard is done, go to the Klipper tab in OctoPrint and edit the Klipper config file.  
 
After the wizard is done, go to the Klipper tab in OctoPrint and edit the Klipper config file.  
 
This is where the bulk of the work will happen.  
 
This is where the bulk of the work will happen.  
 +
 +
On the MainSail image, there should not need to be any configuration necessary. Verify that the web interface comes up and that Klipper is running as expected.
  
 
== Klipper configuration ==
 
== Klipper configuration ==
 
There is a standard klipper configuration file that comes with Refactor. The configuration file is set up  
 
There is a standard klipper configuration file that comes with Refactor. The configuration file is set up  
to work out of the box, but it assumes that there is a 100 K ntc thermistor on analog inputs T0 and T3 (bed).  
+
to work out of the box without anything connected. The default Klipper config can be used as a starting point for building a custom config file for the printer at hand.  
If these are not present, Klipper will halt with a warning.
 
 
 
The default klipper config can be used as a starting point for building a custom config file for the printer at hand.  
 
  
 
After the Klipper configuration is complete, do a test print to make sure everything is working.  
 
After the Klipper configuration is complete, do a test print to make sure everything is working.  
 +
<div class="alert alert-warning">
 +
===='''Note'''====
 +
On Refactor 3.2.x, all hardware revisions communicate with the MCU (STM32) on UART /dev/ttyS2. This was different on previous versions of Refactor.
 +
</div>
  
 
=== Recore booting ===
 
=== Recore booting ===
Line 80: Line 80:
 
# Linux will load the rootfs from eMMC.
 
# Linux will load the rootfs from eMMC.
  
===Booting Recore from eMMC, but load rootfs from USB===
+
===Loading u-boot from eMMC but load kernel and rootfs from USB===
<div class="alert alert-warning">
 
===='''Note'''====
 
Using a root file system on a different drive work well if the kernel version is the same on both media.
 
The kernel version has changed between Refactor v3.0.2-RC3 and v3.0.2-RC4. The board will still boot, but will not load
 
kernel modules as expected, including nft that maps OctoPrint to the HTTP port (80).
 
</div>
 
 
 
 
If the board is working normally and you are able to log in through ssh, but want to try out a new  
 
If the board is working normally and you are able to log in through ssh, but want to try out a new  
 
Refactor version you can let the rootfs be loaded from a USB drive (mass storage device):
 
Refactor version you can let the rootfs be loaded from a USB drive (mass storage device):
Line 133: Line 126:
 
This should upload u-boot from the host computer to the board via the USB cable. u-boot will then boot from the connected USB drive.  
 
This should upload u-boot from the host computer to the board via the USB cable. u-boot will then boot from the connected USB drive.  
 
Please note that in some instances, the USB drive is not detected as a mass storage device without also having the VIN power connector inserted. See more in [[Recore_A6#USB_connectors_not_discovered_when_powered_by_USB_device|in the "known errors" section of Recore A6]]
 
Please note that in some instances, the USB drive is not detected as a mass storage device without also having the VIN power connector inserted. See more in [[Recore_A6#USB_connectors_not_discovered_when_powered_by_USB_device|in the "known errors" section of Recore A6]]
 
==Upgrading Refactor==
 
After upgrading refactor, if the recore board is A5 or older, you can set the device tree to a different version by running the command
 
<pre>
 
use-recore-revision a5
 
</pre>
 
After a reboot, you can check that the loaded device tree matches the revision of firmware.
 
<pre>
 
cat /sys/firmware/devicetree/base/model
 
</pre>
 
It's also worth noting that the klipper configuration is a bit different between the A5 and A6 revisions. The A6 is the now the default configuration, but A5 is also present for use. It can be found on github or on the board.
 
<pre>
 
cat /home/debian/klipper/config/generic-recore-a5.cfg
 
</pre>
 
  
 
===Upgrading Debian via apt upgrade===
 
===Upgrading Debian via apt upgrade===
The /boot partition of Refactor is mounted Read Only, so it will have to be remounted as Read Write before running an upgrade:  
+
The /boot partition of Refactor is mounted Read Only, so it will have to be remounted as Read Write before running an upgrade. This is handled automatically by apt in this version:  
 
<pre>
 
<pre>
sudo mount -o remount,rw /boot
+
sudo apt update
 +
sudo apt upgrade
 
</pre>
 
</pre>
  
Line 171: Line 151:
 
'''Note''': Reflash may not show up with the same IP as your previous ReFactor instance did. It will depend on your router's DHCP, so be sure to check if the IP has changed, even if the MAC has not.
 
'''Note''': Reflash may not show up with the same IP as your previous ReFactor instance did. It will depend on your router's DHCP, so be sure to check if the IP has changed, even if the MAC has not.
  
==Using Moonraker and Mainsail instead of OctoPrint==
+
 
<div class="res-img">
+
=== Enable host mode on the USB-C connector ===
[[File:Mainsail.png]]
 
</div>
 
It is possible to switch to using Mainsail as user interface to control the printer instead of OctoPrint.
 
The best way to do that is by running some install scripts on the command line:
 
 
<pre>
 
<pre>
sudo /home/debian/install-mainsail.sh
+
sudo mount -o remount,rw /boot
sudo /home/debian/install-moonraker.sh
+
sudo armbian-add-overlay /boot/overlay-user/sun50i-a64-usb-host.dts
sudo enable-mainsail
+
sudo mount -o remount,ro /boot
 
</pre>
 
</pre>
  
After that Mainsail should be available from http://recore.local
+
==Using Moonraker and Mainsail==
 
+
<div class="res-img">
<div class="alert alert-info">
+
[[File:Mainsail.png]]
===='''Info'''====
 
You might have to change the settings of Moonraker to allow your host computer to access the
 
user interface. Check that the IP of your host computer is allowed in the moonraker.conf
 
</div>
 
  
To change the allowed IP range run:
+
==Using KlipperScreen==
 +
KlipperScreen is running on X, so a new config should allow rotating the screen.
 
<pre>
 
<pre>
nano /home/debian/moonraker.conf
+
sudo nano /usr/share/X11/xorg.conf.d/90-monitor.conf
 
</pre>
 
</pre>
 
+
Add the following:
Then restart moonraker.
 
 
<pre>
 
<pre>
systemctl restart moonraker
+
Section "Monitor"
 +
    Identifier "HDMI-1"
 +
    Option "Rotate" "left"
 +
EndSection
 
</pre>
 
</pre>
 
+
After that, KlipperScreen can be restarted.  
==Using KlipperScreen instead of Toggle==
 
With version 3.0.4, KlipperScreen can be installed. Use SSH to get access to Recore, then run the following command:
 
 
<pre>
 
<pre>
install-klipperscreen
+
sudo systemctl restart KlipperScreen
 
</pre>
 
</pre>
  
Make sure you update /home/debian/moonraker.conf to allow for 127.0.0.1:
+
If it is necessary to rotate the touch panel as well, here is a useful section that can be added to the bottom of that same file. Uncomment the rotation that matches your setup.
<pre>
 
nano /home/debian/moonraker.conf
 
</pre>
 
 
<pre>
 
<pre>
[authorization]
+
Section "InputClass"
trusted_clients:
+
            Identifier "Coordinate Transformation Matrix"
  127.0.0.1
+
            MatchIsTouchscreen "on"
</pre>
+
            MatchDevicePath "/dev/input/event*"
 +
            MatchDriver "libinput"
 +
            Option "CalibrationMatrix" "1 0 0 0 1 0 0 0 1"    # 0 degrees
 +
            #Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"  # 90 degrees
 +
            #Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1" # 180 degrees
 +
            #Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"  # 270 degrees
  
Weston might be rotated by default. To change rotation:
+
EndSection
<pre>
 
nano /etc/xdg/weston/weston.ini
 
 
</pre>
 
</pre>
The rotation should be 0
 
  
 
==Recompiling and installing binaries==
 
==Recompiling and installing binaries==
Line 243: Line 215:
 
To configure klipper for AR100 and build the binary:
 
To configure klipper for AR100 and build the binary:
 
<pre>
 
<pre>
export PATH=$PATH:/opt/output/bin
 
 
cd /home/debian/klipper/
 
cd /home/debian/klipper/
 
cp test/configs/ar100.config .config
 
cp test/configs/ar100.config .config
Line 268: Line 239:
 
https://github.com/richfelker/musl-cross-make
 
https://github.com/richfelker/musl-cross-make
  
GCC version: 9.2.0
+
GCC version: 11.2.0
  
 
====Cross compilation toolchain for x86_64====
 
====Cross compilation toolchain for x86_64====
Line 276: Line 247:
  
  
====STM32 firmware====
+
===STM32 firmware===
 
 
<div class="alert alert-warning">
 
===='''Note'''====
 
The latest Refactor now does automatic flashing of the STM32 firmware on first boot after a fresh install. This was merged with PR#199 in Refactor on Github.
 
</div>
 
  
 
The firmware for the stm32f031 mcu that is responsible for ADC  
 
The firmware for the stm32f031 mcu that is responsible for ADC  
Line 305: Line 271:
 
cp out/klipper.bin /opt/firmware/stm32.bin
 
cp out/klipper.bin /opt/firmware/stm32.bin
 
sudo flash-stm32
 
sudo flash-stm32
</pre>
 
 
=== Replicape ===
 
 
The Replicape images will be meant to run from the micro SD you flash it to. You cannot boot the Replicape from a USB key at this time.
 
By default, Refactor images do not flash to the eMMC the way Umikaze used to. Part of this is historical - the early betas of Refactor did not fit on the eMMC, but there's another advantage as well: it allows you to test out Refactor on an SD card while keeping your working Redeem config on the eMMC.
 
 
==== Booting Refactor from USB ====
 
If you want to boot Refactor from a USB stick, you need to stop u-boot by pressing space during boot.
 
You must run these commands:
 
<pre>
 
setenv bootpart 0:1; setenv oldroot /dev/sda1; setenv devnum 0; run usb_boot
 
 
load ${devtype} ${bootpart} ${loadaddr} /boot/uEnv.txt; env import -t ${loadaddr} ${filesize}
 
 
run uname_boot
 
 
</pre>
 
</pre>
  
Line 341: Line 291:
 
===Running Toggle===
 
===Running Toggle===
 
Toggle is started automatically by the systemd service toggle.service. A user is created for Toggle on first boot, but the credentials are not set until a user is created in OctoPrint. Once the wizard has been completed, the Toggle user is active, but the credentials will not be valid until OctoPrint is restarted. Therefore, if Toggle is needed, restart OctoPrint after the wizard is complete.
 
Toggle is started automatically by the systemd service toggle.service. A user is created for Toggle on first boot, but the credentials are not set until a user is created in OctoPrint. Once the wizard has been completed, the Toggle user is active, but the credentials will not be valid until OctoPrint is restarted. Therefore, if Toggle is needed, restart OctoPrint after the wizard is complete.
 +
 +
Toggle is running on Weston, so a new config should allow rotating the screen.
 +
<pre>
 +
sudo nano /etc/xdg/weston/weston.ini
 +
</pre>
 +
Edit the section about rotation:
 +
<pre>
 +
[output]
 +
name=HDMI-A-1
 +
transform=rotate-90
 +
</pre>
 +
After that, Weston can be restarted.
 +
<pre>
 +
sudo systemctl restart weston
 +
</pre>
 +
 +
See the Ubuntu documentation for valid rotations: [https://manpages.ubuntu.com/manpages/jammy/man5/weston.ini.5.html weston.ini]
  
 
===Running OctoPrint===
 
===Running OctoPrint===

Latest revision as of 13:45, 15 December 2023

Refactor header 2.png

Refactor is a complete Linux image for Recore 3D printer controller boards. It comes with Klipper installed and the choice of either MainSail or OctoPrint.

These instructions are for version v3.2. For older versions of Refactor:

Installing an image

For instructions on making a flasher image, have a look at Reflash

Note

In order to install Refactor v3.2.x, you need to use Reflash v0.1.2 or newer.

Latest images

The latest images for Recore and Replicape are available from github: https://github.com/intelligent-agent/Refactor/releases

Installed software

The Recore version is based on Armbian, Debian Buster. On top of that, Refactor comes preinstalled with a stack of programs to simplify setting up a new controller board.

Recore OctoPrint

Recore Mainsail

The Recore version is based on Armbian, Debian Buster. On top of that, Refactor comes preinstalled with a stack of programs to simplify setting up a new controller board.

Getting started

It can be a good idea to test the board on the bench before installing it in the printer. Use the USB-C connector to power the board.

Once the board is powered up, use a computer to access the web interface provided by OctoPrint. In order to get access to OctoPrint, a network cable must be connected to the board and to a network switch. It is also possible to use a wifi dongle. If a network cable is used, the board should respond to the address: http://recore.local

Once the OctoPrint interface is visible, run through the wizard to set up a new printer. After the wizard is done, go to the Klipper tab in OctoPrint and edit the Klipper config file. This is where the bulk of the work will happen.

On the MainSail image, there should not need to be any configuration necessary. Verify that the web interface comes up and that Klipper is running as expected.

Klipper configuration

There is a standard klipper configuration file that comes with Refactor. The configuration file is set up to work out of the box without anything connected. The default Klipper config can be used as a starting point for building a custom config file for the printer at hand.

After the Klipper configuration is complete, do a test print to make sure everything is working.

Note

On Refactor 3.2.x, all hardware revisions communicate with the MCU (STM32) on UART /dev/ttyS2. This was different on previous versions of Refactor.

Recore booting

Recore comes with Refactor pre-installed.

The Recore images will need to be flashed to a USB flash drive, as there is no SD slot on the board. Recore's uboot is designed to attempt to boot from a USB drive if there is no OS on the eMMC.

There are several stages to booting Recore, and depending on which media is installed, the boot process will try and boot either from eMMC, USB host or USB device.

Booting Recore from eMMC (the normal way)

  1. Turn on power
  2. The BROM will load u-boot SPL from eMMC
  3. The u-boot SPL will load u-boot
  4. u-boot will load Linux
  5. Linux will load the rootfs from eMMC.

Loading u-boot from eMMC but load kernel and rootfs from USB

If the board is working normally and you are able to log in through ssh, but want to try out a new Refactor version you can let the rootfs be loaded from a USB drive (mass storage device):

  1. Download Refactor and flash it to a USB drive
  2. Insert the USB drive in the board.
  3. Boot the board normally
    1. Open the Refactor tab in OctoPrint.
    2. Select run from USB
    or
    1. Use SSH to log into the board: ssh root@recore.local
    2. Run the command set-boot-media usb
  4. Reboot

The board should now be have the rootfs from the USB drive.

Booting Recore from USB, load Linux kernel from USB drive

This method requires a UART to USB adapter that can plug into a host computer. There is a 4 pin header on Recore marked DBG, where UART 0 is routed. All u-boot and kernel messages will appear here. The baud rate is 115200. If the eMMC is partitioned and has an OS, u-boot will launch right into that. In order to override that and load the boot script from a USB drive, stop u-boot by pressing a key and then write:

  1. Download Refactor and flash it to a USB drive
  2. Insert the USB drive in the board and apply power
  3. When the boot process gets to u-boot, you will see: Hit any key to stop autoboot:
  4. Hit the Any key.
  5. Then write run bootcmd_usb0

This will load the U-boot script from the USB drive and use the USB drive as the rootfs.

Boot Recore from a USB stick using the FEL button

If u-boot should be loaded from a host computer and kernel and rootfs is loaded from a USB drive:

  1. Flash the Reflash Linux distro to a USB drive.
  2. Insert the USB drive in the Recore board in one of the two host connectors close to the HDMI.
  3. Hold down the FEL button while applying power to the board via the USB-C connector.
  4. Download the Recore repository https://github.com/intelligent-agent/Recore
  5. Install the sunxi-tools program
  6. Run the fel command (make fel) from the host computer. All the necessary binarys are in the Recore repository:

You can read more about the steps needed to boot aboard in FEL mode on the Sunxi wiki: https://linux-sunxi.org/FEL

Note: Depending on what linux platform you're running from, sunxi-tools will require the following dependencies to compile properly:

  • libftd-dev
  • libusbx-dev
  • libudev-dev

(These are Debian/ubuntu names. For Fedora, change -dev to -devel)

This should upload u-boot from the host computer to the board via the USB cable. u-boot will then boot from the connected USB drive. Please note that in some instances, the USB drive is not detected as a mass storage device without also having the VIN power connector inserted. See more in in the "known errors" section of Recore A6

Upgrading Debian via apt upgrade

The /boot partition of Refactor is mounted Read Only, so it will have to be remounted as Read Write before running an upgrade. This is handled automatically by apt in this version:

sudo apt update
sudo apt upgrade

Upgrading Refactor from OctoPrint

The only way to upgrade Refactor is by flashing a new version. In OctoPrint there is a "Refactor" plugin that can aid with this. If Refactor is run from a USB stick, a new version of can be downloaded and flashed on the eMMC.

Refactor-tab.png

There is a separate image used for upgrading Refactor. Take a look at Reflash

Upgrading Refactor from the command line

To reboot into a USB drive:

set-boot-media usb
reboot

Note: Reflash may not show up with the same IP as your previous ReFactor instance did. It will depend on your router's DHCP, so be sure to check if the IP has changed, even if the MAC has not.


Enable host mode on the USB-C connector

sudo mount -o remount,rw /boot
sudo armbian-add-overlay /boot/overlay-user/sun50i-a64-usb-host.dts
sudo mount -o remount,ro /boot

Using Moonraker and Mainsail

Mainsail.png

Using KlipperScreen

KlipperScreen is running on X, so a new config should allow rotating the screen.

sudo nano /usr/share/X11/xorg.conf.d/90-monitor.conf

Add the following:

Section "Monitor"
    Identifier "HDMI-1"
    Option "Rotate" "left"
EndSection

After that, KlipperScreen can be restarted.

sudo systemctl restart KlipperScreen

If it is necessary to rotate the touch panel as well, here is a useful section that can be added to the bottom of that same file. Uncomment the rotation that matches your setup.

Section "InputClass"
            Identifier "Coordinate Transformation Matrix"
            MatchIsTouchscreen "on"
            MatchDevicePath "/dev/input/event*"
            MatchDriver "libinput"
            Option "CalibrationMatrix" "1 0 0 0 1 0 0 0 1"    # 0 degrees
            #Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"  # 90 degrees
            #Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1" # 180 degrees
            #Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"  # 270 degrees

EndSection

Recompiling and installing binaries

Update u-boot on Recore

This is not something the regular user would need to do, but documented here for convenience. Place u-boot-sunxi-with-spl.bin in sector 15 (8KB offset) Flash the binary

dd if=u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8 conv=notrunc

Note: U-boot needs to be patched in order to use the eMMC as the first (and only) boot device. The changes can be done in "spl_mmc_get_device_index" where dev_num should be 0 instead of 1.

AR100 firmware

The AR100 CPU needs a binary file that is loaded on startup by the systemd file klipper.service The AR100 binary file comes pre-compiled in Refactor, so most users should not have to re-compile it. For experiments the AR100 binary can be recompiled on Recore (architecture aarch64) or on a host computer (amd64 or similar).

Compiling the ar100 binary

To configure klipper for AR100 and build the binary:

cd /home/debian/klipper/
cp test/configs/ar100.config .config
make olddefconfig
make

This will produce a bin file located in out/ar100.bin, so it should be moved to /opt/firmware

mv out/ar100.bin /opt/firmware/

Once the AR100 binary has been updated, klipper.service can be restarted which then loads the new AR100 binary.

systemctl restart klipper

Cross compilation toolchain for ARM64

The AR100 needs a cross compilation toolchain. For ARM64, it can be downloaded from feeds.iagent.no:

http://feeds.iagent.no/toolchains/

The toolchain has been built with

https://github.com/richfelker/musl-cross-make

GCC version: 11.2.0

Cross compilation toolchain for x86_64

The toolchain used during automatic testing and is the same used for the CRUST firmware project:

https://github.com/crust-firmware/crust#building-the-firmware


STM32 firmware

The firmware for the stm32f031 mcu that is responsible for ADC conversions and PWM for heaters and fans comes pre-installed in the flash of the MCU. It can be recreated on the board using the Klipper build system.

cd /home/debian/klipper
cp test/configs/stm32f031.config .config
make menuconfig
-> Enable extra low-level configuration options
-> Processor model (STM32F031)
-> Bootloader offset (No bootloader)
-> Clock Reference (Internal clock)
-> (16) Internal clock trim override
-> Communication interface (Serial (on USART2 PA15/PA14))
-> Baud rate for serial port: 250000
make

Flashing STM32 firmware

To flash the STM32 firmware:

cp out/klipper.bin /opt/firmware/stm32.bin
sudo flash-stm32

Running Klipper

Klipper is run as a systemd service. It should not normally need to be restarted from the command line, but during development it can be necessary.

systemctl restart klipper

The log for Klipper is located in /tmp. It can be viewed as:

tail -f /tmk/klippy.log

Klipper can also be restarted from the OctoPrint interface. On the "Klipper" tab, press "Firmware" to restart the Klipper firmware.

Klipper-firmware-press.png

Running Toggle

Toggle is started automatically by the systemd service toggle.service. A user is created for Toggle on first boot, but the credentials are not set until a user is created in OctoPrint. Once the wizard has been completed, the Toggle user is active, but the credentials will not be valid until OctoPrint is restarted. Therefore, if Toggle is needed, restart OctoPrint after the wizard is complete.

Toggle is running on Weston, so a new config should allow rotating the screen.

sudo nano /etc/xdg/weston/weston.ini

Edit the section about rotation:

[output]
name=HDMI-A-1
transform=rotate-90

After that, Weston can be restarted.

sudo systemctl restart weston

See the Ubuntu documentation for valid rotations: weston.ini

Running OctoPrint

OctoPrint is stated on boot. If there is a need to restart the daemon, use this command

systemctl restart octoprint

Refactor build system

Refactor uses Ansible as the underlying framework to describe the desired system state. There are many reasons for this:

  1. Ansible describes the system's end state, not individual actions to perform, so it is relatively easy to port across platforms (i.e. debian, arch, BSD...)
  2. The Refactor repository can be updated from the git repository and Ansible will only change what has been updated from the previous version, not needing a complete reinstallation of the system for upgrades.
  3. Description of components is modular, making it easy to pick and choose different components for the end goal desired, while keeping each component's setup independent and reliable, and independently updatable.