Armbian kernel & Klipper host mcu: "Got error -1 in sched_setschedule"

When using a Linux kernel built by the Armbian team, the Klipper host mcu will refuse to start in realtime mode (-r flag) with the error:
Got error -1 in sched_setscheduler: (1)Operation not permitted

This is because the kernel is compiled with CONFIG_RT_GROUP_SCHED=y. Systemd’s devs flat out refused to implement the cgroup management for this, so it’s not possible to allocate the rt_runtime_us from the unit file.

The solution is to disable the limit with sudo sysctl -w kernel.sched_rt_runtime_us=-1
echo "kernel.sched_rt_runtime_us = -1" | sudo tee /etc/sysctl.d/10-disable-rt-group-limit.conf to make it permanent.

Most kernels out there have it disabled (CONFIG_RT_GROUP_SCHED=n). Notably, Raspberry Pi OS and Ubuntu don’t need this fix.

It bothered me for quite some time until an Armbian forum user gave me the solution. I put this here to help future users who know how to use the search function.

7 Likes

Good to know, I’m always using no stock hardware, armbian has these little quirks.

What build of Armbian are you using?

Bullseye, Buster, Focal, etc?

I’m curious if it makes a difference if you use the Debian or Ubuntu release or if this is across the board for Armbian?

Currently on buster, but have used focal & bullseye all seem to have quirks, buster has been stable for 3-4months even with on going updates in klipper / kiauh.

I just fixed my pi with the command. I have spent a lot of time searching the whole internet to figure out what happened and what to do. And it turned out the solution had been posted in the klipper forum…
Anyways, thanks a lot!!

(BTW, I am using the orange pi zero3 with the stock image bullseye debian)

2 Likes

My device is also orangepi zero3. I also tried these two lines of command, but there was no response after the second command was entered. I also tried using the root and klipper user commands, again.
Can you tell me how you succeeded?

The second command should only respond with kernel.sched_rt_runtime_us = -1. It uses the root account to write this line in the file /etc/sysctl.d/10-disable-rt-group-limit.conf. It will be read during the following boots, having the same effect as the first command. It’s run early at boot, before the klipper-mcu starts.

If the host mcu still fails, please check if you have a different error with systemctl status klipper-mcu (compare the outputs with the ones in Sineos guide). There are other potential issues, especially if the config of the host mcu involves GPIOs.

1 Like

@Piezo I thank you for the solution, you saved my life here in y2024.
I register an account for this post in order to express my appreciation.