Tag Archives: Debian

Klipper notes

Setup

I have multiple printers connected to my PC running Klipper: Creality Ender 5+, CR6-SE and Ender 3 S1 Pro.

I used kiauh, GitHub - dw-0/kiauh: Klipper Installation And Update Helper, to install 3 instances of Klipper, Moonraker, Mainsail and Fluidd.

I tried both Debian 12 and Ubuntu 22.04.3 LTS. kiauh successfully installed all of the packages on both OSes but I could not configure the USB ports correctly on Ubuntu. I didn’t capture the errors before I wiped the system and installed Debian. Will need to try again on a different system.

I now have a directory for each printer:

drwxr-xr-x 10 klipper klipper 4096 Sep 3 23:53 CR6SE_data
drwxr-xr-x 10 klipper klipper 4096 Sep 3 23:53 E3S1Pro_data
drwxr-xr-x 10 klipper klipper 4096 Sep 3 23:53 E5Plus_data

along with directories for the various components:

drwxr-xr-x 5 klipper klipper 4096 Sep 3 23:54 fluidd
drwxr-xr-x 3 klipper klipper 4096 Sep 3 23:54 fluidd-config
drwxr-xr-x 4 klipper klipper 4096 Sep 3 23:54 kiauh-backups
drwxr-xr-x 11 klipper klipper 4096 Sep 3 23:36 klipper
drwxr-xr-x 5 klipper klipper 4096 Sep 3 23:50 klippy-env
drwxr-xr-x 5 klipper klipper 4096 Sep 3 23:54 mainsail
drwxr-xr-x 3 klipper klipper 4096 Sep 3 23:54 mainsail-config
drwxr-xr-x 8 klipper klipper 4096 Sep 3 23:53 moonraker
drwxr-xr-x 4 klipper klipper 4096 Sep 3 23:53 moonraker-env

USB ports

Each time the PC boots, it assigns a different USB port to each printer (only two are connected right now)

klipper@klipper1:~$ sudo dmesg | grep ttyUSB
[ 5.580820] usb 1-2.4: FTDI USB Serial Device converter now attached to ttyUSB0
[ 5.581119] usb 1-2.2: ch341-uart converter now attached to ttyUSB1
[ 1213.719327] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[ 1215.624744] usb 1-2.4: FTDI USB Serial Device converter now attached to ttyUSB2
[ 2418.419348] ftdi_sio ttyUSB2: FTDI USB Serial Device converter now disconnected from ttyUSB2
[ 2420.328872] usb 1-2.4: FTDI USB Serial Device converter now attached to ttyUSB0

And the /dev/ttyUSB devices:

klipper@klipper1:~$ ls -ld /dev/ttyUSB*
crw-rw----+ 1 root dialout 188, 0 Sep 6 23:19 /dev/ttyUSB0
crw-rw----+ 1 root dialout 188, 1 Sep 6 23:25 /dev/ttyUSB1

The problem was, I thought I was being smart by specifying the USB port in printer.cfg, but which learned is most probably wrong after a reboot. Ex. for the E5Plus:

197 [mcu]
198 serial: /dev/ttyUSB2

And for the CR6-SE:

195 [mcu]
196 serial: /dev/ttyUSB1
197 restart_method: command

The correct thing to do is specify the /dev/serial/by-id

klipper@klipper1:/dev/serial/by-id$ ls -l /dev/serial/by-id
total 0
lrwxrwxrwx 1 root root 13 Sep 6 17:41 usb-1a86_USB_Serial-if00-port0 -> ../../ttyUSB1
lrwxrwxrwx 1 root root 13 Sep 6 23:19 usb-FTDI_FT232R_USB_UART_AB0KE6G5-if00-port0 -> ../../ttyUSB0

So for the E5Plus

[mcu]
serial: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AB0KE6G5-if00-port0

And the CR6-SE

