自己的电脑装的是双系统,ubuntu22.04安装了很久好久没有(WSL2确实解决了频繁依赖linux的问题)。昨天尝试搞一下STM32MP135的系统搭建,开始启用ubuntu22.04。但是遇到了很多问题,其中一个问题就是CH340的驱动。
在折腾的过程中遇到了多个问题,这里一并汇总。为了尊重原创者的成果,我这里将两篇博文的原始文章连接粘贴如下:
小言W的:串口驱动签名问题解决方案
鱼香ROS的:驱动被占用问题解决方案
使用lsusb命令,发现发现了WCH的设备觉得应该没什么问题了。
Bus 001 Device 013: ID 1a86:7523 QinHeng Electronics CH340 serial converter
实际上查看用ls /dev/tty*
却看不到新增的设备。
所以我判断是没有CH340的驱动,就去官网下载驱动:CH341SER_LINUX.ZIP .然后按照readme的教程make,然后make install.但是最后还是没有成功。
所以就尝试用sudo dmesg
查看新插入的设备。(故意插拔了一次,所以生成的信息在最后。)结果提示:
[ 820.295049] usb 1-6.2: USB disconnect, device number 9
[ 822.334672] usb 1-6.3: new full-speed USB device number 10 using xhci_hcd
[ 822.460652] usb 1-6.3: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.64
[ 822.460664] usb 1-6.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 822.460668] usb 1-6.3: Product: USB Serial
[ 822.480251] Loading of unsigned module is rejected
[ 823.034128] input: BRLTTY 6.4 Linux Screen Driver Keyboard as /devices/virtual/input/input45
提示未签名的模块被拒绝(Loading of unsigned module is rejected)。
@小言W的文章提供了很详尽的问题怎么解决的描述。归纳如下:
sudo apt install mokutil
sudo apt install shim-signed
# 生成新签名,参考https://wiki-ubuntu-com.translate.goog/UEFI/SecureBoot?_x_tr_sl=auto&_x_tr_tl=zh-CN&_x_tr_hl=en-US&_x_tr_pto=wapp
sudo update-secureboot-policy --new-key
# 生成密钥,参考https://wiki-ubuntu-com.translate.goog/UEFI/SecureBoot/KeyManagement/KeyGeneration?_x_tr_sl=auto&_x_tr_tl=zh-CN&_x_tr_hl=en-US&_x_tr_pto=wapp
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Descriptive name/"
#导入签名
sudo mokutil --import /var/lib/shim-signed/mok/MOK.der
Enroll MOK > Continue > 输入密码 > Reboot
第二篇文章中引用的为内核模块签名说明的更详细。
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 /var/lib/shim-signed/mok/MOK.priv /var/lib/shim-signed/mok/MOK.der ch341.ko
# 检查以下驱动十分签名成功
hexdump -C ch341.ko | tail
# 若成功会有Module signature appended字样
sudo make load
sudo make install
# 检查模块load情况
lsmod | grep ch34
但是我的/dev/tty*中还是没有新设备。非常困惑。第二篇文章给了指引。
继续使用dmesg
命令查看如果出现类似问题:
interface 0 claimed by ch341 while 'brltty' sets config #1
说明驱动被britty占用.那么直接移除就成了。
sudo apt remove brltty
brltty的描述如下:
With one exception, this document applies to using BRLTTY with any braille device. The exception is that, when key bindings are given, it assumes that the braille device has a braille keyboard. If it doesn't, then, as mentioned above, you can look up your device's corresponding key bindings online.
说是一个盲文设备的驱动。