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 ...
This thread looked like it was going to solve all my problems but I've hit a snag with the make file.
the cp function seemed to work, mine went to cp /sys/kernel/btf/vmlinux /usr/lib/modules/6.0.9-060009-generic/build/
but then sudo make results in errors
make -C /lib/modules/6.0.9-060009-generic/build M=/home/carterk/CH341SER
make[1]: Entering directory '/usr/src/linux-headers-6.0.9-060009-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.2.0-9ubuntu1) 12.2.0
You are using: gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
CC [M] /home/carterk/CH341SER/ch34x.o
gcc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’
make[2]: *** [scripts/Makefile.build:249: /home/carterk/CH341SER/ch34x.o] Error 1
make[1]: *** [Makefile:1858: /home/carterk/CH341SER] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-6.0.9-060009-generic'
make: *** [Makefile:7: default] Error 2
Which seems basically to be the exact same issue I've been battling with across two different machines and a couple of fresh installations. Suggestions?