Ubuntu20.04, CH340c, 未打開串口時持續(xù)disconnect

用的是CH340C

1. 在Win10下未出現(xiàn)此問題, 在Ubuntu20.04下存在

2. CH340C的RX斷開連接, 或目標(biāo)芯片不發(fā)送數(shù)據(jù)時, 不會disconnect

3. CH340C的RX連接目標(biāo)芯片, 且目標(biāo)芯片持續(xù)發(fā)送數(shù)據(jù)時, 會定時disconnect, 間隔是固定的, 大概5秒左右

4. 如果在3的情況下, 用 cutecom 打開串口, 或用命令行 screen /dev/ttyUSB0 115200 打開串口, ch340就不會disconnect了, 問題消失


猜測是驅(qū)動的問題, 在無軟件操作, 且RX不斷有接收時接收溢出導(dǎo)致USB重啟? 有其他人遇到這個問題嗎?


dmesg日志

[?6785.293860]?usb?1-2:?USB?disconnect,?device?number?9
[?6785.294399]?ch341-uart?ttyUSB0:?ch341-uart?converter?now?disconnected?from?ttyUSB0
[?6785.294449]?ch341?1-2:1.0:?device?disconnected
[?6787.514022]?usb?1-2:?new?full-speed?USB?device?number?10?using?xhci_hcd
[?6787.663705]?usb?1-2:?New?USB?device?found,?idVendor=1a86,?idProduct=7523,?bcdDevice=81.32
[?6787.663725]?usb?1-2:?New?USB?device?strings:?Mfr=0,?Product=2,?SerialNumber=0
[?6787.663734]?usb?1-2:?Product:?USB?Serial
[?6787.666624]?ch341?1-2:1.0:?ch341-uart?converter?detected
[?6787.667417]?usb?1-2:?ch341-uart?converter?now?attached?to?ttyUSB0
[?6793.398198]?usb?1-2:?USB?disconnect,?device?number?10
[?6793.398810]?ch341-uart?ttyUSB0:?ch341-uart?converter?now?disconnected?from?ttyUSB0
[?6793.398868]?ch341?1-2:1.0:?device?disconnected
[?6795.514293]?usb?1-2:?new?full-speed?USB?device?number?11?using?xhci_hcd
[?6795.664682]?usb?1-2:?New?USB?device?found,?idVendor=1a86,?idProduct=7523,?bcdDevice=81.32
[?6795.664700]?usb?1-2:?New?USB?device?strings:?Mfr=0,?Product=2,?SerialNumber=0
[?6795.664709]?usb?1-2:?Product:?USB?Serial
[?6795.669218]?ch341?1-2:1.0:?ch341-uart?converter?detected
[?6795.670888]?usb?1-2:?ch341-uart?converter?now?attached?to?ttyUSB0
[?6800.942508]?usb?1-2:?USB?disconnect,?device?number?11
[?6800.943136]?ch341-uart?ttyUSB0:?ch341-uart?converter?now?disconnected?from?ttyUSB0
[?6800.943191]?ch341?1-2:1.0:?device?disconnected
[?6803.030516]?usb?1-2:?new?full-speed?USB?device?number?12?using?xhci_hcd
[?6803.180155]?usb?1-2:?New?USB?device?found,?idVendor=1a86,?idProduct=7523,?bcdDevice=81.32
[?6803.180174]?usb?1-2:?New?USB?device?strings:?Mfr=0,?Product=2,?SerialNumber=0
[?6803.180183]?usb?1-2:?Product:?USB?Serial
[?6803.183633]?ch341?1-2:1.0:?ch341-uart?converter?detected
[?6803.184633]?usb?1-2:?ch341-uart?converter?now?attached?to?ttyUSB0


lsusb -v output


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

Device Descriptor:

? bLength? ? ? ? ? ? ? ? 18

? bDescriptorType? ? ? ? ?1

? bcdUSB? ? ? ? ? ? ? ?1.10

? bDeviceClass? ? ? ? ? 255 Vendor Specific Class

? bDeviceSubClass? ? ? ? ?0?

? bDeviceProtocol? ? ? ? ?0?

