问题背景
在去年RDC2022上很幸运抽中了纪念板柿饼M7。在此感谢RT-Thread!!!本文介绍了Ubuntu22.04下开发RT Smart遇到的无法使用ch34x串口问题。
问题描述
Ubuntu22.04无法使用ch34x串口
使用lsusb
命令可以看到有Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics CH340 serial converter
是能识别出ch34x设备
原因分析
- Ubuntu22.04自带的ch34x驱动版本过老
使用ls /lib/modules/$(uname -r)/kernel/drivers/usb/serial
命令查看Ubutnu自带驱动,找到ch341.ko
发现是2013年的文件…(无语~)先把旧驱动删除sudo rm ch341.ko
找到一篇相似的文章ubuntu20.4系统安装CH340驱动并使用串口调试助手看来不是我一个人遇到相同的问题…
2.brltty
进程占用了串口
使用sudo dmesg | grep tty
命令可以看到
[ 0.223411] printk: console [tty0] enabled
[ 44.099146] usb 1-1: ch341-uart converter now attached to ttyUSB0
[ 44.673749] usb 1-1: usbfs: interface 0 claimed by ch34x while ‘brltty’ sets config #1
[ 44.675063] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
解决过程
WCH官网下载最新的驱动CH341SER_LINUX.ZIP
解压驱动
unzip CH341SER_LINUX_ZIP
得到三个文件ch34x.c
Makefile
readme.txt
// ChangeLog
// 1.0 - 1.1 modified to solve transmition between ch341 and ch341
// 1.1 - 1.2 Support high Linux kernel
Instructions
Note: 1.Please run followed executable programs as root privilege
2.Current Driver support versions of linux kernel range from 2.6.25 to 3.13.x
3.Current Driver support 32bits and 64bits linux systems
Usage:
(load or unload linux driver of CH34x)
//compile
#make
//load ch34x chips driver
#make load
//unload ch34x chips driver
#make unload
// 1.2 - 1.3 Fix some bugs
编译安装驱动
readme.txt里面介绍到驱动的加载方式,但注意到第7行写着支持的内核版本从2.6.