Can't start a Linux host mcu on Orangepi zero 3

I follow RPi microcontroller - Klipper documentation to create a host mcu on orangepi zero 3.
Already add the klipper-mcu.service to system,make and flash linux process.

In systemctl , seems it work correctly:

But did not see klipper-mcu appear in /tmp/

orangepi@orangepizero3:~/klipper$ ls /tmp
systemd-private-d70b38420c994537929b08508daf4232-bluetooth.service-xx3I8j
systemd-private-d70b38420c994537929b08508daf4232-chrony.service-yE0VHv
systemd-private-d70b38420c994537929b08508daf4232-haveged.service-C8WDsF
systemd-private-d70b38420c994537929b08508daf4232-systemd-logind.service-z7ttjn
systemd-private-d70b38420c994537929b08508daf4232-vnstat.service-590dgC
timelapse

klippy.log:

mcu 'mcu': Starting serial connect
webhooks client 281473441614096: New connection
webhooks client 281473441614096: Client info {'program': 'Moonraker', 'version': 'v0.8.0-138-gfe12095'}
Loaded MCU 'mcu' 107 commands (v0.11.0-240-g6d48adf9 / gcc: (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027] binutils: (2.35.2-2+14+b2) 2.35.2)
MCU 'mcu' config: ADC_MAX=4095 BUS_PINS_i2c1=PB6,PB7 BUS_PINS_i2c1a=PB8,PB9 BUS_PINS_i2c2=PB10,PB11 BUS_PINS_spi1=PA6,PA7,PA5 BUS_PINS_spi1a=PB4,PB5,PB3 BUS_PINS_spi2=PB14,PB15,PB13 BUS_PINS_spi3=PB4,PB5,PB3 CLOCK_FREQ=72000000 INITIAL_PINS=!PA14 MCU=stm32f103xe PWM_MAX=255 RESERVE_PINS_USB=PA11,PA12 STATS_SUMSQ_BASE=256 STEPPER_BOTH_EDGE=1
mcu 'opi': Starting connect
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
mcu 'opi': Unable to open port: [Errno 2] No such file or directory: '/tmp/klipper_host_mcu'
MCU error during connect
Traceback (most recent call last):
  File "/home/orangepi/klipper/klippy/mcu.py", line 800, in _mcu_identify
    self._serial.connect_pipe(self._serialport)
  File "/home/orangepi/klipper/klippy/serialhdl.py", line 165, in connect_pipe
    self._error("Unable to connect")
  File "/home/orangepi/klipper/klippy/serialhdl.py", line 61, in _error
    raise error(self.warn_prefix + (msg % params))
serialhdl.error: mcu 'opi': Unable to connect

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/orangepi/klipper/klippy/klippy.py", line 176, in _connect
    self.send_event("klippy:mcu_identify")
  File "/home/orangepi/klipper/klippy/klippy.py", line 263, in send_event
    return [cb(*params) for cb in self.event_handlers.get(event, [])]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/orangepi/klipper/klippy/klippy.py", line 263, in <listcomp>
    return [cb(*params) for cb in self.event_handlers.get(event, [])]
            ^^^^^^^^^^^
  File "/home/orangepi/klipper/klippy/mcu.py", line 803, in _mcu_identify
    raise error(str(e))
mcu.error: mcu 'opi': Unable to connect
Build file /home/orangepi/klipper/klippy/../.config(857): Mon Aug  7 03:30:44 2023

I used to run successfully by putting klipper-mcu-start.sh into /init.d, but now this .sh does not seem to exist in /klipper/scripts/

What should I do?

Hello @ixprism !

It would have been nice if you would have followed the template you deleted at the very beginning.

It asked for the klippy.log.

Also, what Linux distribution are you running?

If Debian Bulleseye, you may look here:

1 Like

Please provide the output of each of the following commands:

cat /etc/systemd/system/klipper-mcu.service

Perform a:

systemctl restart klipper-mcu.service
systemctl restart klipper.service

Then provide the output of

 systemctl status klipper-mcu.service

Followed by a FIRMWARE_RESTART in the printer’s console.
After this, check the klippy.log and /var/log/syslog. I doubt attach these files here.

It’s running debian12 bookworm Linux 6.1.31-sun50iw9

