树莓派默认支持串口启动,所以只需要一根USB转TTL转换器连接树莓派与电脑,即可通过串口控制调试树莓派,电脑上使用putty串口调试工具进行连接。
在树莓派3中,40pin对应的管脚图如下所示:
raspberry pi | GPIO pin | USB-TTL Pin |
6 | GND | GND |
8 | TXD | RXD |
10 | RXD | TXD |
首次给树莓派烧完官方系统后是无法通过串口登录的,因为官方默认没有开启串口用来输出启动信息。
需要在烧完官方系统的SD卡上找到config.txt文件,然后再最后面添加一句:
enable_uart=1
保存后,打开PC端的串口通信软件(如putty),设置串口波特率为115200,这是默认的串口通信波特率与树莓派的串口波特率一致才能正确通信。 之后插卡启动树莓派,就会在终端窗口看到启动信息了。
默认用户名:pi
默认密码:raspberry
首次登录后,进行如下配置将树莓派的ip设置为固定的ip地址。
打开/etc/network/下的interfaces,进行如下配置:
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.201
netmask 255.255.255.0
gateway 192.168.1.1
#allow-hotplug wlan0
#iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
可见,ip地址被设置成了192.168.1.201。
至此,即可使用winscp进行登录了。