作者: [email protected]
树莓派4b更新(系统引导程序)EEPROM Boot loader
树莓派 4B 板载了 EEPROM 芯片,参数为 4MBits/512KB,通过 SPI 协议读写。出厂时已写入了 Boot loader(系统引导程序)。通常不需要自己手动管理系统引导程序。只在必要的时候,可以通过更新树莓派 EEPROM 中的引导程序获得新的功能(需要在树莓派官方系统下进行更新操作)。引导程序更新的方法如下。
| 1 | sudo apt updatesudo apt upgrade# 安装更新工具sudo apt install rpi-eeprom# 检测更新sudo rpi-eeprom-update |
如果检测到了新版本,程序会提示「需要更新」。这时可以采用两种方式:
1、官方自动更新
| 1 | sudo rpi-eeprom-update -a |
更新完成重启即可。需要注意的是,此命令自动更新为正式版最新固件,如果需要更新到 beta 版本,可以采用下面这种方式。
2、自定义更新
获取树莓派最新的 EEPROM 固件。
| 1 | wget https://github.com/raspberrypi/rpi-eeprom/archive/master.zip # 解压下载的文件,然后进入相应的固件文件夹unzip master.zipcd rpi-eeprom-master/firmware/critical/ |
在 firmware 文件夹中,beta 为测试版本,critical 为稳定版本,可自行选择,测试版固件请慎用,如果变砖了就很难恢复。用下面的命令更新固件。
| 1 | sudo rpi-eeprom-update -d -f 固件文件名 |
更新完成后会提示「更新完成」,然后重启树莓派就更新好了!
| 1 | sudo reboot |
密码保护:基于mqtt的homeassistant温湿度采集
frp 配置





实际案例
frps端
sudo nano /lib/systemd/system/frps.service


服务端:
sudo nano /lib/systemd/system/frps.service
[Unit]
Description=fraps service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
#启动服务的命令(此处写你的frps的实际安装目录)
ExecStart=/opt/soft/frp/frp_0.33.0_linux_amd64/frps -c /opt/soft/frp/frp_0.33.0_linux_amd64/frps.ini
[Install]
WantedBy=multi-user.target
# 启动frps
sudo systemctl start frps
# 打开自启动
sudo systemctl enable frps
# 重启应用
sudo systemctl restart frps
# 停止应用
sudo systemctl stop frps
# 查看应用的日志
sudo systemctl status frps
# 停止开机自启动
systemctl disable frps
客户端:
sudo nano /lib/systemd/system/frpc.service
[Unit]
Description=frpc service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
#启动服务的命令(此处写你的frpc的实际安装目录)
ExecStart=/opt/soft/frp/frp_0.33.0_linux_amd64/frpc -c /opt/soft/frp/frp_0.33.0_linux_amd64/frpc.ini
[Install]
WantedBy=multi-user.target
frpc端

设置自定义域名

