Tested on Ubuntu 20, 21 earlier and they were not working. So upgraded Ubutbu to latest 22 version.
The issue is: The built in Kernals of Ubuntu and many Linux Kernals (between ) have the CH340 drivers broken / have bugs and not fixed (from kernal 5.4.0-87 and above)
Note: I didn't try on linux kernal 5.4.0-86 my self. I though I will see how is the situation in the latest linux kernal (as of 16/05/2022)
sudo apt-get update -y
sudo apt-get install neofetch -y
neofetch
I think it came with Kernel: 5.13.8-...
sudo add-apt-repository ppa:cappelikan/ppa
sudo apt-get update -y
sudo apt-get install mainline -y
sudo apt autoremove -y
Run mainline and select the latest kernel (I tried, as of 16/05/2022, kernel version: 5.17.8-051708-generic
)
After installation and reboot, run neofetch
again and check if the latest linux kernel is loaded.
sudo apt-get update -y
sudo apt-get install build-essential dwarves dkms make cmake -y
sudo apt autoremove -y
As per the guide here in sparkfun and https://github.com/juliagoda/CH341SER
git clone https://github.com/juliagoda/CH341SER
cd CH341SER
sudo make clean
# The Makefile looks for vmlinux in a certain location (check that cat Makefile)
# we need to move that
# https://forum.proxmox.com/threads/kernel-module-not-found-when-compile-skipping-btf-generation.100974/
cp /sys/kernel/btf/vmlinux /usr/lib/modules/`uname -r`/build/
sudo make
sudo make load
lsmod | grep ch34*
# NOTE: if other/prev ch34x drivers are loaded (and you know they were not working), then you can unload them by:
sudo rmmod ch34x
# Plug and unplug your CH340 device again on the USB port
sudo dmesg
# plug un-plug your device and then verify:
ls /dev/tty*
# make it accessible
sudo usermod -a -G dialout $(whoami)
sudo chmod a+rw /dev/ttyUSB0 # if /dev/ttyUSB0 was assigned
# To unload:
sudo rmmod ch34x
# or
sudo make unload
It came out during my test, at least on my machine, a service for some external brail hardware was conflicting with the drivers. I saw that in sudo dmesg
... ch340 1-10:1.0: ch341-uart converter detected
... usb 1-10: ch341-uart converter now attached to ttyUSB0
.
.
.
... usb 1-10: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1
... ch340-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
It was apearing and dis-appearing. so I tried to hunt the service as such:
sudo systemctl list-units | grep brltty
I then disabled it:
sudo systemctl stop <brl service name or other service that is interferring and not needed>
sudo systemctl disable <brl service name or other service that is interferring and not needed>
sudo systemctl mask <brl service name or other service that is interferring and not needed>
for f in /usr/lib/udev/rules.d/*brltty*.rules; do
sudo ln -s /dev/null "/etc/udev/rules.d/$(basename "$f")"
done
sudo udevadm control --reload-rules
Automate loading and unloading ...
HELP! :)
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
$ sudo make
make -C /lib/modules/6.11.0-21-generic/build M=/home/nyarfa/Downloads/CH341SER_LINUX
make[1]: Entering directory '/usr/src/linux-headers-6.11.0-21-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2
24.04) 13.3.024.04) 13.3.0You are using: gcc-13 (Ubuntu 13.3.0-6ubuntu2
CC [M] /home/nyarfa/Downloads/CH341SER_LINUX/ch34x.o
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c: In function ‘ch34x_close’:
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:591:9: error: unknown type name ‘wait_queue_t’; did you mean ‘wait_event’?
591 | wait_queue_t wait;
| ^~~~~~~~~~~~
| wait_event
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:591:22: warning: unused variable ‘wait’ [-Wunused-variable]
591 | wait_queue_t wait;
| ^~~~
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:590:14: warning: unused variable ‘timeout’ [-Wunused-variable]
590 | long timeout;
| ^~~~~~~
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:589:13: warning: unused variable ‘bps’ [-Wunused-variable]
589 | int bps;
| ^~~
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c: At top level:
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:1291:27: error: initialization of ‘void (*)(struct tty_struct *, struct usb_serial_port *, const struct ktermios )’ from incompatible pointer type ‘void ()(struct tty_struct *, struct usb_serial_port *, struct ktermios )’ [-Werror=incompatible-pointer-types]
1291 | .set_termios = ch34x_set_termios,
| ^~~~~~~~~~~~~~~~~
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:1291:27: note: (near initialization for ‘ch34x_device.set_termios’)
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:1297:27: error: initialization of ‘unsigned int ()(struct tty_struct )’ from incompatible pointer type ‘int ()(struct tty_struct )’ [-Werror=incompatible-pointer-types]
1297 | .write_room = ch34x_write_room,
| ^~~~~~~~~~~~~~~~
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:1297:27: note: (near initialization for ‘ch34x_device.write_room’)
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:1298:28: error: initialization of ‘unsigned int ()(struct tty_struct )’ from incompatible pointer type ‘int ()(struct tty_struct *)’ [-Werror=incompatible-pointer-types]
1298 | .chars_in_buffer = ch34x_chars_in_buffer,
| ^~~~~~~~~~~~~~~~~~~~~
/home/nyarfa/Downloads/CH341SER_LINUX/ch34x.c:1298:28: note: (near initialization for ‘ch34x_device.chars_in_buffer’)
cc1: some warnings being treated as errors
make[3]: *** [scripts/Makefile.build:244: /home/nyarfa/Downloads/CH341SER_LINUX/ch34x.o] Error 1
make[2]: *** [/usr/src/linux-headers-6.11.0-21-generic/Makefile:1932: /home/nyarfa/Downloads/CH341SER_LINUX] Error 2
make[1]: *** [Makefile:224: __sub-make] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.11.0-21-generic'
make: *** [Makefile:5: default] Error 2