如何为 PRUSA 打印机的 Ubuntu Pi 映像编译 cdc-acm.ko 内核模块

发布于 2025-01-20 15:27:39 字数 277 浏览 0 评论 0原文

我有一台Prusa打印机,它不允许在Raspberry Pi CM4上与Ubuntu 21.10服务器进行USB /串行通信。

我正在尝试将串行端口传递给Docker图像。

我尝试通过 /dev /ttyAcm0和 /dev /ttyacm1,但它不起作用,因为它们不是正确的设备。

经过一些研究,事实证明,Prusa需要cdc-acm.ko内核模块进行通信。默认情况下,Ubuntu Server Raspberry Pi不包含该模块,现有的串行端口不是正确的端口。

I have a PRUSA printer that would not allow USB / serial communication with Ubuntu 21.10 Server on a raspberry pi CM4.

I am trying to pass the serial port to a Docker image.

I have tried passing /dev/ttyACM0 and /dev/ttyACM1, but it isn't working, because they are not the correct devices.

After some research, it turns out that the PRUSA requires the cdc-acm.ko kernel module for communication. This module is not included with Ubuntu Server Raspberry Pi by default and the existing serial ports were not the correct ports.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠北森屋 2025-01-27 15:27:39

每次有较小的内核更新时,您都必须重复此过程。由于源基于父树,因此如果需要,您可以使用 git pull 从源进行更新。然而,就我的目的而言,这个模块实际上不会更新太多,所以当 apt 安装新内核时,我可以重新运行 make 和 make install 组件。

在您的主文件夹中安装内核源代码

cd ~

apt-get source linux-image-$(uname -r)
sudo apt-get install linux-headers-$(uname -r)

cd $(uname -r)

make oldconfig
make prepare

准备构建/安装

这可以防止在使用 insmod 或 modprobe 加载模块时出现“no symbol version for module_layout”消息。

$ cd ~/linux-3.13.0
$ sudo cp -v /usr/src/linux-headers-$(uname -r)/Module.symvers .

备份现有文件(如果存在)(如果您已经构建了另一个版本)

sudo mv -v /lib/modules/$(uname -r)/kernel/drivers/usb/class/cdc-acm.ko /lib/modules/$(uname -r)/kernel/drivers/usb/class/cdc-acm.ko.backup

更改到包含 cdc-acm 模块源文件的目录。

cd drivers/usb/class

的目录中构建模块

make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

在安装模块

sudo make -C /lib/modules/$(uname -r)/build M=$(pwd) modules_install

。确保模块加载

insmod cdc-acm.ko

检查 dmesg 以查看串行端口是否已添加为设备。

[342064.530529] usb 1-1.3: USB disconnect, device number 3
[342068.876355] usb 1-1.3: new full-speed USB device number 4 using xhci_hcd
[342068.992089] usb 1-1.3: New USB device found, idVendor=2c99, idProduct=0002, bcdDevice= 1.30
[342068.992120] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[342068.992135] usb 1-1.3: Product: Original Prusa i3 MK3
[342068.992147] usb 1-1.3: Manufacturer: Prusa Research (prusa3d.com)
[342068.992159] usb 1-1.3: SerialNumber: CZPX4121X00XXXXXXXXX
[344887.408684] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device
[344887.408815] usbcore: registered new interface driver cdc_acm
[344887.408824] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

通过 ID 验证串行设备,以便您可以传递到 Docker 容器等。

ls -al /dev/serial/by-id/*

lrwxrwxrwx 1 root root 13 Apr 11 13:31 /dev/serial/by-id/usb-Prusa_Research__prusa3d.com__Original_Prusa_i3_MK3_CZPX4121X00XXXXXXXXX-if00 -> ../../ttyACM0

额外说明一下,以下是如何将此串行端口传递到 Docker 进行 OctoPrint。

devices:
  - /dev/serial/by-id/usb-Prusa_Research__prusa3d.com__Original_Prusa_i3_MK3_CZPX4121X00XXXXXXXXX-if00:/dev/ttyACM0

You will have to repeat this procedure every time there is a minor kernel update. Because the source is based on the parent tree, you can update with a git pull from the source if you want to. For my purposes, however, this module really won't be updated much, so I can just re-run the make and make install components when a new kernel is installed by apt.

Install Kernel Source in your home folder

cd ~

apt-get source linux-image-$(uname -r)
sudo apt-get install linux-headers-$(uname -r)

cd $(uname -r)

make oldconfig
make prepare

Prepare for build / install

This to prevent the message "no symbol version for module_layout" when loading the module with insmod or modprobe.

$ cd ~/linux-3.13.0
$ sudo cp -v /usr/src/linux-headers-$(uname -r)/Module.symvers .

backup existing file if it exists (if you already built another version)

sudo mv -v /lib/modules/$(uname -r)/kernel/drivers/usb/class/cdc-acm.ko /lib/modules/$(uname -r)/kernel/drivers/usb/class/cdc-acm.ko.backup

change to the directory with the cdc-acm module source files.

cd drivers/usb/class

build the modules in the directory

make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

install the modules.

sudo make -C /lib/modules/$(uname -r)/build M=$(pwd) modules_install

make sure the module loads

insmod cdc-acm.ko

check dmesg to see if the serial port is added as a device.

[342064.530529] usb 1-1.3: USB disconnect, device number 3
[342068.876355] usb 1-1.3: new full-speed USB device number 4 using xhci_hcd
[342068.992089] usb 1-1.3: New USB device found, idVendor=2c99, idProduct=0002, bcdDevice= 1.30
[342068.992120] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[342068.992135] usb 1-1.3: Product: Original Prusa i3 MK3
[342068.992147] usb 1-1.3: Manufacturer: Prusa Research (prusa3d.com)
[342068.992159] usb 1-1.3: SerialNumber: CZPX4121X00XXXXXXXXX
[344887.408684] cdc_acm 1-1.3:1.0: ttyACM0: USB ACM device
[344887.408815] usbcore: registered new interface driver cdc_acm
[344887.408824] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Verify Serial Device by ID, so you can pass to Docker container etc.

ls -al /dev/serial/by-id/*

lrwxrwxrwx 1 root root 13 Apr 11 13:31 /dev/serial/by-id/usb-Prusa_Research__prusa3d.com__Original_Prusa_i3_MK3_CZPX4121X00XXXXXXXXX-if00 -> ../../ttyACM0

For extra credit, here is how you pass this serial port to Docker for OctoPrint.

devices:
  - /dev/serial/by-id/usb-Prusa_Research__prusa3d.com__Original_Prusa_i3_MK3_CZPX4121X00XXXXXXXXX-if00:/dev/ttyACM0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文