为了方便远程调试路由器和交换机或者console口的设备,避免携带笔记本处于机房嘈杂之中,可以充分利用下我的闲置的树莓派,让它充当一个小终端在前线,坐在办公室使用台式机远程连上树莓派,然后在树莓派上调试console。
系统安装可参考https://blog.csdn.net/gsl371/article/details/83931999,或者官网最新的指导说明。
烧录成功后,不要着急拔掉SD卡,有很关键的两步要走:
2016年底之后的系统,要在SD 卡根目录新建一个ssh的空白文件,才能开启ssh。可以新建文本文件,然后改名为“ssh”,同时删除拓展名后缀。
在cmdline.txt文件中,添加一行ip=192.168.1.110,必须很电脑在同一个网段
把电脑终端设置成和树莓派在一个网段,重启树莓派,就可以ssh登陆了。
目前的系统默认支持pl2303芯片,插上usb转串口设备到usb口
发现串口设备
串口的名字
下面在修改minicom参数时用到这个名字。
至此,串口设备已经正常安装。
The Raspberry Pi uses dhcpcd to configure TCP/IP across all of its network interfaces. The dhcpcd daemon was written by Roy Marples and is intended to be an all-in-one ZeroConf client for UNIX-like systems. This includes assigning each interface an IP address, setting netmasks, and configuring DNS resolution via the Name Service Switch (NSS) facility.
By default, Raspberry Pi OS attempts to automatically configure all network interfaces by DHCP, falling back to automatic private addresses in the range 169.254.0.0/16 if DHCP fails. This is consistent with the behaviour of other Linux variants and of Microsoft Windows.
Static IP address
If you wish to disable automatic configuration for an interface and instead configure it statically, add the details to /etc/dhcpcd.conf. For example:
interface eth0
static ip_address=192.168.0.4/24
static routers=192.168.0.254
static domain_name_servers=192.168.0.254 8.8.8.8
安装minicom
先更新
pi@raspberrypi:~ $ sudo apt update
Get:1 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
Get:2 http://archive.raspberrypi.org/debian buster/main armhf Packages [330 kB]
Get:3 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Get:4 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages [13.0 MB]
Get:5 http://raspbian.raspberrypi.org/raspbian buster/contrib armhf Packages [58.7 kB]
Get:6 http://raspbian.raspberrypi.org/raspbian buster/non-free armhf Packages [103 kB]
Fetched 13.5 MB in 50s (269 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
64 packages can be upgraded. Run 'apt list --upgradable' to see them.
安装minicom
pi@raspberrypi:~ $ sudo apt install minicom
设置minicom
pi@raspberrypi:~ $ sudo minicom -s
使用上下键选择Serial port setup,回车。
先择前面的字母,先择编辑项,修改完后回车确认。
按下“A”更改Serial Device为“/dev/ttyUSB0”,表示minicom要操作的是usb转串口。
按“E”修改Bps/Par/Bits(数据传输的波特率以及数据传输格式),波特率选为9600 8N1(数据位8,奇偶校验无,停止位1),硬/软件流控制分别键入“F”和“G”,并且都选No。
打开minicom
pi@raspberrypi:~ $ sudo minicom
只能在一个窗口中使用,在此打开报锁定
退出,CTRL-A 打开帮助,按q键退出
把rj45头插入路由器或交换机console,回车,可以看到回显。