BPI-R2 + ch341 serial adapter = not work

Hi !

has anyone tried using a serial adapter on CH341 (USB - RS485) ? This adapter recognise by kernel, but not working ((( In Windows this adapter work fine.

dmesg output: [72004.731453] usb 3-1: new full-speed USB device number 2 using xhci-mtk [72004.893011] ch341 3-1:1.0: ch341-uart converter detected [72004.902875] usb 3-1: ch341-uart converter now attached to ttyUSB0

lsusb output: Bus 003 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

uname -a output: Linux bpi-iot-ros-ai 4.4.70-BPI-R2-Kernel #4 SMP Thu Mar 29 10:31:30 CST 2018 armv7l armv7l armv7l GNU/Linux

I find some information about this promblem - https://forums.linuxmint.com/viewtopic.php?t=230835 How I can change and recomplile CH341 module ?


dimap101

Latest CH341 module source http://www.wch.cn/download/ch341ser_linux_zip.html

Kernelsource for your current kernel: https://github.com/BPI-SINOVOIP/BPI-R2-bsp

But i don’t think you can get the driver working because kernel is 4 years old. You can try newer one (e.g. 5.4) from my repo and include driver there if it’s not already there

Newer kernels from 2007+ (2.6.24 ) seem to contain driver for this chip

Thank you for answer. Right now, I’m not sure if the problem is in the ch341 driver. I changed the USB-RS485 adapter to new ones (FT232RL), but it still doesn’t work. Under Windows 10, the new adapter also works well.

My kernels (and maybe odficial too) do not contain drivers for usb2serial devices yet…

Just to be sure…You want to use usb-side on r2 or serial side (for get debug-console)?

I want use USB side on R2. I need connect RS485 device to R2.

USB device both adapter (ch341 and FT232RL/FTDI) discovered correctly and visible. Device file /dev/ttyUSB0 is present when adapter connected.

Ok,then you need kernel with matching driver installed on r2…

I check kernel configuration in BSP - USB serial driver included (CH341 and FDTI also included).

Are other usb-devices recognized (e.g. storage) on same port? Do you see your usb2serial in lsusb? Look in dmesg if anything happens when you connect your device

dmesg -w

Or look if there is anything related in syslog

grep -i 'usb' /var/log/syslog

dmesg -w | grep serial

[ 13.057814] usbcore: registered new interface driver usbserial

[ 13.057890] usbcore: registered new interface driver usbserial_generic

[ 13.057954] usbserial: USB Serial support registered for generic

[ 13.079165] usbserial: USB Serial support registered for FTDI USB Serial Device

lsusb | grep serial

Bus 003 Device 002: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC

Looks good…and no /dev/ttyUSBx?

/dev/ttyUSB0 is present. But not receive data from RS485… Tomorкow I try connect Windows 10 terminal via RS485 to R2 terminal.

Maybe you need to configure serial port (baudrate,stopbits,…)

send/receive data by bash script:

#!/bin/sh

cmd=echo -n "x00x01x01x01x01x01x01x01x01x77x81" | sed 's/x/\\\0x/g'

port=“ttyUSB0”

ans="./1"

stty -F /dev/$port 9600 -cstopb -oddp -opost raw

echo -n $cmd | awk -F’’ ‘{for(i=1; i<=NF; i++) {printf “%c”, $i}}’ > /dev/$port & ( dd if=/dev/$port of=$ans count=128 ) & sleep 10 ; kill $!