- Saved searches
- Use saved searches to filter your results more quickly
- Support for QinHeng Electronics HL-340 USB-Serial adapter (CH340) #1027
- Support for QinHeng Electronics HL-340 USB-Serial adapter (CH340) #1027
- Comments
- blog.crox.net
- Обратные ссылки
- Комментарии
- crox on Saturday, 19 July. 2008 :
- net blues on Monday, 13 May. 2013 :
- Carlos on Friday, 16 January. 2015 :
- CH340 Serial device doesn’t appear in /dev/ (WSL)
- 2 Answers 2
- minicom -> usb-serial -> кодировка
- Похожие темы
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for QinHeng Electronics HL-340 USB-Serial adapter (CH340) #1027
Support for QinHeng Electronics HL-340 USB-Serial adapter (CH340) #1027
Comments
I was hoping to use Photon OS 3 far a dedicated Zigbee adapter gateway but it does not seem to support the serial to USB device that my Zigbee dongle uses. When connected I get the following:
[68363.889980] usb 2-2.1: new full-speed USB device number 5 using uhci_hcd [68365.115834] usb 2-2.1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.62 [68365.115837] usb 2-2.1: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [68365.115839] usb 2-2.1: Product: USB2.0-Serial
Bus 002 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
According to the manufacturer I should be getting:
[152343.203201] usb 1-1.4: new full-speed USB device number 5 using dwc_otg [152343.336384] usb 1-1.4: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.62 [152343.336400] usb 1-1.4: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [152343.336409] usb 1-1.4: Product: USB2.0-Serial [152343.338315] ch341 1-1.4:1.0: ch341-uart converter detected [152343.341440] usb 1-1.4: ch341-uart converter now attached to ttyUSB0
Could this be added to Photon OS 3? Or is there a configuration tweak I could perform to make it work?
The text was updated successfully, but these errors were encountered:
@dcasota Thank you for your response.
I tried that and it loaded the usbserial module but still did not create a device. I removed the usb device and replugged it in while the usebsertal module was loaded and everything behaved as before.
For the record I also have a seperate Photon OS 3 VM with aa wave device and that works fine.
I noticed that the usb device is SUPPOSED to load using dwc_otg but instead loads using uhci_hcd if that is of any help.
Floppy disk support, requested by #1020 CH341 usb to serial converterm requested by #1027 Change-Id: Iadedfbc26fb3025bfd37d617f61b47ea2624a1cb Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/10707 Tested-by: gerrit-photon Reviewed-by: Ajay Kaher
Added. Will be available in linux-4.19.138-2.ph3
I’ve just tried with 4.19.154-3.ph3-esx and nothing appears to have changed. Still no ch341-uart and still no ttyUSB device.
Just tried on a Debian 10 VM and it works.
I don’t know what the problem is.
Can confirm that.
And I think that’s because the change in e839f43 is not there anymore as the file was removed.
The change has to be done again in the other spec configs.
@mihalski In a generic environment I’ve upgraded from 4.19.79 to latest (4.19.154-1), and downgraded step by step. Actually with all other than kernel 4.19.138-2, modinfo ch341 is not found. On kernel 4.19.138-2 confirmed by @YustasSwamp it throws out:
root@ph3 [ ~ ]# modinfo ch341 filename: /lib/modules/4.19.138-2.ph3/kernel/drivers/usb/serial/ch341.ko.xz license: GPL v2 alias: usb:v1A86p5523d*dc*dsc*dp*ic*isc*ip*in* alias: usb:v1A86p7523d*dc*dsc*dp*ic*isc*ip*in* alias: usb:v1A86p7522d*dc*dsc*dp*ic*isc*ip*in* alias: usb:v4348p5523d*dc*dsc*dp*ic*isc*ip*in* depends: usbserial,usbcore retpoline: Y intree: Y name: ch341 vermagic: 4.19.138-2.ph3 SMP mod_unload
blog.crox.net
ch341.c implements a serial port driver for the Winchiphead CH341.
The CH341 device can be used to implement an RS232 asynchronous serial port, an IEEE-1284 parallel printer port or a memory-like interface. In all cases the CH341 supports an I2C interface as well. This driver only supports the asynchronous serial interface.
Обратные ссылки
Комментарии
Показывать комментарии Как список | Древовидной структурой
crox on Saturday, 19 July. 2008 :
net blues on Monday, 13 May. 2013 :
Just compiled under centos 5.4 i386
Linux atom.home.loc 2.6.18-348.el5 #1 SMP Tue Jan 8 17:57:28 EST 2013 i686 i686 i386 GNU/Linux
In addition to info above
had to comment out what is suggested here
http://softwarelivre.org/gud-ba/blog/using-a-hl-340-usb-serial-adapter-against-2.6.23-linux-kernel
AND
everything after
EXPORT_SYMBOL_GPL(tty_encode_baud_rate);
in tty_ioctl.c
and also remove the
.usb_driver line
in ch341.c (circa line 320).
after compiling and insterting
I got
drivers/usb/serial/usb-serial.c: USB Serial support registered for ch341-uart
ch341 4-1:1.0: ch341-uart converter detected
usb 4-1: ch341-uart converter now attached to ttyUSB3
usbcore: registered new driver ch341
Haven’t tried connecting anything yet, but it seems it will work.
Carlos on Friday, 16 January. 2015 :
if anyone have problems with ch341 drivers on Ubuntu 14.04 I have a patched driver and it works with 3.13.X kernel:
Автор не разрешил комментировать эту запись
CH340 Serial device doesn’t appear in /dev/ (WSL)
I have an arduino nano clone with a CH340 serial chip. It appears in lsusb as QinHeng Electronics HL-340 USB-Serial adapter and when it connects I can see it in dmesg with the following logging:
[ 31.251098] vhci_hcd vhci_hcd.0: pdev(0) rhport(0) sockfd(3) [ 31.251544] vhci_hcd vhci_hcd.0: devid(65541) speed(2) speed_str(full-speed) [ 31.252004] vhci_hcd vhci_hcd.0: Device attached [ 31.538489] vhci_hcd: vhci_device speed not set [ 31.608492] usb 1-1: new full-speed USB device number 2 using vhci_hcd [ 31.698522] vhci_hcd: vhci_device speed not set [ 31.768510] usb 1-1: SetAddress Request (2) to port 0 [ 31.812328] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.63 [ 31.812734] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [ 31.813059] usb 1-1: Product: USB2.0-Serial
Are you using USB/IP or trying to access it directly from WSL? AFAIK, only USB/IP will work (and only in the latest kernel, which you apparently have).
USB/IP (with usbipd) in WSL2 on Win11. Appears with lsusb as «Bus 001 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter» and uname -r is «5.10.60.1-microsoft-standard-WSL2»
2 Answers 2
So as of writing this, the reason for the lack of support for USB serial devices is due to their modules not being included in the WSL kernel.
You can compile your own WSL kernel with the modules by doing the following:
- You may need these dependencies: sudo apt install build-essential flex bison libssl-dev libelf-dev dwarves libncurses-dev
- Clone the WSL2 repo with: git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
- Change directory into the WSL2-Linux-Kernel folder: cd WSL2-Linux-Kernel
- Modify the kernel config by running make menuconfig KCONFIG_CONFIG=Microsoft/config-wsl .
- Go to Device Drivers -> USB Support -> USB Serial Converter support then enable your drivers in here.
- The CP210x family are also common on microcontroller dev boards.
- You probably want these baked into the kernel so press y or space twice to make sure they are enabled with rather than .
Then save and exit menuconfig and overwrite config-wsl.
— You probably shouldn’t use the following struck through points but they are an alternative to the previous two —
3. Modify the config-wsl file: nano Microsoft/config-wsl (Or use your editor of choice).
Go to line 2409 (shift+_ then 2409 in nano) and replace # CONFIG_USB_SERIAL_CH341 is not set with CONFIG_USB_SERIAL_CH341=y - You may want to do the same for CONFIG_USB_SERIAL_CP210X — another common serial-usb adapter.
- Close your text editor and save ( ctrl + x then y then enter with nano).
- Build the kernel using the WSL2 kernel configuration: make KCONFIG_CONFIG=Microsoft/config-wsl - This can take a while - You can speed this up with the -j argument but make sure to specify a value e.g. -j4
- Copy the compiled kernel to your Windows user directory: cp arch/x86/boot/bzImage /mnt/c/Users//wsl_kernel
- Create a file in your Windows user directory called .wslconfig and paste this into it:
[wsl2] kernel = C:\\Users\\\\wsl_kernel
- Shut down WSL with wsl —shutdown in a Windows command prompt.
- Open your WSL terminal and now you should be able to connect USB serial devices as outlined here.
And hopefully everything should work! (Tested on Win10 and Win11 with Ubuntu WSL2 distro)
minicom -> usb-serial -> кодировка
Подключил тестовую заглушку для тестирования com-порта (спаял 2-3, 4-6, 7-8)
Раскладка английская, на экране вводимые символы не совпадают с клавиатурой,
(английские несовпадающие или квадратики с цифрами).
Для восстановления подключился к TP-Link TL-WR941ND через serial,
вывод с роутера нормальный, но не могу ввести tpl+enter.
скорость пробовал понижать ?
Ничего, что в роутере TTL, а не RS232 уровни?
NiTr0 ★★★★★ ( 19.11.13 19:31:19 MSK )
Последнее исправление: NiTr0 19.11.13 19:32:07 MSK (всего исправлений: 1)
Скорость понизил до 38400 — символы стали не читаемые.
http://wiki.openwrt.org/toh/tp-link/tl-wr941nd
It is not possible to directly connect the serial port to one of your computer (voltage mismatch).
You have to use a converter (i.e. a Nokia CA-42 cable, serial to USB converter or something similar. An Arduino MEGA with a simple serial bridge also works).
Использую usb-serial, напрямую не подключал к com-порту.
On the ver3 board, there is a 4.7k pull-down resistor on the RX pin.
To interface with 5V devices (such as the Arduino MEGA), use a 2k2 resistor in series with the RX pin (Arduino’s TX pin). Arduino’s RX pin can be connected directly with the router’s TX pin.
Подключил в разрыв 2k2. Замкнул R356.
С роутера все символы читаются нормально.
Почему проблемы при замыкании ввод-вывод (заглушка на com-порту)?
Во первых на lookback скорость роли не играет.
Во вторых, в самом деле, что за шнурок? USB — D-Type(9)? Тогда это в самом деле RS232 с уровнем сигнала -10V .. +10V. Тебе же нужен скорей всего TTL (0V .. 5V или 0V .. 3.5V — там тоже есть варианты).
Далее, скорость по умолчанию у большинства устройств 9600 8N1 (с неё и надо начинать) или 115200 8N1, что тоже стало сейчас распространнено.
Мусор на линии может говорить о чём угодно.
Ну и в заключение, я тут тоже недавно плакался: Linux — это…
beastie ★★★★★ ( 19.11.13 20:42:22 MSK )
Последнее исправление: beastie 19.11.13 20:43:51 MSK (всего исправлений: 1)
USB-serial — они разные какбы. Те что с DB9 — самый что ни на есть RS232.
Вы были правы.
Первый шнурок USB-serial (ch3401) неправильно отображал вводимые символы при замыкании Rx-Tx,
но при этом нормально читал вывод с роутера. Успешно сдал обратно.
Второй шнурок Gembird (PL2303) оказался честным RS232:
— есть вторая микросхема — преобразователь в 12В;
— в разъеме DB-9 распаяны все провода.
При замыкании Rx-Tx отображает ввод правильно.
Можно использовать для оборудования кроме программаторов.
С роутера выводился нечитаемый мусор, настройки minicom не помогали.
Вскрыл корпус Gembird и подпаялся прямо к ножкам микросхемы PL2303 у самого корпуса микросхемы.
Выводы PL2303 (1 — Tx ,7 — земля, 5 — Rx).
Вывод с роутера нормальный, ввел tpl и получил командную строку.
Похожие темы
- Форум QinHeng Electronics HL-340 USB-Serial adapter (USB-to-COM) (2015)
- Форум Подключить HDD по RS-232 через Arduino (2017)
- Форум ESP8266EX D1 mini странно себя ведёт, при попытке прошивки (2023)
- Форум Неправильно работает USB-SERIAL CH340/CH341 (2014)
- Форум Не могу заставить работать USB RS232 converter (2017)
- Форум Как настроить принтер в Ubuntu? (2009)
- Форум Проброс USB устройства в Wine (Fedora 30) (2019)
- Форум У меня появился программатор СН341А, но я не могу найти статей, как им работать с онтопика. (2018)
- Форум A4Tech PK-910H (2021)
- Форум Помогите нубу оживить свисток ZTE MF831 от Билайна (2015)