QinHeng Electronics HL-340 USB-Serial adapter

Bug #1527491 reported by Pieter
56
This bug affects 11 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Medium
Unassigned

Bug Description

USB serial adapter detected but not working.

$ lsusb
Bus 001 Device 125: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

$ ls /dev/ttyU*
/dev/ttyUSB0

From syslog
Dec 18 09:35:23 pieter-ThinkPad kernel: [487228.018937] usb 1-1: new full-speed USB device number 126 using xhci_hcd
Dec 18 09:35:23 pieter-ThinkPad kernel: [487228.183954] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523
Dec 18 09:35:23 pieter-ThinkPad kernel: [487228.183959] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
Dec 18 09:35:23 pieter-ThinkPad kernel: [487228.183962] usb 1-1: Product: USB2.0-Ser!
Dec 18 09:35:23 pieter-ThinkPad kernel: [487228.184731] ch341 1-1:1.0: ch341-uart converter detected
Dec 18 09:35:23 pieter-ThinkPad kernel: [487228.185569] usb 1-1: ch341-uart converter now attached to ttyUSB0
Dec 18 09:35:23 pieter-ThinkPad mtp-probe: checking bus 1, device 126: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-1"
Dec 18 09:35:23 pieter-ThinkPad mtp-probe: bus: 1, device: 126 was not an MTP device

$ uname -a
Linux pieter-ThinkPad 4.3.0-040300-lowlatency #201511020949 SMP PREEMPT Mon Nov 2 14:55:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Google search
http://comments.gmane.org/gmane.linux.usb.general/121851
https://bugzilla.redhat.com/show_bug.cgi?id=1235715
http://unix.stackexchange.com/questions/189896/testing-if-hl-340-works
---
ApportVersion: 2.19.1-0ubuntu5
Architecture: amd64
CurrentDesktop: Unity
DistroRelease: Ubuntu 15.10
InstallationDate: Installed on 2015-01-23 (331 days ago)
InstallationMedia: Ubuntu 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.2)
Package: linux (not installed)
Tags: wily
Uname: Linux 4.3.0-040300-lowlatency x86_64
UnreportableReason: The running kernel is not an Ubuntu kernel
UpgradeStatus: Upgraded to wily on 2015-11-11 (39 days ago)
UserGroups: adm btsync cdrom dialout dip kismet kvm libvirtd lpadmin plugdev sambashare sudo wireshark
_MarkForUpload: True

Pieter (diepes)
affects: btrfs (Ubuntu) → linux-meta (Ubuntu)
Brad Figg (brad-figg)
affects: linux-meta (Ubuntu) → linux (Ubuntu)
Revision history for this message
Brad Figg (brad-figg) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. From a terminal window please run:

apport-collect 1527491

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
Pieter (diepes) wrote :

2012 ubuntuforum, same device, worked and then stopped after a upgrade.
http://ubuntuforums.org/archive/index.php/t-1923883.html

Revision history for this message
Pieter (diepes) wrote :

CentOS reference to serial problems with same device.
https://www.centos.org/forums/viewtopic.php?t=7369

Revision history for this message
Pieter (diepes) wrote : JournalErrors.txt

apport information

tags: added: apport-collected wily
description: updated
Revision history for this message
Pieter (diepes) wrote : ProcEnviron.txt

apport information

Revision history for this message
Jon "The Nice Guy" Spriggs (jontheniceguy) wrote :

Also affects 14.04 LTS with 3.19 kernel