After using these commands , it shows:


orangepi@orangepizero3:~$ cat /etc/systemd/system/klipper-mcu.service
#Systemd klipper linux mcu Service

[Unit]
Description=Starts the MCU Linux firmware for klipper on startup
Documentation=https://www.klipper3d.org/RPi_microcontroller.html
Before=klipper.service
ConditionFileIsExecutable=/usr/local/bin/klipper_mcu

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
Environment=KLIPPER_HOST_MCU_SERIAL=/tmp/klipper_host_mcu
RemainAfterExit=yes
ExecStart=/usr/local/bin/klipper_mcu -r -I ${KLIPPER_HOST_MCU_SERIAL}
ExecStop=sh -c 'echo "FORCE_SHUTDOWN" > ${KLIPPER_HOST_MCU_SERIAL}'
ExecStop=sleep 1
TimeoutStopSec=2
Restart=always
RestartSec=5



orangepi@orangepizero3:~$ systemctl restart klipper-mcu.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to restart 'klipper-mcu.service'.
Authenticating as: orangepi,,, (orangepi)
Password:
==== AUTHENTICATION COMPLETE ====
orangepi@orangepizero3:~$ systemctl restart klipper.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to restart 'klipper.service'.
Authenticating as: orangepi,,, (orangepi)
Password:
==== AUTHENTICATION COMPLETE ====
orangepi@orangepizero3:~$  systemctl status klipper-mcu.servic
Unit klipper-mcu.servic.service could not be found.
orangepi@orangepizero3:~$ systemctl restart klipper.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to restart 'klipper.service'.
Authenticating as: orangepi,,, (orangepi)
Password:
==== AUTHENTICATION COMPLETE ====
orangepi@orangepizero3:~$ systemctl status klipper-mcu.service
● klipper-mcu.service - Starts the MCU Linux firmware for klipper on startup
     Loaded: loaded (/etc/systemd/system/klipper-mcu.service; enabled; preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Mon 2023-08-07 15:11:52 UTC; 2s ago
       Docs: https://www.klipper3d.org/RPi_microcontroller.html
    Process: 3345 ExecStart=/usr/local/bin/klipper_mcu -r -I ${KLIPPER_HOST_MCU_SERIAL} (code=exited, status=255/EXCEPTION)
   Main PID: 3345 (code=exited, status=255/EXCEPTION)
        CPU: 7ms
orangepi@orangepizero3:~$

This is the full log

klippy.log (1.5 MB)

syslog.txt (5.4 MB)

I will try it in debian11 with linux 5.4 to see if klipper-mcu work.

Apparently the start fails with:

2023-08-07T15:09:41.543871+00:00 orangepizero3 systemd[1]: Stopped klipper-mcu.service - Starts the MCU Linux firmware for klipper on startup.
2023-08-07T15:09:41.552596+00:00 orangepizero3 systemd[1]: Started klipper-mcu.service - Starts the MCU Linux firmware for klipper on startup.
2023-08-07T15:09:41.555356+00:00 orangepizero3 klipper_mcu[1226]: Got error -1 in sched_setscheduler: (1)Operation not permitted

Did you modify anything in the system with respect to CPU affinity, Cgroups etc?
Never seen this before

No settings changed, just enabled some gpio functions.

I downloaded Orangepizero3_1.0.0_debian_bookworm_server_linux6.1.31.img , installed klipper with kiauh, and then this problem occurred

Unfortunately, I cannot offer any more insight. This seems some incompatibility between switching real time parameters of the Kernel in the Armbian’s development branch and Klipper’s host process.

Although its not a Zero 3 as yours I ran my Orange Pi Zero with Armbian back in the days.
Everything worked fine and with some tricks even Numpy could be installed. But for the Zero 3 it looks like you can only choose from here:

Did you install a server or desktop version?

Unfortunately wifi doesn’t work on this Zero3 Armbian firmware, can’t see ssid anymore after two failed connections
I tested orangepi zero1 and 2, klipper host mcu working normally.

Maybe just wait for a better Zero3 armbian image.

ok, looks like I found a solution, at Armbian kernel & Klipper host mcu: "Got error -1 in sched_setschedule"

1 Like