Close

OctoPrint to Running Klipper

A project log for Klipper 3D Printer Firmware on Malyan M180 Install

I'm trying to install Klipper on my modified Malyan M180 3D Printer. Currently, Marlin is installed but it has loads of performance issues.

timo-birnscheinTimo Birnschein 12/18/2021 at 15:170 Comments

Install Octoprint from here: https://github.com/guysoft/OctoPi

Clone Klipper: git clone https://github.com/Klipper3d/klipper

Run the install script and run into an error: 

./klipper/scripts/install-octopi.sh

 Error:

###### Running apt-get update...
[sudo] password for pi:
Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Get:2 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
Reading package lists... Done
E: Repository 'http://archive.raspberrypi.org/debian buster InRelease' changed its 'Suite' value from 'testing'     to 'oldstable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage     for details.

This can be mitigated by running:

sudo apt-get update --allow-releaseinfo-change

 Then run

./klipper/scripts/install-octopi.sh

again. This time it should go though as expected. It will download all the dependencies that Klipper needs to run and configure it to load at startup with OctoPi.

Then follow the steps from the Klipper install manual: https://www.klipper3d.org/Installation.html

The install manual will ask you to run make menuconfig, configure the three items and then run make. However, this just resulted in an error for me:

Rempi@octopi-klipper:~/klipper $ make
  Building out/autoconf.h
  Compiling out/src/sched.o
  Compiling out/src/command.o
  Compiling out/src/basecmd.o
  Compiling out/src/debugcmds.o
  Compiling out/src/initial_pins.o
  Compiling out/src/gpiocmds.o
  Compiling out/src/stepper.o
  Compiling out/src/endstop.o
  Compiling out/src/trsync.o
  Compiling out/src/adccmds.o
  Compiling out/src/spicmds.o
  Compiling out/src/thermocouple.o
  Compiling out/src/i2ccmds.o
src/i2ccmds.c:14:23: error: field ‘i2c_config’ has incomplete type
     struct i2c_config i2c_config;
                       ^
src/i2ccmds.c: In function ‘command_config_i2c’:
src/i2ccmds.c:23:23: warning: implicit declaration of function ‘i2c_setup’ [-Wimplicit-function-declaration]
     i2c->i2c_config = i2c_setup(args[1], args[2], addr);
                       ^
src/i2ccmds.c: In function ‘command_i2c_write’:
src/i2ccmds.c:35:5: warning: implicit declaration of function ‘i2c_write’ [-Wimplicit-function-declaration]
     i2c_write(i2c->i2c_config, data_len, data);
     ^
src/i2ccmds.c: In function ‘command_i2c_read’:
src/i2ccmds.c:48:5: warning: implicit declaration of function ‘i2c_read’ [-Wimplicit-function-declaration]
     i2c_read(i2c->i2c_config, reg_len, reg, data_len, data);
     ^
make: *** [Makefile:64: out/src/i2ccmds.o] Error 1
pi@octopi-klipper:~/klipper $

 This can be solved by running:

make clean && git pull && make menuconfig

again. Found here: https://github.com/Klipper3d/klipper/issues/4409 . It works. 

After this, I just hit

make

again and end up with a hex file.

If you're anything like me, you want to test the upload process on any other controller board that's remotely compatible, first. So I grabbed my trusty Arduino Mega 256 board, plugged it into the Raspberry Pi running the latest OctoPi and....nothing.

The board shows up in dmesg but it does not get a port assigned. This is due to

modprobe cdc-acm

failing as the cdc-acm driver either is not present at all or is broken. I'll be honest: WHAT THE ACTUAL F? This worked well on any other machine I use but this OctoPi installation. Probably Raspberry Pi in general. For some reason, this driver was removed and many prople on the web struggle with this specific issue. As long as your Arduino Mega uses a Mega8U2 for communication and not the cheaper aftermarket versions and serial converters, you're pretty much at the end of the line. Please let me know if you find a solution for this that can be documented here.

At this point, we can flash the machine - obviously I made sure that I have a backup of my original up and running code base and configuration - not like last time - so let's continue...

Let's look for the port with:

ls -la /dev/serial/by-id/

 Which results in

pi@octopi-klipper:~ $ ls -la /dev/serial/by-id/
total 0
drwxr-xr-x 2 root root 60 Dec 18 09:21 .
drwxr-xr-x 4 root root 80 Dec 18 09:21 ..
lrwxrwxrwx 1 root root 13 Dec 18 09:21 usb-1a86_USB2.0-Serial-if00-port0 -> ../../ttyUSB0

With the port in hand, we can flash - or so I thought.

sudo service klipper stop
make flash FLASH_DEVICE=/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
sudo service klipper start

Doesn't work. 

pi@octopi-klipper:~ $ avrdude -cwiring -patmega2560 -P/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 -b57600 -D                                                   -Uflash:w:out/klipper.elf.hex:i
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

The uploader assumes, I'm using an STK500 uploader which essentially no one uses with an Arduino. I'm sometimes really confused by these instructions. First, the menuconfig essentially only offers me MEGA2560 options to choose from and then it won't work with the standard settings despite the fact that it should be Arduino compatible. Anyways. 

Instead, for my Malyan M180 I need to use a standard Arduino uploading method.

EDIT 2023/07/30: To flash the Malyan M180, power on while pressing the menu button at the front of the printer and press return on the command below within 3-5 seconds or it won't accept the flash command.

avrdude -carduino -patmega2560 -P/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 -b57600 -D -Uflash:w:out/klipper.elf.hex:i

Please note, my M180 bootloader needs 57600 baud which is also non-standard.

pi@octopi-klipper:~/klipper $ avrdude -carduino -patmega2560 -P/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0 -b57600 -D -Uflash:w:out/klipper.elf.hex:          i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "out/klipper.elf.hex"
avrdude: writing flash (26468 bytes):

Writing | ################################################## | 100% 6.36s

avrdude: 26468 bytes of flash written
avrdude: verifying flash memory against out/klipper.elf.hex:
avrdude: load data flash data from input file out/klipper.elf.hex:
avrdude: input file out/klipper.elf.hex contains 26468 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 5.33s

avrdude: verifying ...
avrdude: 26468 bytes of flash verified

avrdude: safemode: Fuses OK (E:00, H:00, L:00)

avrdude done.  Thank you.

Awsome! Now, off to the Klipper configuration.

Discussions