具体型号差异参见:树莓派实验室的树莓派各版本对照表
装机
- 准备好要安装的系统镜像
树莓派官方给的镜像列表 - 使用SD Formatter格式化SD卡
SD Formatter官方下载地址 - 使用Etcher把镜像载到SD卡
(需要注意镜像文件为img文件,请提前解压好)
Etcher官方下载地址 - Flash完SD卡后,将SD卡装到树莓派上,连接电源即开机。
参见:https://www.raspberrypi.org/documentation/installation/installing-images/README.md
屏幕设置
参见微雪百科等官方文档。
在SD卡,config.txt写入:
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
hdmi_drive=1
找到你的树莓派的IP
自己可以控制的局域网
- 在SD卡中创建空白的ssh
- 在SD卡中创建空白的wpa_supplicant.conf:
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant
GROUP=netdev
update_config=1
network={
ssid="WiFi-XXX"
psk="qwer1234"
priority=1
scan_ssid=1
}
- 下载Angry IP Scanner 扫一下 下载Angry IP Scanner 扫一下
官方下载地址
受限制的局域网,如校网
如果你没有屏幕,但是可以读SD卡,请准备一根线,连接你的电脑和你的树莓派(以下简称“Pi”)
如果你有屏幕,也可以读SD卡,则不需要Pi直连电脑。
同一IP不同Pi (可能你重装了系统)
问题回报:
ECDSA host key “IP Address” for has changed and you have requested strict checking.
输入以下内容清除已经存储的公钥信息:
ssh-keygen -R "你的远程服务器ip地址"
参见:https://www.cnblogs.com/huiy/p/6230913.html
忘记密码
有屏幕 可以改SD卡
- 关机,拔卡,用电脑读卡
- 找到cmdline.txt文件,原内容应当如下:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
在rootwait末加入 init=/bin/sh,(不得换行)改为:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait init=/bin/sh```
(问题:我的文件原内容并非如此 直接复制了上述内容)
- 安回SD卡,重新开机,停下时不要打回车,依次输入:
mount -o remount, rw /
等载入完后再输入
passwd pi
修改完成后不要忘记输入:(否则硬盘会出错)
sync
exec /sbin/init
- 复原cmdline.txt文件
参见:https://howtoraspberrypi.com/recover-password-raspberry-pi/
su:鉴定故障
sudo passwd
直接改密码就好了
换pip和系统源
参见树莓派更换国内源:
sudo nano /etc/apt/sources.list
而后清空,键入
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
sudo nano /etc/apt/sources.list.d/raspi.list
而后清空,键入
deb http://mirror.tuna.tsinghua.edu.cn/raspberrypi/debian stretch main ui
deb-src http://mirror.tuna.tsinghua.edu.cn/raspberrypi/debian stretch main ui
最后,一定要sudo apt-get update
。
参见更换pip源:
sudo mkdir -p ~/.pip
创建目录 , sudo nano ~/.pip/pip.conf
修改配置文件,清空,输入
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host= https://mirrors.aliyun.com/pypi/simple/
后保存。