raspberry pi zero w硬件串口,软件串口soft_uart
使用百度搜索没找到自己想要的资料,就稍微写了一点。
raspberry pi zero w硬件串口,软件串口
官方文档:https://www.raspberrypi.org/documentation/configuration/uart.md
一.打开硬件串口
1)zero w主串口使用的是mini_uart,次串口PL011被分配给蓝牙,官方系统默认zw的mini_uart是禁用的。
2)打开硬件串口,要先关闭login shell to be accessible over serial,启用the serial port hardware to be enabled。
3)config.txt内添加dtoverlay=disable-bt,将会禁用蓝牙设备并且使PL011作为主串口。
或者添加dtoverlay=miniuart-bt,蓝牙使用mini_uart,硬件串口使用PL011。
disable_splash=1,禁用开机彩虹屏。
4)/boot/cmdline.txt修改需要的波特率。
二.启动软件串口
方法一:RpiSoft-UART
https://github.com/themrleon/RpiSoft-UART
需要在电脑端下载raspberry linux kernel,raspberry tools,并进行交叉编译。
https://github.com/raspberrypi/linux
https://github.com/raspberrypi/tools
选择的内核编译版本必须与使用的系统内核版本一致。
方法二:pigpio
也支持gpio模拟串口
方法三:soft_uart
https://github.com/adrianomarto/soft_uart
个人比较推荐这个,编译的速度也快,不麻烦,支持自定义gpio口。
git clone https://github.com/adrianomarto/soft_uart
sudo apt-get install raspberrypi-kernel-headers
cd soft_uart
make
sudo make install
sudo insmod soft_uart.ko
注意软件串口波特率比较低,作者说不要超过4800,我试过9600,偶尔会有几个字符错误,使用常见的115200就全是乱码了。
这样就实现了用电脑调试硬串树莓派一软传树莓派二