Steps to install MainsailOS onto a Raspberry Pi, and flash the Klipper firmware onto a Creality CR10-Mini controller board (Melzi 1.1.2 Atmega1284p).
This configuration is intended to set up a Raspberry Pi 3B+ that can be connected to via WiFi and SSH; ie. no ethernet cable or monitor!
NB: Before attempting to flash Klipper firmware onto the CR-10, the board needs a bootloader. See https://gist.github.com/x45dev/edfa3985cb5c7ce3b5835f7493d62060
- PC with SSH client. This guide uses a Linux workstation - Ubuntu 21.04.
- Raspberry Pi 3B+
sudo apt update
sudo apt install snapd
sudo snap install rpi-imager
- Insert a SD card into PC or connect it using an adapter. There’s no need to format the SD card prior, but any existing contents will be wiped.
- Open the Raspberry Pi Imager and click on “Choose OS” under “Operating Systems”.
- Then go to “Other specific purpose OS > MainsailOS”. There should be the latest version.
- Back on the main window, click on “Choose Storage” and select the SD card.
- Open advanced options by using the keyboard shortcut "Ctrl" + "Shift" + "X" to configure your Wifi connection.
- Ensure that SSH is enabled.
- Click “Write” and the Raspberry Pi Imager will download and install the MainsailOS image.
4. From PC, connect to the RPi via SSH. (Try mainsailos.local as an address, or check your router for its DHCP-assigned IP address)
user@workstation:~ $ ssh pi@mainsailos.local
# Defaults:
# username: pi
# password: raspberry
# Update Mainsail
- a. Connect to Mainsail UI from PC browser via HTTP endpoint: `http://mainsailos.local` (if exists in router hosts) or via LAN private IP.
- b. Menu item: "Machine"
Update Manager: "Check for Updates"
Then select "Update all components" at the bottom of the list.
# Update Raspbian
pi@mainsailos:~ $ sudo raspi-config
Menu item: "8. Update"
Then <Finish>
# Configure Klipper
pi@mainsailos:~ $ cp ./klipper/config/printer-creality-cr10mini-2017.cfg ~/printer_data/config/printer.cfg
# Add `[include mainsail.cfg]` to the top of printer-*.cfg
# and then **then restart via the Mainsail UI**.
pi@mainsailos:~ $ echo "[include mainsail.cfg]" | cat - ./printer_data/config/printer.cfg > temp && mv temp ./printer_data/config/printer.cfg
NB: The comments at the top of the printer configuration file should describe the settings that need to be set during "make menuconfig".
The following settings were used for the CR10 Mini Melzi V1.1.2 Atmega1284p board.
pi@mainsailos:~ $ cd ~/klipper/
pi@mainsailos:~ $ make menuconfig
[*] Enable extra low-level configuration options
Micro-controller Architecture (Atmega AVR) --->
Processor model (atmega1284p) --->
Processor speed (16Mhz) --->
Communication interface (UART0) --->
[ ] Compile for simulavr software emulation (NEW)
(115200) Baud rate for serial port
() GPIO pins to set at micro-controller startup (NEW)
# Obtain USB serial UUID
# In my case, it is /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A906V745-if00-port0
# Alternatively, you could also try device '/dev/ttyUSB0'
# For additional device diagnostics, use `lsusb` and `usb-devices` commands.
pi@mainsailos:~ $ ls /dev/serial/by-id/*
# Flash it!
pi@mainsailos:~ $ make flash FLASH_DEVICE=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A906V745-if00-port0
# Update printer.cfg
# Perform a *firmware restart* (via Mainsail UI) after editing this file.
pi@mainsailos:~ $ nano ~/printer_data/config/printer.cfg
# Add/replace under [mcu]:
serial: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A906V745-if00-port0
baud: 115200
restart_method: command
Make sure to reset your EEPROM on your printer after flashing any firmware. You can do this from your printer LCD by going to Configuration -> Reset EEPROM or by sending an M502 followed by M500 with your favorite Gcode sender application.
pi@mainsailos:~ $ curl -X POST http://localhost:7125/printer/gcode/script?script=M502
pi@mainsailos:~ $ curl -X POST http://localhost:7125/printer/gcode/script?script=M500
Note: I had previously attempted to write code directly to /tmp/printer. This didn't work in the end. At first attempt, /tmp/printer didn't exist, but when I sent it a MainsailOS 'STATUS' command, it was created. Nevertheless, the syntax echo <my-gcode-command> >> /tmp/printer had no effect. (Test this with the "zero all axes" command, G28.)
Done!! :)