{"id":17532,"date":"2022-06-23T22:24:06","date_gmt":"2022-06-23T15:24:06","guid":{"rendered":"https:\/\/www.makeriot2020.com\/?p=17532"},"modified":"2022-06-23T22:24:12","modified_gmt":"2022-06-23T15:24:12","slug":"fix-driver-issues-with-ch340g-on-ubuntu-22-04-lts-and-possibly-other-linux-distros","status":"publish","type":"post","link":"https:\/\/www.makeriot2020.com\/index.php\/2022\/06\/23\/fix-driver-issues-with-ch340g-on-ubuntu-22-04-lts-and-possibly-other-linux-distros\/","title":{"rendered":"Fix Driver Issues with CH340G on Ubuntu 22.04 LTS ( and possibly other Linux Distro&#8217;s)"},"content":{"rendered":"\n<p>Having recently upgraded to Ubuntu 22.04 LTS ( After the local power-company managed to destroy my HP ML350-G6 server, with a UPS installed, with a power surge or something &#8211; still no answers &#8212; \ud83d\ude41 ) on a new more modern Desktop computer, I found some intermittent issues with my ESP32 \/ ESP8266 and Arduino boards&#8230; The Serial port would not work at all ( on devices with CH340G chips )&#8230; <br><br>A quick online search found the following, <a href=\"https:\/\/gist.github.com\/dattasaurabh82\/082d13fd61c0d06c7a358c5e605ce4fd\" target=\"_blank\" rel=\"noreferrer noopener\">link to the original article here<\/a>,<\/p>\n\n\n\n<p><a href=\"https:\/\/gist.github.com\/dattasaurabh82\/082d13fd61c0d06c7a358c5e605ce4fd#instructions-for-ubuntu-2204-lts-x86_64\"><\/a>Instructions for Ubuntu 22.04 LTS x86_64<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/gist.github.com\/dattasaurabh82\/082d13fd61c0d06c7a358c5e605ce4fd#get-the-kernel-verison-installed\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Get the currently  installed kernel version:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get update -y\nsudo apt-get install neofetch -y\nneofetch<\/pre>\n\n\n\n<p>I think it came with <code>Kernel: 5.13.8-...<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/gist.github.com\/dattasaurabh82\/082d13fd61c0d06c7a358c5e605ce4fd#instal-latest-kernel-gui-solution\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Install latest kernel (GUI solution):<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo add-apt-repository ppa:cappelikan\/ppa\nsudo apt-get update -y\nsudo apt-get install mainline -y\nsudo apt autoremove -y<\/pre>\n\n\n\n<p>Run <strong>mainline<\/strong> and select the latest kernel (I tried, as of 16\/05\/2022, kernel version: <code>5.17.8-051708-generic<\/code>)<\/p>\n\n\n\n<p>After installation and reboot, run <code>neofetch<\/code> again and check if the latest linux kernel is loaded.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/gist.github.com\/dattasaurabh82\/082d13fd61c0d06c7a358c5e605ce4fd#install-build-tools-if-not-installed-already\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Install build tools (if not installed already):<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo apt-get update -y\nsudo apt-get install build-essential dwarves dkms make cmake -y\nsudo apt autoremove -y<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/gist.github.com\/dattasaurabh82\/082d13fd61c0d06c7a358c5e605ce4fd#install-and-fix-ch34x-drivers\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Install and fix CH34x drivers:<\/h3>\n\n\n\n<p>As per the guide here in <a href=\"https:\/\/learn.sparkfun.com\/tutorials\/how-to-install-ch340-drivers\/linux\">sparkfun<\/a> and <a href=\"https:\/\/github.com\/juliagoda\/CH341SER\">https:\/\/github.com\/juliagoda\/CH341SER<\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">git clone https:\/\/github.com\/juliagoda\/CH341SER\ncd CH341SER\nsudo make clean \n\n# The Makefile looks for vmlinux in a certain location (check that cat Makefile)\n# we need to move that\n# https:\/\/forum.proxmox.com\/threads\/kernel-module-not-found-when-compile-skipping-btf-generation.100974\/\ncp \/sys\/kernel\/btf\/vmlinux \/usr\/lib\/modules\/`uname -r`\/build\/\n\nsudo make\nsudo make load\nlsmod | grep ch34*\n\n# NOTE: if other\/prev ch34x drivers are loaded (and you know they were not working), then you can unload them by:\nsudo rmmod ch34x\n\n# Plug and unplug your CH340 device again on the USB port\nsudo dmesg\n\n# plug un-plug your device and then verify:\nls \/dev\/tty*\n\n# make it accessible\nsudo usermod -a -G dialout $(whoami)\nsudo chmod a+rw \/dev\/ttyUSB0 # if \/dev\/ttyUSB0 was assigned\n\n# To unload:\nsudo rmmod ch34x\n# or \nsudo make unload<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/gist.github.com\/dattasaurabh82\/082d13fd61c0d06c7a358c5e605ce4fd#disable-some-conflicting-services\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Disable some conflicting services.<\/h3>\n\n\n\n<p>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 <code>sudo dmesg<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">... ch340 1-10:1.0: ch341-uart converter detected\n... usb 1-10: ch341-uart converter now attached to ttyUSB0\n.\n.\n.\n... usb 1-10: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1\n... ch340-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0<\/pre>\n\n\n\n<p>It was apearing and dis-appearing. so I tried to hunt the service as such:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl list-units | grep brltty<\/pre>\n\n\n\n<p>I then disabled it:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo systemctl stop &lt;brl service name or other service that is interfering and not needed>\nsudo systemctl disable &lt;brl service name or other service that is interfering and not needed>\nsudo systemctl mask &lt;brl service name or other service that is interfering and not needed>\n\nfor f in \/usr\/lib\/udev\/rules.d\/*brltty*.rules; do\n    sudo ln -s \/dev\/null \"\/etc\/udev\/rules.d\/$(basename \"$f\")\"\ndone\nsudo udevadm control --reload-rules\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Having recently upgraded to Ubuntu 22.04 LTS ( After the local power-company managed to destroy my HP ML350-G6 server, with a UPS installed, with a power surge or something &#8211; still no answers &#8212; \ud83d\ude41 ) on a new more modern Desktop computer, I found some intermittent issues with my ESP32 \/ ESP8266 and Arduino &hellip; <a href=\"https:\/\/www.makeriot2020.com\/index.php\/2022\/06\/23\/fix-driver-issues-with-ch340g-on-ubuntu-22-04-lts-and-possibly-other-linux-distros\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Fix Driver Issues with CH340G on Ubuntu 22.04 LTS ( and possibly other Linux Distro&#8217;s)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-17532","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/17532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/comments?post=17532"}],"version-history":[{"count":0,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/posts\/17532\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/media?parent=17532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/categories?post=17532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.makeriot2020.com\/index.php\/wp-json\/wp\/v2\/tags?post=17532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}