Free shipping on order over $99.99;Buy X40 get 10% off ( CODE:EN10 )

Update CH340 driver on Raspberry Pi

Update CH340 driver on Raspberry Pi

Introduction

The CH340 driver in the Linux kernel-based system such as Raspberry Pi is too old. It has compatibility issues with the new CH340G chip. You need to install the new driver manually.

The Linux driver source code download url is here:
download

Hardware and operating system

Raspberry Pi 4B, Broadcom BCM711, 4GB Ram, install the official Raspberry Pi system released on May 7th 2021. The kernel version is 5.10.




1. Delete the original driver

Input the command to find the serial device driver installed in the system.

ls /lib/modules/(version)/kernel/drivers/usb/serial/



Find ch341.ko and delete.

sudo rm /lib/modules/(version)/kernel/drivers/usb/serial/ch341.ko



2. Compile and install the new driver

Download the CH340 driver source code and unzip it.

unzip CH341SER_LINUX.ZIP



Enter the source directory and compile.

cd CH341SER_LINUX &&  make



If the kernel header file is not installed in the system, the compiler will prompt an error, /lib/modules/(version)/build not found.
Install Raspberry Pi kernel header files.

sudo apt install raspberrypi-kernel-headers



Recompile after installing the kernel header files. If the compiler prompts an unknown error of type'wait-queue+t', please use vi to open the ch34x.c file, find and comment out line 591.


After successful compilation, the ch34x.ko file will be generated.


Copy the ch34x.ko file to the kernel driver directory, and install the driver.

sudo cp ch34x.ko /lib/modules/(version)/kernel/drivers/usb/serial/
sudo depmod



3. Test the serial connection

Connect the 3D printer with a USB cable and turn on the power. If the driver is successfully installed, the ttyUSB0 device will appear in the /dev/ directory.


Find the ttyUSB0 device in OctoPrint and set the baud rate to 115200.
Open the port and switch to the Terminal panel. The firmware version information of the 3D printer is displayed in the console, and the connection is successful.



OctoPi

If you are using OctoPi V0.18.0 or earlier system, you need to update the kernel first.

sudo apt-get update
sudo apt-get install raspberrypi-bootloader raspberrypi-kernel
sudo reboot



Reboot the system, check the kernel version, then install the Raspberry Pi kernel header files.