树梅派学习 21. 串口连接

版权声明:(谢厂节的博客)博主文章绝大部分非原创,转载望留链接。 https://blog.csdn.net/xundh/article/details/82085553

1. 执行命令

sudo apt-get update 
sudo apt-get upgrade
sudo reboot

2. 编辑/boot目录下的config.txt文件

sudo nano /boot/config.txt

添加下面两行:

enable_uart=1
dtoverlay=pi3-disable-bt

3. 编辑/boot目录下的cmdline.txt文件

sudo nano /boot/cmdline.txt

原内容:

dwc_otg.lpm_enable=0 console=tty1 console=serial0,115200 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait splash plymouth.ignore-serial-consoles

参考下面内容修改:

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait splash plymouth.ignore-serial-consoles

保存退出

4. 启用串口

sudp raspi-config

选择Interfacing Options–>Serial,回车进入后选择enable

5. 关闭板载蓝牙的方法:

1.SSH登录树莓派3后,输入下面命令关闭hciuart使用uart0.

sudo systemctl disable hciuart

2.编辑/lib/systemd/system/hciuart.server将 “ttyAMA0”修改为“ttyS0”

sudo nano /lib/systemd/system/hciuart.service

将 “ttyAMA0”修改为“ttyS0”
如果没有ttyAMA0,就参照下面修改其内容:

[Unit]
Description=Configure Bluetooth Modems connected by UART
ConditionPathIsDirectory=/proc/device-tree/soc/gpio@7e200000/bt_pins
Requires=dev-serial1.device
After=dev-serial1.device

[Service]
Type=forking
ExecStart=/usr/bin/hciattach /dev/ttyS0 bcm43xx 921600 noflow -

[Install]
WantedBy=multi-user.target

6. 重启

sudo reboot

7. 安装minicom

sudo apt-get install minicom
sudo minicom -D /dev/ttyAMA0 -b 115200

minicom设置方法:

sudo  minicom -s

这里写图片描述

这里写图片描述

参考:
https://github.com/RPi-Distro/repo/issues/31
https://hallard.me/enable-serial-port-on-raspberry-pi/

猜你喜欢

转载自blog.csdn.net/xundh/article/details/82085553
21.