Skip to content

Latest commit

 

History

History
270 lines (183 loc) · 6.42 KB

README.md

File metadata and controls

270 lines (183 loc) · 6.42 KB

CH341SER driver

  1. About driver
  2. Required dependencies
  3. Changes
  4. Tests
  5. Installation
  6. Official website
  7. Tutorial on Arch Linux
  8. Tutorial on Ubuntu
  9. Compatibility
  10. Fixing Problems


About driver

It's a manufacturer software of standard serial to usb chip marked CH340



Required dependencies

  • linux-headers

if you are using a different kernel, remember to install the headers for it, because the above package is for the standard linux kernel

When using SecureBoot, you need to sign module. You can follow this instruction
Otherwise make load can fail

Changes

Added line
#include <linux/sched/signal.h>

which helps to fix the problem below:
error: implicit declaration of function ‘signal_pending’; did you mean ‘timer_pending’? [-Werror=implicit-function-declaration]

and changed line:
wait_queue_t wait;
to
wait_queue_entry_t wait;
which helps to fix next problem below:
error: unknown type name ‘wait_queue_t’; did you mean ‘wait_event’?


merged pull request #17 (sirlucjan) and e-mail from zenon.ingielewicz@gmail.com fixed:

error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]

Thanks to hesaputra - #10


Added const to the line with ch34x_set_termios

Thanks to beautifulzzzz - #30



Additionally first pull request helped to merge changes for version 1.5 released in 2018-03-18: [https://github.com/juliagoda/CH341SER/pull/1](https://github.com/juliagoda/CH341SER/pull/1)

Tests

Tested on:

  • Arch Linux 4.11.3-1-hardened
  • Arch Linux 4.11.3-1-ARCH
  • Linux Mint 19.3 Cinnamon
  • Ubuntu 18.04.5 LTS
  • ubuntu 22.04
  • CentOS Linux release 8.3.2011


Installation

See original readme.txt



Official website

http://www.wch.cn/download/CH341SER_LINUX_ZIP.html



Tutorial on Arch Linux

Tested for Arduino UNO R3 Clone

install required packages:
sudo pacman -S arduino arduino-docs avr-binutils avr-gcc avr-libc avrdude


if your system detects the package below:
pacman -Qs arduino-avr-core


you should remove it:
sudo pacman -R arduino-avr-core


we add current user to uucp and lock groups:

gpasswd -a $USER uucp
gpasswd -a $USER lock

it's possible, that you have to load that module:
modprobe cdc_acm


clone fixed driver:
git clone https://github.com/juliagoda/CH341SER.git


according to the original readme.txt, we use the commands below:

make
sudo make load

to be sure, that module will be loaded after reboot, you can change file extension from ".ko" to ".ko.gz" and add it to drivers path:

find . -name *.ko | xargs gzip
sudo cp ch34x.ko.gz /usr/lib/modules/$(uname -r)/kernel/drivers/usb/serial

if the command:
lsmod | grep ch341


shows some result (but it doesn't have to), then:

sudo rmmod ch341
sudo mv /usr/lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko.gz /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko.gz~

sudo depmod -a


let's connect Arduino UNO R3 Clone to USB input and check our results:
dmesg | grep ch34x


that's example of my command's output:

[  492.836159] ch34x 3-1:1.0: ch34x converter detected
[  492.846265] usb 3-1: ch34x converter now attached to ttyUSB0

so our driver ch34x was successfully loaded and our port's name is ttyUSB0

Let's start our installed Arduino IDE.

First we should install package for Arduino AVR Boards from Boards Manager:


Choose of Boards Manager


Installation of packages for Arduino AVR Boards from Boards Manager


And now we must choose our port's name. My port's name is ttyUSB0.


Choose of port's name




Why we wanted arduino-avr-core package from official repo to be removed? Let's check it out.

sudo pacman -S arduino-avr-core


and let's reopen our Arduino IDE and check out boards list.


New label have been added to boards list


New label "Arch Linux Arduino AVR Boards" with boards has been added to boards list. It has the same options, so let's choose "Arduino/Genuino Uno" from a new part and upload our code to Arduino UNO R3 Clone.


The same option has been checked in new part


Upload with error


It didn't work. I think, that the package was created for original arduino boards, which are not compatible with their clones. If you want to have installed the package and work on clone of Arduino, better choose the same option from part labeled "Arduino AVR Boards".



Tutorial on Ubuntu

  1. First uninstall brltty (if you are blind DO NOT DO THIS) brltty helps peoples who can´t see to do things on system.
  2. Download the source code: git clone -b ubuntu https://github.com/juliagoda/CH341SER.git
  3. Goto the directory of the source code
  4. Compile: make
  5. Sign the module (needed in systems with secure boot enabled) : kmodsign sha512 /var/lib/shim-signed/mok/MOK.priv /var/lib/shim-signed/mok/MOK.der ./ch34x.ko
  6. Load module: make load

Compatibility

This driver is not compatible with the Olimex ESP32-POE rev C board

Fixing Problems

if the dmesg command does not indicate ttyUSB, only:

[ 457.050482] usbserial: USB Serial support registered for ch34x
1279.608531] ch34x 3-2:1.0: ch34x converter detected

then:

  1. some dependencies are missing (are not installed)
  2. at this stage the Arduino was connected not only to USB, but also to a prepared breadboard (you have to unplug cables connecting Arduino to breadboard)
  3. kernel hearders are missing (are not installed)
  4. It may happen, that kernel doesn't contain CONFIG_USB_SERIAL_CH341 flag, but you need it or it is disabled. You have to check configs of the kernel you are using