frps.ini
# frps.ini
[common]
bind_port = 7000 #与客户端绑定的进行通信的端口
vhost_http_port = 80 #访问客户端web服务自定义的端口号
frpc.ini
# frpc.ini
[common]
server_addr = x.x.x.x #公网服务器ip
server_port = 7000 #与服务端bind_port一致
#公网通过ssh访问内部服务器
[ssh]
type = tcp #连接协议
local_ip = 192.168.3.48 #内网服务器ip
local_port = 22 #ssh默认端口号
remote_port = 6000 #自定义的访问内部ssh端口号[web]
type = http
local_port = 80 #内网web服务的端口号
custom_domains = www.yourdomain.com #所绑定的公网服务器域名,一级、二级域名都可以
#保存然后启动服务./frps -c ./frps.ini,这是前台启动,后台启动命令为nohup ./frps -c ./frps.ini &
#保存然后执行./frpc -c ./frpc.ini启动,这是前台启动,后台启动命令为nohup ./frpc -c ./frpc.ini &
经验证
[Unit]
Description=frpc service
After=network.target
Wants=network.target
[Service]
#一开始没加这两行,frp总是起不来
Restart = on-failure
RestartSec = 5
#启动服务的命令(此处写你的frpc的实际安装目录)
ExecStart=/home/pi/Downloads/frp_0.44.0_linux_arm/frpc -c /home/pi/Downloads/frp_0.44.0_linux_arm/frpc.ini
[Install]
WantedBy=multi-user.target
frp下载
http://www.mixdiy.com/wp-content/uploads/2022/08/frp_0.44.0_linux_arm64.zip
http://www.mixdiy.com/wp-content/uploads/2022/08/frp_0.44.0_linux_arm.zip
http://www.mixdiy.com/wp-content/uploads/2022/08/frp_0.44.0_linux_386.zip
http://www.mixdiy.com/wp-content/uploads/2022/08/frp_0.44.0_darwin_amd64.tar
test pyscript
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入 PyScript -->
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<title>First PyScript Application</title>
<style>
py-script {
width: 100%;
height: 100%;
font-size: 20px;
text-align: center;
position: absolute;
}
</style>
</head>
<body>
<py-script>
print('Hello PyScript!')
</py-script>
</body>
</html>
pyscript参考
密码保护:about new
about mqtt over homeassistant
编译pico固件
Building MicroPython From Source
The prebuilt binary which can be downloaded from the MicroPython section of the documentation should serve most
use cases, but you can build your own MicroPython firmware from source if you’d like to customise its low-level
aspects.
TIP
If you have already downloaded and installed a prebuilt MicroPython UF2 file, you can skip ahead to Chapter 2 to
start using your board.
IMPORTANT
These instructions for getting and building MicroPython assume you are using Raspberry Pi OS running on a
Raspberry Pi 4, or an equivalent Debian-based Linux distribution running on another platform.
It’s a good idea to create a pico directory to keep all pico-related checkouts in. These instructions create a pico directory
at /home/pi/pico.
$ cd ~/
$ mkdir pico
$ cd pico
Raspberry Pi Pico Python SDK
1.2. Installing MicroPython on Raspberry Pi Pico 4
Then clone the micropython git repository. These instructions will fetch the latest version of the source code.
$ git clone -b master https://github.com/micropython/micropython.git
Once the download has finished, the source code for MicroPython should be in a new directory called micropython. The
MicroPython repository also contains pointers (submodules) to specific versions of libraries it needs to run on a
particular board, like the SDK in the case of RP2040. We need to fetch these submodules too:
$ cd micropython
$ make -C ports/rp2 submodules
NOTE
The following instructions assume that you are using a Raspberry Pi Pico. Some details may differ if you are building
firmware for a different RP2040-based board. The board vendor should detail any extra steps needed to build
firmware for that particular board. The version we’re building here is fairly generic, but there might be some
differences like putting the default serial port on different pins, or including extra modules to drive that board’s
hardware.
To build the RP2040 MicroPython port, you’ll need to install some extra tools. To build projects you’ll need CMake, a
cross-platform tool used to build the software, and the GNU Embedded Toolchain for Arm, which turns MicroPython’s C
source code into a binary program RP2040’s processors can understand. build-essential is a bundle of tools you need
to build code native to your own machine — this is needed for some internal tools in MicroPython and the SDK. You can
install all of these via apt from the command line. Anything you already have installed will be ignored by apt.
$ sudo apt update
$ sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
First we need to bootstrap a special tool for MicroPython builds, that ships with the source code:
$ make -C mpy-cross
We can now build the port we need for RP2040, that is, the version of MicroPython that has specific support for our
chip.
$ cd ports/rp2
$ make
If everything went well, there will be a new directory called build-PICO (ports/rp2/build-PICO relative to the micropython
directory), which contains the new firmware binaries. The most important ones are:
firmware.uf2 A UF2 binary file which can dragged onto the RPI-RP2 drive that pops up once your Raspberry Pi
Pico is in BOOTSEL mode. The firmware binary you can download from the documentation page
is a UF2 file, because they’re the easiest to install.
Raspberry Pi Pico Python SDK
1.3. Building MicroPython From Source 5
firmware.elf A different type of binary file, which can be loaded by a debugger (such as gdb with openocd) over
RP2040’s SWD debug port. This is useful for debugging either a native C module you’ve added to
MicroPython, or the MicroPython core interpreter itself. The actual binary contents is the same
as firmware.uf2.
You can take a look inside your new firmware.uf2 using picotool, see the Appendix B in the Getting started with
Raspberry Pi Pico book for details of how to use picotool, e.g.
$ picotool info -a build-PICO/firmware.uf2
File build-PICO/firmware.uf2:
Program Information
name: MicroPython
version: v1.18-412-g965747bd9
features: USB REPL
thread support
frozen modules: _boot, rp2, _boot_fat, ds18x20, onewire, dht, uasyncio,
uasyncio/core, uasyncio/event, uasyncio/funcs, uasyncio/lock,
uasyncio/stream, neopixel
binary start: 0x10000000
binary end: 0x1004ba24
embedded drive: 0x100a0000-0x10200000 (1408K): MicroPython
Fixed Pin Information
none
Build Information
sdk version: 1.3.0
pico_board: pico
boot2_name: boot2_w25q080
https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf