ubuntu20.4系统安装CH340驱动并使用串口调试助手
Posted 疯狂程序
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu20.4系统安装CH340驱动并使用串口调试助手相关的知识,希望对你有一定的参考价值。
目录
一、安装CH340驱动
1.查看ubuntu系统自带的驱动
jiki@jiki-M15X:~$ 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文件,系统自带的版本比较老,删除掉:
jiki@jiki-M15X:~$ cd /lib/modules/$(uname -r)/kernel/drivers/usb/serial
sudo rm -rf ch341.ko
2.下载驱动
链接:http://www.wch.cn/download/CH341SER_LINUX_ZIP.html
解压后得到以下3个文件:
3.查询操作系统的发行编号
命令:uname -r
打开:https://elixir.bootlin.com/linux/v5.8/source/drivers/usb/serial/ch341.c
根据查询到的操作系统的发行编号,打开对应的版本,复制所有内容替换ch34x.c内容。
4.编译源程序
cd切换至下载的文件夹,make编译源码,生成ch34x.ko文件:
jiki@jiki-M15X:/lib/modules/5.8.0-55-generic/kernel/drivers/usb/serial$ cd /home/jiki/Downloads/CH341SER_LINUX
jiki@jiki-M15X:~/Downloads/CH341SER_LINUX$ 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
jiki@jiki-M15X:~/Downloads/CH341SER_LINUX$ sudo cp ch34x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
[sudo] jiki 的密码:
jiki@jiki-M15X:~/Downloads/CH341SER_LINUX$ 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
ch34x.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
输入lsmod命令查看:
iki@jiki-M15X:~/Downloads/CH341SER_LINUX$ 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.测试
终端窗口输入sudo cutecom命令启动cutecom
插入ch340设备,选择usb口,点击seting进行串口参数,再点击Open。
至此CH340驱动安装并测试完成。
以上是关于ubuntu20.4系统安装CH340驱动并使用串口调试助手的主要内容,如果未能解决你的问题,请参考以下文章
ubuntu20.4系统安装CH340驱动并使用串口调试助手