[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command

I also discovered the udevadm command which provides a lot of information about a connected USB device

klipper@klipper1:~$ sudo udevadm info /dev/ttyUSB0
P: /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.4/1-2.4:1.0/ttyUSB0/tty/ttyUSB0
M: ttyUSB0
R: 0
U: tty
D: c 188:0
N: ttyUSB0
L: 0
S: serial/by-path/pci-0000:00:14.0-usb-0:2.4:1.0-port0
S: serial/by-id/usb-FTDI_FT232R_USB_UART_AB0KE6G5-if00-port0
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.4/1-2.4:1.0/ttyUSB0/tty/ttyUSB0
E: DEVNAME=/dev/ttyUSB0
E: MAJOR=188
E: MINOR=0
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=2420730776
E: ID_BUS=usb
E: ID_MODEL=FT232R_USB_UART
E: ID_MODEL_ENC=FT232R\x20USB\x20UART
E: ID_MODEL_ID=6001
E: ID_SERIAL=FTDI_FT232R_USB_UART_AB0KE6G5
E: ID_SERIAL_SHORT=AB0KE6G5
E: ID_VENDOR=FTDI
E: ID_VENDOR_ENC=FTDI
E: ID_VENDOR_ID=0403
E: ID_REVISION=0600
E: ID_TYPE=generic
E: ID_USB_MODEL=FT232R_USB_UART
E: ID_USB_MODEL_ENC=FT232R\x20USB\x20UART
E: ID_USB_MODEL_ID=6001
E: ID_USB_SERIAL=FTDI_FT232R_USB_UART_AB0KE6G5
E: ID_USB_SERIAL_SHORT=AB0KE6G5
E: ID_USB_VENDOR=FTDI
E: ID_USB_VENDOR_ENC=FTDI
E: ID_USB_VENDOR_ID=0403
E: ID_USB_REVISION=0600
E: ID_USB_TYPE=generic
E: ID_USB_INTERFACES=:ffffff:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=ftdi_sio
E: ID_VENDOR_FROM_DATABASE=Future Technology Devices International, Ltd
E: ID_MODEL_FROM_DATABASE=FT232 Serial (UART) IC
E: ID_PATH=pci-0000:00:14.0-usb-0:2.4:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_4_1_0
E: ID_FOR_SEAT=tty-pci-0000_00_14_0-usb-0_2_4_1_0
E: ID_MM_CANDIDATE=1
E: DEVLINKS=/dev/serial/by-path/pci-0000:00:14.0-usb-0:2.4:1.0-port0 /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AB0KE6G>
E: TAGS=:uaccess:systemd:seat:
E: CURRENT_TAGS=:uaccess:systemd:seat:
klipper@klipper1:~$ sudo udevadm info /dev/ttyUSB1
P: /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB1/tty/ttyUSB1
M: ttyUSB1
R: 1
U: tty
D: c 188:1
N: ttyUSB1
L: 0
S: serial/by-path/pci-0000:00:14.0-usb-0:2.2:1.0-port0
S: serial/by-id/usb-1a86_USB_Serial-if00-port0
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2.2/1-2.2:1.0/ttyUSB1/tty/ttyUSB1
E: DEVNAME=/dev/ttyUSB1
E: MAJOR=188
E: MINOR=1
E: SUBSYSTEM=tty
E: USEC_INITIALIZED=6202418
E: ID_BUS=usb
E: ID_MODEL=USB_Serial
E: ID_MODEL_ENC=USB\x20Serial
E: ID_MODEL_ID=7523
E: ID_SERIAL=1a86_USB_Serial
E: ID_VENDOR=1a86
E: ID_VENDOR_ENC=1a86
E: ID_VENDOR_ID=1a86
E: ID_REVISION=0264
E: ID_TYPE=generic
E: ID_USB_MODEL=USB_Serial
E: ID_USB_MODEL_ENC=USB\x20Serial
E: ID_USB_MODEL_ID=7523
E: ID_USB_SERIAL=1a86_USB_Serial
E: ID_USB_VENDOR=1a86
E: ID_USB_VENDOR_ENC=1a86
E: ID_USB_VENDOR_ID=1a86
E: ID_USB_REVISION=0264
E: ID_USB_TYPE=generic
E: ID_USB_INTERFACES=:ff0102:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=ch341
E: ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
E: ID_VENDOR_FROM_DATABASE=QinHeng Electronics
E: ID_MODEL_FROM_DATABASE=CH340 serial converter
E: ID_PATH=pci-0000:00:14.0-usb-0:2.2:1.0
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_2_2_1_0
E: ID_FOR_SEAT=tty-pci-0000_00_14_0-usb-0_2_2_1_0
E: ID_MM_CANDIDATE=1
E: DEVLINKS=/dev/serial/by-path/pci-0000:00:14.0-usb-0:2.2:1.0-port0 /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
E: TAGS=:seat:uaccess:systemd:
E: CURRENT_TAGS=:seat:uaccess:systemd:

Powering off the printers

If I power off the AC to the printers, the fans and motors turn off but their mainboards are still powered via the USB from the PC. The E5Plus’ screen remains lit but the CR6SE’s screen flickers annoyingly. So, I unplug the USB cables from the PC. The PC detects the disconnect and removes the USB devices:

klipper@klipper1:~$ sudo dmesg | grep USB
...
[ 7192.491354] ch341-uart ttyUSB1: usb_serial_generic_read_bulk_callback - urb stopped: -32
[ 7192.491871] ch341-uart ttyUSB1: usb_serial_generic_read_bulk_callback - urb stopped: -32
[ 7192.545458] usb 1-2.2: USB disconnect, device number 5
[ 7192.548319] ch341-uart ttyUSB1: ch341-uart converter now disconnected from ttyUSB1
[ 7193.313261] usb 1-2.4: USB disconnect, device number 6
[ 7193.314428] ftdi_sio ttyUSB2: FTDI USB Serial Device converter now disconnected from ttyUSB2

Changing the printer name in fluidd

By default, every printer is called fluidd, which is confusing because you have to remember which moonraker port each printer is connected to (7125, 7126, etc)

In the web GUI, go to Settings (the gear icon):

Then change the Printer Name:

The change happens as soon as you hit return – there is no Save button.

The printer name is stored in ~/printer_data/databases/data.mdb. I can see it with strings:

klipper@klipper1:~/E5Plus_data/database$ strings data.mdb
fluidd
authorized_users
update_manager
history
announcements
uiSettings{"general": {"instanceName": "E5Plus"}}
layout
cameras{}

But I cannot find it in the dump created by mdb_dump. First install lmdb-utils:

klipper@klipper1:~/E5Plus_data/database$ sudo apt install lmdb-utils
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
The following packages were automatically installed and are no longer required:
libmdb3 libmdbsql3
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
lmdb-utils
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 63.5 kB of archives.
After this operation, 389 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bookworm/main amd64 lmdb-utils amd64 0.9.24-1 [63.5 kB]
Fetched 63.5 kB in 0s (305 kB/s)
Selecting previously unselected package lmdb-utils.
(Reading database … 174663 files and directories currently installed.)
Preparing to unpack …/lmdb-utils_0.9.24-1_amd64.deb …
Unpacking lmdb-utils (0.9.24-1) …
Setting up lmdb-utils (0.9.24-1) …
Processing triggers for man-db (2.11.2-2) …

Then run mdb_dump. Note the trailing period:

klipper@klipper1:~/E5Plus_data/database$ cd ~/E5Plus_data/database
klipper@klipper1:~/E5Plus_data/database$ ls -l
total 88
-rw-r--r-- 1 klipper klipper 81920 Sep 6 23:00 data.mdb
-rw-r--r-- 1 klipper klipper 8192 Sep 7 00:07 lock.mdb
klipper@klipper1:~/E5Plus_data/database$ mdb_dump -f moonraker.txt -a .
klipper@klipper1:~/E5Plus_data/database$ fgrep E5Plus moonraker.txt
klipper@klipper1:~/E5Plus_data/database$ fgrep uiSetting moonraker.txt
klipper@klipper1:~/E5Plus_data/database$