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