Ubuntu 14.04 and USB to Serial ch341 (chinese device from Ebay)

You can find pretty cheap USB to Serial devices on Ebay. I bought one and received a device using a chip ch341.

Unfortunately, the drive is bugged in Ubuntu 12.04 and 14.04. Fortunately, there is patch to fix it.

Here is how to recompile the module to enjoy these devices.

$ sudo apt-get source linux-source-3.13.0 linux-headers-$(uname -r)
$ cd /tmp
$ tar -xjf /usr/src/linux-source-3.13.0.tar.bz2
$ cd linux-source-3.13.0/
$ make oldconfig
$ make prepare
$ make scripts
$ cp -v /usr/src/linux-headers-$(uname -r)/Module.symvers .
$ cp /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko.orig
$ cd drivers/usb/serial
$ cp ch341.c ch341.c.orig
$ wget https://github.com/karlp/ch341-linux/raw/master/0001-usb-serial-ch341-Add-parity-support.patch
$ cat 0001-usb-serial-ch341-Add-parity-support.patch | patch -p4
patching file ch341.c
Hunk #1 succeeded at 349 (offset 3 lines).
Hunk #2 succeeded at 370 (offset 3 lines).
$ make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
$ sudo cp ch341.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko
$ sudo rmmod ch341
$ sudo modprobe ch341

Source for instructions: askubuntu.com/questions/515407/how-recipe-to-build-only-one-kernel-module

This entry was posted in Computer, Linux. Bookmark the permalink.

6 Responses to Ubuntu 14.04 and USB to Serial ch341 (chinese device from Ebay)

  1. mrstanlez says:

    This row do not work:
    patch -p4 < 0001-usb-serial-ch341-Add-parity-support.patch

    Xubuntu 16.04 64-bit(2016), – fresh installation

  2. blogger says:

    Hello. I just tested on Ubuntu 16.04 with kernel 4.4 sources, the patch succeeds as long as you specify the filename to be patched (drivers/usb/serial/ch341.c).


    $ cd /tmp
    $ tar -xjf /usr/src/linux-source-4.4.0.tar.bz2
    $ cd linux-source-4.4.0/
    $ wget https://github.com/karlp/ch341-linux/raw/master/0001-usb-serial-ch341-Add-parity-support.patch
    $ cat 0001-usb-serial-ch341-Add-parity-support.patch | patch -p4
    (complains about mbox format)
    File to patch: drivers/usb/serial/ch341.c
    patching file drivers/usb/serial/ch341.c
    Hunk #1 succeeded at 342 (offset -4 lines).
    Hunk #2 succeeded at 363 (offset -4 lines).

    What is not working for you ?

  3. Nate says:

    I’m confused. On Ubuntu 16.04, do you follow the same instructions in the post while replacing the lines for 16.04 or do you just enter the lines for 16.04? This chip is causing a lot of effort to troubleshoot. Wouldn’t work at all on Windows.

  4. blogger says:

    I haven’t tried this chip on Ubuntu 16.04 yet, I only use it on Windows systems and when I have no other device available since it is so unreliable.

    I would get the correct source & headers [linux-sources and linux-headers-$(uname -r)], then follow my previous comment. I haven’t compiled it but it patched successfully as stated.

  5. cmel says:

    I’m using CH341 on Ubuntu 16.04. So simple!
    Just no driver to install. It works straightforward.

  6. Marco says:

    It’s works for me in :

    – Lubuntu 16.04 Kernel 4.4.
    – Lubuntu 16.10 Kernel 4.8.

    For me:

    – Enable download source code first

    #Required to compile
    apt-get install build-essential
    cd /tmp
    tar -vzxf Name_of_downloaded_file.tar.gz
    cd Folder_Create
    make oldconfig
    make prepare
    make scripts

    # If there is an error
    # Fatal error: openssl/opensslv.h: No such file or directory
    #Install this

    sudo apt-get install libssl-dev
    and run “make scripts”

    cp /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko.orig

    cd drivers/usb/serial
    cp ch341.c ch341.c.orig
    wget github.com/karlp/ch341-linux/raw/master/0001-usb-serial-ch341-Add-parity-support.patch
    cat 0001-usb-serial-ch341-Add-parity-support.patch | patch -p4
    make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
    sudo cp ch341.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko
    sudo rmmod ch341
    sudo modprobe ch341

Leave a Reply

Your email address will not be published. Required fields are marked *