树莓派 Zero 2W

——《》/

记录使用树莓派 Zero 2W 中的软件设置,系统为 Pi OS Debian Bullseye。

一、系统环境

1
2
3
4
uname -a

Linux * 5.15.26-v8+ #1528 SMP PREEMPT Fri Mar 4 15:45:11 GMT 2022 aarch64 GNU/Linux
Linux * 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64 GNU/Linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
lscpu

Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Vendor ID: ARM
Model: 4
Model name: Cortex-A53
Stepping: r0p4
CPU max MHz: 1000.0000
CPU min MHz: 600.0000
BogoMIPS: 38.40
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Spec store bypass: Not affected
Vulnerability Spectre v1: Mitigation; __user pointer sanitization
Vulnerability Spectre v2: Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fp asimd evtstrm crc32 cpuid

二、安装依赖工具

1
sudo apt update && sudo apt install vim

二、更新树莓派源(阿里云)

编辑 /etc/apt/sources.list 文件

1
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak && sudo vim /etc/apt/sources.list

删除原文件所有内容,用以下内容取代:

1
2
deb http://mirrors.aliyun.com/raspbian/raspbian/ bullseye main non-free contrib
deb-src http://mirrors.aliyun.com/raspbian/raspbian/ bullseye main non-free contrib

编辑 /etc/apt/sources.list.d/raspi.list 文件

1
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak && sudo vim /etc/apt/sources.list.d/raspi.list

删除原文件所有内容,用以下内容取代:

1
deb http://mirrors.aliyun.com/raspberrypi/ bullseye main

三、安装中文语言支持

解决ssh连接后如下问题:

1
-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN)
1
sudo dpkg-reconfigure locales

选择 zh_CN.UTF-8 UTF-8en_US.UTF8,默认 locale 选 en_US.UTF8

四、更新系统及软件

1
sudo apt update && sudo apt upgrade -y && sudo rpi-update

五、安装oh-my-zsh

1
2
3
4
5
6
7
8
sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.1.2/zsh-in-docker.sh)" -- \
-t https://github.com/denysdovhan/spaceship-prompt \
-a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \
-a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \
-p git \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/zsh-users/zsh-syntax-highlighting \
-p https://github.com/zsh-users/zsh-completions

六、使用树莓派摄像头

1
2
libcamera-vid -t 0 --inline --listen -o tcp://0.0.0.0:8888
vlc tcp/h264://<ip-addr-of-server>:<port>

七、安装并使用 zerotier

1
2
3
curl -s https://install.zerotier.com | sudo bash
sudo zerotier-cli join <Network ID>
sudo zerotier-cli orbit <Node ID> <Node pwd>

八、开启I2C接口

1
sudo raspi-config 

选择 Interfacing Options -> I2C ->yes 启动 i2C 内核驱动

1
sudo reboot now

九、Python 依赖和 pip 安装

Python 3

1
2
3
4
5
6
#python3
wget https://bootstrap.pypa.io/get-pip.py
# libgl1-mesa-glx for opencv deps.
sudo apt install python3-distutils python3-smbus libgl1-mesa-glx
sudo python get-pip.py
sudo pip install RPi.GPIO spidev opencv-contrib-python

十、设置和修改WiFi连接方式

1
sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
1
2
3
4
network={
ssid="The SSID of your network (eg. Network name)"
psk="Your Wifi Password"
}

Reference

  1. Raspbian 源使用帮助
  2. Raspberrypi 源使用帮助
  3. ssh树苺派问题:-bash: warning: setlocale: LC_ALL: cannot change locale (zh_CN)
  4. Debian 下安装中文语言包和中文输入法
  5. Introducing the Raspberry Pi Cameras
  6. How To Use Raspberry Pi Cameras with Bullseye