树莓派3B串口通讯的配置

【前面说的话】: 对于树莓派3 B+ 来讲,他的uart 功能有三种: 一、内部蓝牙使用 二、控制终端使用 三、与其余设备进行串口通讯;然而 树莓派 3 确只提供一个硬件 uart,对应硬件接口 p14-TX/P15-RX。全部树莓派3 的串口只能是鱼与熊掌不能兼得了。树莓派官方系统 Raspbian Jessie releases 默认串口是给蓝牙使用。若是想让串口做为控制终端调试口即 serial console ,则须要对系统配置进行修改,关闭蓝牙而且映射 pl011 UART 到p14和p15。html

一:安装系统并配置系统 Raspbian Jessie releases 系统安装到sd卡上(其余系统没有测试),相信看到该博文的你这一步确定已经完成了。 配置系统: sudo raspi-config
执行:Expand filesystem and enable serial on advanced page exit and reboot测试

sudo apt-get update.net

sudo apt-get upgrade调试

sudo rebootserver

二: 修改配置 编辑 /lib/systemd/system/hciuart.server 而后用 ttyS0 替换文件中的 ttyAMA0
sudo vi / /lib/systemd/system/hciuart.server 替换文件中的 ttyAMA0 为 ttyS0(若是没有ttyAMA0可不改)htm

三:设置 Device tree sudo vi /boot/config.txt 在文件末尾添加 : dtoverlay=pi3-miniuart-bt 保存->退出blog

四:编辑 /boot/cmdline.txt 文件 sudo nano /boot/cmdline.txt 修改文件中的内容为: dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait 退出并保存文件。 sudo reboot 这个时候咱们的串口就可使用了,串口的设备号为 /dev/ttyAMA0接口

检测:用pi4j中的串口demo打开/dev/ttyAMA0,pc用串口调试助手打开便可,须要注意的是rx和tx口不要反了,若是不行,能够短接树莓派的串口检测一下pc串口线是否正常。ip

参考博客: 1:http://blog.csdn.net/qq_30968657/article/details/52044876 2:http://blog.csdn.net/victo2012/article/details/51473992ci

3:http://shumeipai.nxez.com/2016/08/08/solution-raspberry-pi3-serial-uart-use-issues.html(旧的,部分参考) 4:http://ukonline2000.com/?p=880

###################################华丽丽的分割线####2017-04-07修改################# 基于2017年3月2号RASPBIAN JESSIE WITH PIXEL镜像 其实只需这几部分操做: 一、sudo raspi-config 选择 5 Interfacing Options Configure connections to peripherals 进入serial配置使能。 二、sudo vi /boot/config.txt 在文件末尾添加 : dtoverlay=pi3-miniuart-bt enable_uart=1 保存->退出 三、sudo apt-get update 四、sudo nano /boot/cmdline.txt dwc_otg.lpm_enable=0 console=serial10,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait 去掉加粗斜体,保存重启便可。

相关文章
相关标签/搜索