2015-08-26 16:09:38

by Ajay Garg

[permalink] [raw]
Subject: Likely issue with ch341 kernel-module/driver

Hi all.

I am attaching the RS232-TTL via a serial-USB converter on my machine.

However, when I connect a putty-session with my embedded-device, I see
strange issues (garbage characters transmitted from embedded-device to
putty; nothing can be read from putty into embedded-device).

It seems that there is some issue with the driver.
Lots of these lines are seen in dmesg ::


########################################################################################
[ 8657.022997] ch341-uart ttyUSB0:
usb_serial_generic_read_bulk_callback - nonzero urb status: -71
########################################################################################



Other informations ::

########################################################################################
ajay@ajay-HP-15-Notebook-PC:~$ lsusb
Bus 001 Device 002: ID 8087:8001 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 003: ID 05c8:036e Cheng Uei Precision Industry Co., Ltd (Foxlink)
Bus 002 Device 002: ID 0bda:b001 Realtek Semiconductor Corp.
Bus 002 Device 011: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
########################################################################################


########################################################################################
ajay@ajay-HP-15-Notebook-PC:~$ lsmod | grep ch341
ch341 13761 1
usbserial 38972 3 ch341
########################################################################################


########################################################################################
ajay@ajay-HP-15-Notebook-PC:~$ uname -a
Linux ajay-HP-15-Notebook-PC 3.16.0-30-generic #40~14.04.1-Ubuntu SMP
Thu Jan 15 17:45:15 UTC 2015 i686 i686 i686 GNU/Linux
########################################################################################



Any chance this can be made to work? Any upgrade that might solve the issue?
We will be grateful for ideas.


Thanks and Regards,
Ajay


2015-08-26 17:04:43

by Johan Hovold

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

[ +CC: linux-usb ]

On Wed, Aug 26, 2015 at 09:39:36PM +0530, Ajay Garg wrote:
> Hi all.
>
> I am attaching the RS232-TTL via a serial-USB converter on my machine.
>
> However, when I connect a putty-session with my embedded-device, I see
> strange issues (garbage characters transmitted from embedded-device to
> putty; nothing can be read from putty into embedded-device).
>
> It seems that there is some issue with the driver.

Why do think it's a driver issue?

> Lots of these lines are seen in dmesg ::
>
>
> ########################################################################################
> [ 8657.022997] ch341-uart ttyUSB0:
> usb_serial_generic_read_bulk_callback - nonzero urb status: -71
> ########################################################################################
>
>
>
> Other informations ::
>
> ########################################################################################
> ajay@ajay-HP-15-Notebook-PC:~$ lsusb
> Bus 001 Device 002: ID 8087:8001 Intel Corp.
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
> Bus 002 Device 003: ID 05c8:036e Cheng Uei Precision Industry Co., Ltd (Foxlink)
> Bus 002 Device 002: ID 0bda:b001 Realtek Semiconductor Corp.
> Bus 002 Device 011: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
> Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> ########################################################################################
>
>
> ########################################################################################
> ajay@ajay-HP-15-Notebook-PC:~$ lsmod | grep ch341
> ch341 13761 1
> usbserial 38972 3 ch341
> ########################################################################################
>
>
> ########################################################################################
> ajay@ajay-HP-15-Notebook-PC:~$ uname -a
> Linux ajay-HP-15-Notebook-PC 3.16.0-30-generic #40~14.04.1-Ubuntu SMP
> Thu Jan 15 17:45:15 UTC 2015 i686 i686 i686 GNU/Linux
> ########################################################################################
>
>
>
> Any chance this can be made to work? Any upgrade that might solve the issue?
> We will be grateful for ideas.

This is a known issue with your device that has been reported in this
thread:

https://lkml.kernel.org/r/CAF3ayyDe44POd1NoSBqn_gjA8XLoK3r_getDYnWx+a_1rL0r5g@mail.gmail.com

Looks like a hardware issue, I'm afraid.

Johan

2015-08-26 18:09:34

by Peter Stuge

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

Johan Hovold wrote:
> On Wed, Aug 26, 2015 at 09:39:36PM +0530, Ajay Garg wrote:
..
> > garbage characters transmitted from embedded-device
..
> > It seems that there is some issue with the driver.
>
> Why do think it's a driver issue?

I can confirm similar issues with the in-tree driver and my hardware.


> > Any chance this can be made to work?

Ajay, please try building the vendor driver. That works well for me.


> > Any upgrade that might solve the issue?

There is no upgrade. Someone needs to spend a day or so on adding
functionality from the vendor driver to the in-tree driver, in a
backwards-compatible way.


> Looks like a hardware issue, I'm afraid.

When I got garbage from the in-tree driver it was indeed a driver issue.


//Peter

2015-08-26 18:15:09

by Johan Hovold

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

On Wed, Aug 26, 2015 at 08:09:30PM +0200, Peter Stuge wrote:
> Johan Hovold wrote:
> > On Wed, Aug 26, 2015 at 09:39:36PM +0530, Ajay Garg wrote:
> ..
> > > garbage characters transmitted from embedded-device
> ..
> > > It seems that there is some issue with the driver.
> >
> > Why do think it's a driver issue?
>
> I can confirm similar issues with the in-tree driver and my hardware.

What hardware is that?

> > > Any chance this can be made to work?
>
> Ajay, please try building the vendor driver. That works well for me.

Yes, please do.

> > > Any upgrade that might solve the issue?
>
> There is no upgrade. Someone needs to spend a day or so on adding
> functionality from the vendor driver to the in-tree driver, in a
> backwards-compatible way.
>
> > Looks like a hardware issue, I'm afraid.
>
> When I got garbage from the in-tree driver it was indeed a driver issue.

That's good to hear. Care to write up a patch? :)

Thanks,
Johan

2015-08-27 06:43:34

by Ajay Garg

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

I started in the morning to build the driver from the source provided
by the vendor, but it was written in the times of kernel-version 2.4,
and I got hopelessly stuck.

Wanting to take a break, I reset my setup, and VERY strangely, what I
now observe is ::

a)
I am NOT able to send anything from the embedded-system to
putty-session (nothing appears at all on the putty session).

b)
Receive is working perfectly (anything I type in the putty-session is
received fine in the embedded-application).


