okass 在版块 Linux平台 中发起了话题 Ubuntu/Linux Mint 安装CH34x USB转串口驱动 2年, 10个月前
一、安装CH340驱动
1.查看ubuntu系统自带的驱动$ ls /lib/modules/$(uname -r)/kernel/drivers/usb/serial
aircable.ko cypress_m8.ko garmin_gps.ko iuu_phoenix.ko metro-usb.ko opticon.ko quatech2.ko ti_usb_3410_5052.ko visor.ko
ark3116.ko digi_acceleport.ko io_edgeport.ko keyspan.ko mos7720.ko option.ko safe_serial.ko upd78f0730.ko whiteheat.ko
belkin_sa.ko empeg.ko io_ti.ko keyspan_pda.ko mos7840.ko oti6858.ko sierra.ko usb_debug.ko wishbone-serial.ko
ch341.ko f81232.ko ipaq.ko kl5kusb105.ko mxuport.ko pl2303.ko spcp8x5.ko usbserial.ko xsens_mt.ko
cp210x.ko f81534.ko ipw.ko kobil_sct.ko navman.ko qcaux.ko ssu100.ko usb-serial-simple.ko
cyberjack.ko ftdi_sio.ko ir-usb.ko mct_u232.ko omninet.ko qcserial.ko symbolserial.ko usb_wwan.ko可以看到含有ch341.ko文件,系统自带的版本比较老,删除掉:
$ cd /lib/modules/$(uname -r)/kernel/drivers/usb/serial
sudo rm -rf ch341.ko2.下载驱动
链接:http://www.wch.cn/download/CH341SER_LINUX_ZIP.html
解压后得到以下3个文件:
ch34x.c Makefile readme.txt
3.查询操作系统的发行编号
$ uname -r
5.4.0-94-generic
https://elixir.bootlin.com/linux/v5.4.94/source/drivers/usb/serial/ch341.c
根据查询到的操作系统的发行编号,打开对应的版本,复制所有内容替换ch34x.c内容。
4.编译源程序
cd切换至下载的文件夹,make编译源码,生成ch34x.ko文件:$ make
make -C /lib/modules/5.8.0-55-generic/build M=/home/jiki/Downloads/CH341SER_LINUX
make[1]: 进入目录“/usr/src/linux-headers-5.8.0-55-generic”
AR /home/jiki/Downloads/CH341SER_LINUX/built-in.a
CC [M] /home/jiki/Downloads/CH341SER_LINUX/ch34x.o
MODPOST /home/jiki/Downloads/CH341SER_LINUX/Module.symvers
CC [M] /home/jiki/Downloads/CH341SER_LINUX/ch34x.mod.o
LD [M] /home/jiki/Downloads/CH341SER_LINUX/ch34x.ko
make[1]: 离开目录“/usr/src/linux-headers-5.8.0-55-generic”注:编译需要安装gcc与make。
5.复制ch34x.ko文件
复制ch34x.ko文件至系统默认驱动文件夹:sudo cp ch34x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
$ sudo cp ch34x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
$ ls /lib/modules/$(uname -r)/kernel/drivers/usb/serial
输入lsmod命令查看:
$ lsmod
Module Size Used by
ch34x 24576 0
usbserial 53248 1 ch34x
nls_iso8859_1 16384 2
nvidia_uvm 1019904 0
nvidia_drm 57344 13
nvidia_modeset 1228800 10 nvidia_drm看到ch34x模块,至此ch34驱动安装完成,如果未看到,输入sudo depmod -a命令,重启一次电脑。
二、cutecom串口调试助手
1.安装cutecom串口调试助手
$ sudo apt install cutecom
2.测试
终端窗口输入命令启动cutecom$ sudo cutecom
插入ch340设备,选择usb口,点击seting进行串口参数,再点击Open。
最后在线: 活跃于 6个月, 2周前
评论: 7
获赞: 0
文章: 0
粉丝: 68
关注: 68
好友: 8
User Rating: ( vote)