dino99 (9d9)
Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Changed in linux (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Stanislav Petrek (stanislav-petrek) wrote :

OS: Linux 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
fresh install.

modinfo i2c-ch341
filename: /lib/modules/4.4.0-31-generic/kernel/drivers/i2c/i2c-ch341.ko
license: GPL
description: i2c-ch341-u2c driver
author: Marco Gittler <email address hidden>
srcversion: 793AECF7CF0745E30FD20F9
alias: usb:v1A86p5512d*dc*dsc*dp*ic*isc*ip*in*
depends:
vermagic: 4.4.0-31-generic SMP mod_unload modversions
parm: frequency:I2C clock frequency in hertz (uint)

I try to run Arduino Nano with ch341, but nothing work. Something between USB2.0 or USB3.0 ? or kernel compilation anyways ?
And if so, why on old kernel 3.18 work it snoothly ?

Also dont work a guide:
http://blog.xentoo.info/2015/12/31/ubuntu-14-04-and-usb-to-serial-ch341-chinese-device-from-ebay/

Revision history for this message
Stanislav Petrek (stanislav-petrek) wrote :

dmesg
[ 1431.007315] usbcore: registered new interface driver usbserial
[ 1431.007323] usbcore: registered new interface driver usbserial_generic
[ 1431.007330] usbserial: USB Serial support registered for generic
[ 1431.008619] usbcore: registered new interface driver ch341
[ 1431.008629] usbserial: USB Serial support registered for ch341-uart

- its very nice that Serial support is registered, but not attached for example: to the BUS 003 Device 001: ID 1A86:.... (and this is important)

ls /dev/tty*
/dev/tty /dev/ttyS22 /dev/tty0 /dev/tty24 /dev/tty4 /dev/tty55
/dev/ttyprintk /dev/ttyS23 /dev/tty1 /dev/tty25 /dev/tty40 /dev/tty56
/dev/ttyS0 /dev/ttyS24 /dev/tty10 /dev/tty26 /dev/tty41 /dev/tty57
/dev/ttyS1 /dev/ttyS25 /dev/tty11 /dev/tty27 /dev/tty42 /dev/tty58
.....and so on. but nothing with ttyUSB0, ttyUSB1, or ttyACM0, ttyACM1.

Please Is here some competent person to FIX this ISUE ?

Thank you

Revision history for this message
wlarsong (wlarsong) wrote :

I have these adapters

 /* expect two bytes 0x56 0x00 */
 r = ch341_control_in(dev, 0x95, 0x2518, 0, buffer, size);
 if (r < 0)
  goto out;
/*Comment this line out and recompile*/ //r = ch341_control_out(dev, 0x9a, 0x2518, 0x0050);
 if (r < 0)
  goto out;

Everything works now

Revision history for this message
TJani (tjani) wrote :

Thank you wlarsong! Work nice!

Revision history for this message
kliurka (baruse) wrote :

Hello, same problem to me. Wlarsong, how to fix step by step?

Revision history for this message
Thomas (moosethemucha) wrote :

You can rebuild the kernel by following these steps

https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

the file you will need to edit is here

drivers/usb/serial/ch341.c

&&

http://lxr.free-electrons.com/source/drivers/usb/serial/ch341.c

I'm sure you can recompile things by module but from memory the process is lengthy and difficult. This is the easiest option -- although re-compiling the kernel will take a while. Hopefully a patch will come soon.

Revision history for this message
bill danford (w-danford) wrote :

26 Jan 2017; same problem

from syslog

Jan 26 08:36:17 USSMLTRDLinux02 kernel: [259338.868105] usb 2-1.1: new full-speed USB device number 38 using ehci-pci
Jan 26 08:36:17 USSMLTRDLinux02 kernel: [259338.961091] usb 2-1.1: New USB device found, idVendor=1a86, idProduct=7523
Jan 26 08:36:17 USSMLTRDLinux02 kernel: [259338.961097] usb 2-1.1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
Jan 26 08:36:17 USSMLTRDLinux02 kernel: [259338.961099] usb 2-1.1: Product: USB2.0-Ser!
Jan 26 08:36:17 USSMLTRDLinux02 kernel: [259338.961389] ch341 2-1.1:1.0: ch341-uart converter detected
Jan 26 08:36:17 USSMLTRDLinux02 kernel: [259338.963275] usb 2-1.1: ch341-uart converter now attached to ttyUSB1
Jan 26 08:36:17 USSMLTRDLinux02 mtp-probe: checking bus 2, device 38: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.1"
Jan 26 08:36:17 USSMLTRDLinux02 mtp-probe: bus: 2, device: 38 was not an MTP device

$ uname -a
Linux USSMLTRDLinux02 3.13.0-107-generic #154~precise1-Ubuntu SMP Tue Dec 20 10:37:27 UTC 2016 i686 i686 i386 GNU/Linux

I do observe the associated access is ehci-pci, whereas the original post access was xhci_hcd

Also I have some CH341 bases RS485 interfaces, they work just fine, same VID:PID. The device having problems is RS232. These have a driver CD for Windows, works fine there.

sys;log for the RS485 device

Jan 26 08:48:04 USSMLTRDLinux02 kernel: [260046.435291] usb 2-1.4: USB disconnect, device number 37
Jan 26 08:48:07 USSMLTRDLinux02 kernel: [260049.195120] usb 2-1.4: new full-speed USB device number 39 using ehci-pci
Jan 26 08:48:07 USSMLTRDLinux02 kernel: [260049.288782] usb 2-1.4: New USB device found, idVendor=1a86, idProduct=7523
Jan 26 08:48:07 USSMLTRDLinux02 kernel: [260049.288788] usb 2-1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=0
Jan 26 08:48:07 USSMLTRDLinux02 kernel: [260049.288791] usb 2-1.4: Product: USB2.0-Serial
Jan 26 08:48:07 USSMLTRDLinux02 kernel: [260049.289149] ch341 2-1.4:1.0: ch341-uart converter detected
Jan 26 08:48:07 USSMLTRDLinux02 kernel: [260049.291092] usb 2-1.4: ch341-uart converter now attached to ttyUSB2
Jan 26 08:48:07 USSMLTRDLinux02 mtp-probe: checking bus 2, device 39: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4"
Jan 26 08:48:07 USSMLTRDLinux02 mtp-probe: bus: 2, device: 39 was not an MTP device

I note in RS232 description:
Jan 26 08:36:17 USSMLTRDLinux02 kernel: [259338.961099] usb 2-1.1: Product: USB2.0-Ser!

and in RS485 description:
Jan 26 08:48:07 USSMLTRDLinux02 kernel: [260049.288791] usb 2-1.4: Product: USB2.0-Serial

interesting how the description in syslog also corrupts

Revision history for this message
Daniel Liabeuf (daniel-liabeuf) wrote :

Module ch341 still defect on kernel 4.9 .
In my case, the correction proposed in #9 works (thanks to the author).

Tips: How to build module without the entire kernel
# cd drivers/usb/serial
# make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

Revision history for this message
Kai-Heng Feng (kaihengfeng) wrote :
Revision history for this message
Seiichi Nakashima (ubuntu-linuxer) wrote :

I found a new ch341.c source code.

<https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c>

and I wanted to build a module ch341.ko on ubuntu16.04(Japanese) that
kenerl-4.4.0-81-generic, but could not build. I think that ch341.c
was changed interface to upper module. ch341.c in github is about 640 lines.
so I search kernel in The Linux Kernel Archives that ch341.c has same size.
then I found kernel-4.11.6(but now 4.11.7).

I build kernel-4.11.6 on ubuntu16.04, I build kernel-image, but could not
build kernel-headers. I install kernel-image to use dpkg command. and I
use minicom to communicate HL-340, and work fine.

also I build kernel-4.11.6 on slackware64-14.2, HL-340 also work fine.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.