Permission issue when connecting to printer - Unable to open serial port, operation not permitted

Basic Information:

Printer Model: Anycubic Mega SE
MCU / Printerboard: BTT skr mini e3 v3
klippy (3).log (194.4 KB)
→ OS: Debian 12 in LXC

Describe your issue:

Note that the top of klippy.log shows an old error. I didn’t know that klipper/moonrake uses ~/printer_data/config/printer.cfg instead of ~/printer.cfg.
My problem can be seen below, the serial connection is created but a permission problem cancels it.

The printer is connected and the container sees it:

$ ls /dev/serial/by-id/*
/dev/serial/by-id/usb-Klipper_stm32g0b1xx_100010001850425938323120-if00

The user I used to install Klipper (done with KIAUH) is also part of the necessary groups:

$ groups
user tty dialout sudo

and the container is privileged, if that matters at all.
What permissions do I need to change to make the connection work?

edit:
When I created the usb passthrough I only changed the permissions of /dev/ttyACM0 but I use /dev/serial/by-id/usb-Klipper.... in the printer.cfg.
I gave dialout group permission on /dev/serial but still get the same error.

Generally, virtualized setups are not recommended or supported and you might be experiencing strange errors later.

What you could try is to mount the /dev folder as volume into the Docker and I’d guess that privilege mode is indeed needed.

Just spitballing here, since I never tried such a setup.

I tried mounting the whole /dev folder but still get the same error:

mcu 'mcu': Unable to open serial port: [Errno 1] could not open port /mnt/dev/ttyACM0: [Errno 1] Operation not permitted: '/mnt/dev/ttyACM0'

or

mcu 'mcu': Unable to open serial port: [Errno 1] could not open port /dev/serial/by-id/usb-Klipper_stm32g0b1xx_100010001850425938323120-if00: [Errno 1] Operation not permitted: '/dev/serial/by-id/usb-Klipper_stm32g0b1xx_100010001850425938323120-if00'

depending on what is used in the printer.cfg.
I also added the whole /dev folder to the dialup group but it didn’t help so I reverted the changes.

I have seen one post on reddit from a guy who also uses LXC and also got permission problems. It is marked as solved but I can’t ask how because it is archived. But it shows that somehow it is possible.

I was thinking about something like:

volumes:
    - /dev:/dev
    - ...

It’s diffrent in Proxmox containers but I mounted the whole /dev folder.

mp0: /dev,mp=/mnt/dev

followed by changing the path in in printer.cfg to include the /mnt.

I do not think this will work as /dev is a system folder and expected to be a root folder. Mounting it under mnt/dev will likely kill its special meaning.

But as indicated, I have never tried it and would not recommend it as issues with virtualization are well known.

I tried to mount it as /dev, but it doesn’t work. It just does nothing. However, accessing the board is not the problem, the usb passthrough works fine. It must be a permission issue, but I don’t know what to change…

I’ve just set up a VM and it works without problems. Still bothers me that I wasn’t able to find out what went wrong when using an LXC…

See Running Klipper in a Virtual Machine (VM). So should you get a “Time too close error” mid-print you know that it did not work without problems :wink:

Thanks for pointing that out, I’ll keep it in mind if something strange happens.

Pretty sure that octoprint + marlin works different than Klipper but at least that worked fine. Octoprint wasn’t even a VM but a docker container inside a VM.

Running Klipper in a Virtual Machine

  • Abstracted access to USB or other hardware

This was the reason why I started out with an LXC. It got a “deeper” connection to the host system making things like this normally work better.

You cannot compare the two. In Klipper, the host process running on the SBC (or in your case in Docker) is the central “brain” of this solution and is responsible for maintaining the necessary timings and it requires constant, precisely timed and permanent access to the MCU. Any delay or interference will result in Klipper errors.

For a better understanding of the Klipper architecture refer to Klipper Architecture / Ecosystem

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.