? bMaxPacketSize0? ? ? ? ?8

? idVendor? ? ? ? ? ?0x1a86 QinHeng Electronics

? idProduct? ? ? ? ? 0x7523 HL-340 USB-Serial adapter

? bcdDevice? ? ? ? ? ?81.32

? iManufacturer? ? ? ? ? ?0?

? iProduct? ? ? ? ? ? ? ? 2 USB Serial

? iSerial? ? ? ? ? ? ? ? ?0?

? bNumConfigurations? ? ? 1

? Configuration Descriptor:

? ? bLength? ? ? ? ? ? ? ? ?9

? ? bDescriptorType? ? ? ? ?2

? ? wTotalLength? ? ? ?0x0027

? ? bNumInterfaces? ? ? ? ? 1

? ? bConfigurationValue? ? ?1

? ? iConfiguration? ? ? ? ? 0?

? ? bmAttributes? ? ? ? ?0x80

? ? ? (Bus Powered)

? ? MaxPower? ? ? ? ? ? ? 100mA

? ? Interface Descriptor:

? ? ? bLength? ? ? ? ? ? ? ? ?9

? ? ? bDescriptorType? ? ? ? ?4

? ? ? bInterfaceNumber? ? ? ? 0

? ? ? bAlternateSetting? ? ? ?0

? ? ? bNumEndpoints? ? ? ? ? ?3

? ? ? bInterfaceClass? ? ? ?255 Vendor Specific Class

? ? ? bInterfaceSubClass? ? ? 1?

? ? ? bInterfaceProtocol? ? ? 2?

? ? ? iInterface? ? ? ? ? ? ? 0?

? ? ? Endpoint Descriptor:

? ? ? ? bLength? ? ? ? ? ? ? ? ?7

? ? ? ? bDescriptorType? ? ? ? ?5

? ? ? ? bEndpointAddress? ? ?0x82? EP 2 IN

? ? ? ? bmAttributes? ? ? ? ? ? 2

? ? ? ? ? Transfer Type? ? ? ? ? ? Bulk

? ? ? ? ? Synch Type? ? ? ? ? ? ? ?None

? ? ? ? ? Usage Type? ? ? ? ? ? ? ?Data

? ? ? ? wMaxPacketSize? ? ?0x0020? 1x 32 bytes

? ? ? ? bInterval? ? ? ? ? ? ? ?0

? ? ? Endpoint Descriptor:

? ? ? ? bLength? ? ? ? ? ? ? ? ?7

? ? ? ? bDescriptorType? ? ? ? ?5

? ? ? ? bEndpointAddress? ? ?0x02? EP 2 OUT

? ? ? ? bmAttributes? ? ? ? ? ? 2

? ? ? ? ? Transfer Type? ? ? ? ? ? Bulk

? ? ? ? ? Synch Type? ? ? ? ? ? ? ?None

? ? ? ? ? Usage Type? ? ? ? ? ? ? ?Data

? ? ? ? wMaxPacketSize? ? ?0x0020? 1x 32 bytes

? ? ? ? bInterval? ? ? ? ? ? ? ?0

? ? ? Endpoint Descriptor:

? ? ? ? bLength? ? ? ? ? ? ? ? ?7

? ? ? ? bDescriptorType? ? ? ? ?5

? ? ? ? bEndpointAddress? ? ?0x81? EP 1 IN

? ? ? ? bmAttributes? ? ? ? ? ? 3

? ? ? ? ? Transfer Type? ? ? ? ? ? Interrupt

? ? ? ? ? Synch Type? ? ? ? ? ? ? ?None

? ? ? ? ? Usage Type? ? ? ? ? ? ? ?Data

? ? ? ? wMaxPacketSize? ? ?0x0008? 1x 8 bytes

? ? ? ? bInterval? ? ? ? ? ? ? ?1

can't get debug descriptor: Resource temporarily unavailable

Device Status:? ? ?0x0000

? (Bus Powered)



您好,為排除驅(qū)動軟件影響,建議先更新驅(qū)動程序看下現(xiàn)象是否仍然存在,同時我們也會對比測試該內(nèi)核自帶驅(qū)動是否有類似現(xiàn)象。麻煩發(fā)送郵件到我司技術(shù)郵箱:tech@wch.cn 獲取最新驅(qū)動。


驅(qū)動在 Ubuntu20.04 下無法編譯, 已經(jīng)更新至 issues 中, 麻煩技術(shù)排查.


您好,已更新,麻煩重新下載嘗試。


按說明編譯并替換為新的驅(qū)動, 問題依然存在, 甚至更嚴(yán)重了, 現(xiàn)在每三秒就會disconnect一次


以下是dmesg信息


== 載入新驅(qū)動


[ 9625.113986] ch341: loading out-of-tree module taints kernel.

[ 9625.114034] ch341: module verification failed: signature and/or required key missing - tainting kernel

[ 9625.114438] usbcore: registered new interface driver usb_ch341

[ 9625.114439] ch341: USB serial driver for ch340, ch341, etc.

[ 9625.114440] ch341: V1.7 On 2022.08.23


== 插入CH340C之后


[ 9833.778228] usb 2-3: new full-speed USB device number 21 using xhci_hcd

[ 9833.927577] usb 2-3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice=81.32

[ 9833.927591] usb 2-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0

[ 9833.927597] usb 2-3: Product: USB Serial

[ 9833.929259] usb_ch341 2-3:1.0: ttyCH341USB0: ch341 USB device

[ 9838.207279] usb 2-3: USB disconnect, device number 21

[ 9838.207662] usb_ch341 2-3:1.0: ch341 usb device disconnect.

[ 9840.470202] usb 2-3: new full-speed USB device number 22 using xhci_hcd

[ 9840.619301] usb 2-3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice=81.32

[ 9840.619315] usb 2-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0

[ 9840.619321] usb 2-3: Product: USB Serial

[ 9840.620851] usb_ch341 2-3:1.0: ttyCH341USB0: ch341 USB device

[ 9843.920954] usb 2-3: USB disconnect, device number 22

[ 9843.921395] usb_ch341 2-3:1.0: ch341 usb device disconnect.

[ 9846.186150] usb 2-3: new full-speed USB device number 23 using xhci_hcd

[ 9846.335506] usb 2-3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice=81.32

[ 9846.335521] usb 2-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0

[ 9846.335527] usb 2-3: Product: USB Serial

[ 9846.337151] usb_ch341 2-3:1.0: ttyCH341USB0: ch341 USB device

[ 9849.633677] usb 2-3: USB disconnect, device number 23

[ 9849.634128] usb_ch341 2-3:1.0: ch341 usb device disconnect.

[ 9851.898162] usb 2-3: new full-speed USB device number 24 using xhci_hcd

[ 9852.047286] usb 2-3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice=81.32

[ 9852.047300] usb 2-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0

[ 9852.047306] usb 2-3: Product: USB Serial

[ 9852.051420] usb_ch341 2-3:1.0: ttyCH341USB0: ch341 USB device

[ 9855.346542] usb 2-3: USB disconnect, device number 24

[ 9855.346879] usb_ch341 2-3:1.0: ch341 usb device disconnect.

[ 9857.610115] usb 2-3: new full-speed USB device number 25 using xhci_hcd

[ 9857.763530] usb 2-3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice=81.32

[ 9857.763545] usb 2-3: New USB device strings: Mfr=0, Product=2, SerialNumber=0

[ 9857.763551] usb 2-3: Product: USB Serial

[ 9857.765407] usb_ch341 2-3:1.0: ttyCH341USB0: ch341 USB device

[ 9861.058856] usb 2-3: USB disconnect, device number 25


如果用 cutecom 打開, 就不會 disconnect?


搜了一下, 發(fā)現(xiàn)有類似的問題存在

https://forum.odroid.com/viewtopic.php?t=40931

另外找到一個解決方案,?

https://stackoverflow.com/questions/70123431/why-would-ch341-uart-is-disconnected-from-ttyusb?

但是這個方案試了不起作用. 在Ubuntu20.04上沒有 90-brltty-device.rules 和? ?90-brltty-uinput.rules 這兩個文件, 只有一個 85-brltty.rules, 并且這個文件中并沒有出現(xiàn)endor為 1a86 的設(shè)備規(guī)則, 將這個規(guī)則文件禁用之后問題依然存在




不知道為什么修改完會多出一篇, 請刪除


您好,從如上提示信息來看,這個掉線屬于物理層掉線并不是驅(qū)動的提示。這個掉線和USB移除一樣,拔掉USB端會得到相同的提示信息。麻煩把設(shè)計原理圖也發(fā)下看下。


之前板子比較復(fù)雜不好測, 今天用面包板搭了一個測試電路還原了一下現(xiàn)場. 這是一片新的CH340C, 單獨焊在轉(zhuǎn)接板上便于調(diào)試.



ch340c-test.jpg

電路如下所示, 就是一個最簡單的STC8H的下載電路. 最開始猜測是3.3V LDO帶不動STC8H, 特意將STC8H單獨供電(上圖右側(cè)), 僅將 RX, TX, GND與CH340C相連. 結(jié)果發(fā)現(xiàn)這樣還是能復(fù)現(xiàn)CH340C每隔5~6秒斷開一次的問題.


癥狀: 在Ubuntu20.04下, 如果STC8H通過串口給CH340C發(fā)送數(shù)據(jù), 并且沒有使用任何串口軟件(Cutecom, screen這些)打開串口, 那么在dmesg里就能觀察到CH340C每隔5~6秒斷開一次, 然后再連上.?

如果用Cutecom或者screen打開串口觀察輸出, 那么這個問題就會消失, dmesg里看不會再產(chǎn)生新的自動disconnect的記錄.

如果Cutecom或者screen斷開串口, 問題就會再次出現(xiàn).


1662562537413434.png

dmesg日志輸出

1662562537154637.png



換了一片CH340N測試, 復(fù)現(xiàn)同樣的問題

1662565020290944.jpg


綠線上方, 用cutecom打開串口, 沒有disconnect, 綠線下方, cutecom關(guān)閉連接, 就開始出現(xiàn)disconnect了


1662565020184748.png



請問有反饋嗎? 或者是我的電路有問題??


您好,針對如上情況,有以下幾點建議:

1、芯片VCC采用5V供電時,V3建議連接退耦電容104(0.1uF),太大了影響效果。

2、VCC端常規(guī)建議大電容并連小電容(如:10uF或22uF并聯(lián)0.1uF)。

3、USB通訊不建議用面包板飛線測試,因USB規(guī)范走線有等距差分的要求,并且飛線線材不同阻抗也可能不匹配。

您可申請我司demo同步對比驗證。


  1. 電容容值V3用104也測過, 一樣的問題

  2. 5V改10uF+104, 這個明天會測

  3. 面包板是用于復(fù)現(xiàn)問題的, 原先是PCB, 因為存在這樣的問題, 又存在其它電路, 我并不能確定是CH340C的原因, 才用面包板復(fù)現(xiàn)的. 飛線都是硅膠線, 電阻很低, 不是普通的杜邦線. 關(guān)于差分同距是有考慮到的, 否則不可能在打開cutecom時長時間正常通信.


這是最開始測出上面問題的板子, 這個問題和飛線一點關(guān)系沒有.


ch340-pcb.png


我想確認(rèn)的是:?

貴司技術(shù)是否在Ubuntu20.04下用CH340C和CH340N測試了? 測的結(jié)果是什么??

如果沒測的話, 建議先測一下看看結(jié)果.

如果實在無法復(fù)現(xiàn), 我再申請你們的demo對比.


早上測試了 5V電容換成10u+104, 3V3電容換成104, 還是一樣的問題


您好,Ubuntu20.04系統(tǒng)我們內(nèi)測和客戶處使用均可以正常工作的。如上反饋現(xiàn)象確有特殊之處,當(dāng)不操作串口USB才會掉線這個現(xiàn)象較反常,還有個可能性就是系統(tǒng)監(jiān)測未使用該設(shè)備主動斷線。您這邊使用的是虛擬機還是真實環(huán)境的主機,在其他Linux主機也可做下對比,排除系統(tǒng)差異性。


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频