介绍
The Raspberry Pi Zero W extends the Pi Zero family and comes with added wireless LAN and Bluetooth connectivity.
产品图
配置
欧盟合规认证
pi@raspberrypi:~ $ dpkg --print-architecture
armhf
armhf
架构
安装系统
格式化SD卡为FAT分区,用 Win32DiskImager 把系统镜像如2020-08-20-raspios-buster-armhf-full.img
写入到SD卡。写入后SD卡会分成两个区,Windows下只能见到一个BOOT区
在BOOT分区下创建两个文件,用于连接路由器和开启SSH
1.空文件 ssh
2.Unix文本文件 wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=CN
network={
ssid="YourWifiName"
psk="YourWifiPassword"
scan_ssid=1
}
路由器WIFI账号密码写你自己的。该文件会在初次系统安装时被读取用于配置WIFI,然后该文件就会被自动删除。
把SD卡插回树莓派,把usb数据线一端插到树莓派zeroW(两个口都可以,标有 USB
是数据+供电,标有 PWR IN
的是单供电),一端插到电脑上。
这时候树莓派就会闪灯开机(如果没有插SD卡,灯是一点都不会亮的)
等到树莓派灯不怎么闪烁时,登陆路由器后台看看
远程登陆
ssh
电脑cmd窗口输入
ssh pi@192.168.123.8
密码默认为 raspberry
修改密码命令:
passwd
修改镜像源
sudo sed -i 's|raspbian.raspberrypi.org|mirrors.ustc.edu.cn/raspbian|g' /etc/apt/sources.list
sudo sed -i 's|//archive.raspberrypi.org|//mirrors.ustc.edu.cn/archive.raspberrypi.org|g' /etc/apt/sources.list.d/raspi.list
sudo apt update
Windows远程桌面(RDP)
安装 Windows 远程桌面服务
sudo apt-get install xrdp
效果图
也可以用支持ssh rdp x11等多种协议的远程控制工具 Mobaxterm
更多
高级设置
还有一些高级设置,可以通过命令行设置
sudo raspi-config
如果是 可以安装 rasp-AP
GPIO 针脚
http://www.ruanyifeng.com/blog/2017/06/raspberry-pi-tutorial.html
树莓派学习二(点亮LED灯)
讓你的 Raspberry Pi 透過 GPIO 閃爍 LED 燈
Shell C C++ Java Python NodeJS 等语言均有支持GPIO的库,详情谷歌
查看硬件输出信息
如查看 SoC 温度(也就是常说的 CPU)
vcgencmd measure_temp
详见:https://www.raspberrypi.org/documentation/raspbian/applications/vcgencmd.md
正确关机
sudo halt
驱动开发
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/README.md
译文:BCM2835
这是树莓派 A, B, B+, the Compute Module 及 Zero 系列所用的博通 CPU 芯片
请参考:
Peripheral specification 参考手册
注:该文档有一些错误,已知错误和一些额外信息可以点这里获取
GPU 文档 及其 开源驱动
ARM1176 processor
ARM1176JZF-S
Also see the Raspberry Pi 2 Model B's chip, BCM2836.
Peripheral specification(ARM 外设说明书) 是博通的数据手册,在其文档介绍里可看到这么一行:
The purpose of this
datasheet
is to provide documentation for these peripherals in sufficient
detail to allow a developer to port an operating system to BCM2835.
There are a number of peripherals which are intended to be controlled by the GPU. These are
omitted from this datasheet. Accessing these peripherals from the ARM is not recommended.
总结:
资料名 | 文件名 | 网址 |
---|---|---|
CPU 数据手册 | BCM2835-ARM-Peripherals.pdf | https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf |
CPU 数据手册错误修正与注意 | BCM2835 datasheet errata - eLinux.org.mhtml | https://elinux.org/BCM2835_datasheet_errata |
ZeroW 电路原理图(schematics) | rpi_SCH_ZeroW_1p1_reduced.pdf | https://www.raspberrypi.org/documentation/hardware/raspberrypi/schematics/rpi_SCH_ZeroW_1p1_reduced.pdf |
GPU 文档 | VideoCoreIV-AG100-R.pdf | https://docs.broadcom.com/docs/12358545 |
CPU 开源驱动 | Brcm_Android_ICS_Graphics_Stack.tar.gz | https://docs.broadcom.com/docs/12358546 |
为方便大家使用,我已经把上面5个资料都打包了,下载地址:Pi_zeroW.zip 更新日期:2021-01-13
以上硬件资料均可在树莓派官网 HardWare 文档 找到
软硬件等更多资料详见:https://www.raspberrypi.org/documentation/
PS. 树莓派 ZeroW 的 CPU 是 BCM2835,该 CPU 内核是 ARM1176 processor 系列里的 ARM1176JZF-S
剩下的就是:看手册/看寄存器/看电路图->写代码了,和普通的 ARM Linux 驱动开发没有什么两样
给个案例:
驱动编写教程(非树莓派,但大同小异): [野火]i.MX Linux开发实战指南-驱动章节
开发方式推荐:VSCode + Remote SSH + Linux X64 桌面操作系统(或虚拟机)交叉编译环境 和 NFS 服务 + 树莓派挂载 NFS
在 VSCode 直接调用 Makefile 的方法:https://www.cnblogs.com/yucloud/p/vs_code_config.html#makefile
树莓派挂载 NFS:
# 192.168.12.130 是你的服务器地址,一般是台式/笔记本/虚拟机系统上的 NFS Server
mount -t nfs 192.168.12.130:/mnt /media
#修改 /etc/fstab 文件,添加以下代码,更多参数见 https://wiki.archlinux.org/index.php/Fstab_(简体中文)#字段定义
192.168.12.130:/mnt /mnt nfs rw
NOTE: 不要在 zeroW 上编译,因为它没有树莓派3 那么好的性能。
拉取代码
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.4.83+ #1379 Mon Dec 14 13:06:05 GMT 2020 armv6l GNU/Linux
# 根据版本号和Github仓库代码分支,可确定应该拉取 rpi-5.4.y
# 然后在 笔记本或台式机上拉取代码 git clone --depth=1 --branch rpi-5.4.y https://github.com/raspberrypi/linux
# 编译构建部分请看以下官方资料
- 内核源码及其编译构建指南(请看 Cross-compiling 部分): https://www.raspberrypi.org/documentation/linux/kernel/building.md
- raspbian 系统相关配置:https://www.raspberrypi.org/documentation/raspbian/
- Github 搜索关键词"rasp kernel module"
- 裸机编程(像STM32单片机那样)Raspberry Pi Zero baremetal examples: https://github.com/dwelch67/raspberrypi-zero
- 树莓派官方论坛-裸机及汇编区Bare metal, Assembly language