Not sure what the hell is going on :(

Also, as per http://lxr.free-electrons.com/source/drivers/usb/serial/ch341.c?v=3.16,
the particular serial-USB-adapter device is added into the id_table,
so seems supported as per say.


Additionally, the message has changed to

###########################################################
usb 2-2: device not accepting address 8, error -71
###########################################################



Completely lost :(

On Wed, Aug 26, 2015 at 11:45 PM, Johan Hovold <[email protected]> wrote:
> On Wed, Aug 26, 2015 at 08:09:30PM +0200, Peter Stuge wrote:
>> Johan Hovold wrote:
>> > On Wed, Aug 26, 2015 at 09:39:36PM +0530, Ajay Garg wrote:
>> ..
>> > > garbage characters transmitted from embedded-device
>> ..
>> > > It seems that there is some issue with the driver.
>> >
>> > Why do think it's a driver issue?
>>
>> I can confirm similar issues with the in-tree driver and my hardware.
>
> What hardware is that?
>
>> > > Any chance this can be made to work?
>>
>> Ajay, please try building the vendor driver. That works well for me.
>
> Yes, please do.
>
>> > > Any upgrade that might solve the issue?
>>
>> There is no upgrade. Someone needs to spend a day or so on adding
>> functionality from the vendor driver to the in-tree driver, in a
>> backwards-compatible way.
>>
>> > Looks like a hardware issue, I'm afraid.
>>
>> When I got garbage from the in-tree driver it was indeed a driver issue.
>
> That's good to hear. Care to write up a patch? :)
>
> Thanks,
> Johan



--
Regards,
Ajay

2015-08-27 07:38:01

by Johan Hovold

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

[ Please avoid top-posting. ]

On Thu, Aug 27, 2015 at 12:13:32PM +0530, Ajay Garg wrote:
> I started in the morning to build the driver from the source provided
> by the vendor, but it was written in the times of kernel-version 2.4,
> and I got hopelessly stuck.

The vendor driver is only for 2.4? Peter?

> Wanting to take a break, I reset my setup, and VERY strangely, what I
> now observe is ::
>
> a)
> I am NOT able to send anything from the embedded-system to
> putty-session (nothing appears at all on the putty session).
>
> b)
> Receive is working perfectly (anything I type in the putty-session is
> received fine in the embedded-application).
>
>
> Not sure what the hell is going on :(

Did you enable hardware flow control somewhere perhaps?

> Also, as per http://lxr.free-electrons.com/source/drivers/usb/serial/ch341.c?v=3.16,
> the particular serial-USB-adapter device is added into the id_table,
> so seems supported as per say.

That id was added by 82078234d402 ("USB: serial: ch341: New VID/PID for
CH341 USB-serial") in 2008, which claims that the driver supports both
old and new devices.

> Additionally, the message has changed to
>
> ###########################################################
> usb 2-2: device not accepting address 8, error -71
> ###########################################################

This still looks like a hardware issue to me. Specifically, this happens
before the ch341 driver is even involved.

> Completely lost :(

Try to see if you can get the device to work reliably with some other
driver (vendor driver or other OS) to rule out a broken device.

Thanks,
Johan

2015-08-27 08:27:12

by Ajay Garg

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

Hi John.

On Thu, Aug 27, 2015 at 1:07 PM, Johan Hovold <[email protected]> wrote:
>
> Try to see if you can get the device to work reliably with some other
> driver (vendor driver or other OS) to rule out a broken device.
>

I tested the serial-usb adapter using a loopback-hardware-tool
(confirmed to be perfect).
Using this, I see what I type, echo it back, and see what I receive.

The putty session-settings are standard one - 9600, 8N-1, no parity.


The byte flow is
putty-on-laptop => usb-interface => serial-interface => loopback =>
serial-interface => usb-interface => putty-on-laptop.

Thereafter, following are the echo-sequences I see ::

a ==> 0
b ==> '
c ==> N



This (I guess) confirms a problem on (at least) the driver-side.

Thanks everyone for the quick replies so far, I am grateful.


Thanks and Regards,
Ajay

2015-08-27 09:45:52

by Johan Hovold

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

On Thu, Aug 27, 2015 at 01:57:01PM +0530, Ajay Garg wrote:
> Hi John.
>
> On Thu, Aug 27, 2015 at 1:07 PM, Johan Hovold <[email protected]> wrote:
> >
> > Try to see if you can get the device to work reliably with some other
> > driver (vendor driver or other OS) to rule out a broken device.
> >
>
> I tested the serial-usb adapter using a loopback-hardware-tool
> (confirmed to be perfect).
>
> Using this, I see what I type, echo it back, and see what I receive.
>
> The putty session-settings are standard one - 9600, 8N-1, no parity.
>
> The byte flow is
> putty-on-laptop => usb-interface => serial-interface => loopback =>
> serial-interface => usb-interface => putty-on-laptop.
>
> Thereafter, following are the echo-sequences I see ::
>
> a ==> 0
> b ==> '
> c ==> N
>
> This (I guess) confirms a problem on (at least) the driver-side.

Not unless you confirm that the same setup works when using a different
driver, right? Otherwise, it could still be a hw issue.

Johan

2015-08-27 12:03:05

by Peter Stuge

[permalink] [raw]
Subject: Re: Likely issue with ch341 kernel-module/driver

Johan Hovold wrote:
> > I started in the morning to build the driver from the source provided
> > by the vendor, but it was written in the times of kernel-version 2.4,
> > and I got hopelessly stuck.
>
> The vendor driver is only for 2.4? Peter?

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

The vendor driver version 1.2 readme.txt from 2014-10-10 says:

Current Driver support versions of linux kernel range from 2.6.25 to 3.13.x

It didn't build immediately against the kernel I had at hand, but with
a small touchup (patch attached) it built fine against a 3.10 kernel.


> > Also, as per http://lxr.free-electrons.com/source/drivers/usb/serial/ch341.c?v=3.16,
> > the particular serial-USB-adapter device is added into the id_table,
> > so seems supported as per say.
>
> That id was added by 82078234d402 ("USB: serial: ch341: New VID/PID for
> CH341 USB-serial") in 2008, which claims that the driver supports both
> old and new devices.

My hardware has that same VID/PID, but there is a version request
sent to the device and my version number is quite a bit higher (20-30)
than what is mentioned in the in-tree driver comments; I guess the
protocol grew with newer versions of the device, but VID/PID weren't
updated. I'm sure it's possible to have a backwards-compatible
driver, but the vendor driver differs enough from the in-tree driver
that I can't be confident that simply doing what the vendor driver
does will work also on older versions of the device.


> > ###########################################################
> > usb 2-2: device not accepting address 8, error -71
> > ###########################################################
>
> This still looks like a hardware issue to me. Specifically, this happens
> before the ch341 driver is even involved.

I haven't seen any messages like this with my hardware.


//Peter


Attachments:
(No filename) (1.84 kB)
touchup-ch34x.c-version-1.2-for-linux-3.10.patch (5.19 kB)
Download all attachments