树莓派cm4更新bootloader(eeprom)

发布时间 2023-06-20 22:28:56作者: PYPYN

cm4不能在系统里通过 rpi-eeprom-update 指令进行升级,也不能通过 update 进行更新,只能通过recovery模式进行更新。

以下为Windows的升级方式。

Setp 1:下载recovery

git clone --depth=1 https://github.com/raspberrypi/usbboot

 

Setp 2:安装rpiboot

进入usbboot\win32,双击rpiboot_setup.exe安装

 

Setp 3:修改启动顺序(可选)

如果你不想修改启动顺序,那么请跳过此步

修改启动顺序需要在Linux或WSL下进行,因为需要用到shell环境。

默认的启动顺序:SD CARD/eMMC > USB-MSD > NVME > BCM-USB-MSD > NETWORK > RESTART

BOOT_ORDER=0xf25641 

修改的启动顺序:NVME > USB-MSD > BCM-USB-MSD > SD CARD/eMMC > NETWORK > RESTART

BOOT_ORDER=0xf21564

[all]
BOOT_UART=1
WAKE_ON_GPIO=1
POWER_OFF_ON_HALT=0

# Boot Order Codes, from https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#BOOT_ORDER
# Try SD first (1), followed by, USB PCIe, NVMe PCIe, USB SoC XHCI then network
BOOT_ORDER=0xf21564

# Set to 0 to prevent bootloader updates from USB/Network boot
# For remote units EEPROM hardware write protection should be used.
ENABLE_SELF_UPDATE=1

 

修改好执行脚本。脚本会从pieeprom.original.bin源文件生成pieeprom.bin和pieeprom.sig两个新的目标文件。

cd recovery
nano boot.conf
./update-pieeprom.sh

将pieeprom.bin和pieeprom.sig两个新的目标文件拷贝到C:\Program Files (x86)\Raspberry Pi\recovery,替换安装包里默认的文件。

 

Setp 4:从recovery更新

短接CM4的Boot到GND后上电,此时CM4就进入了Boot模式。

 

进入C:\Program Files (x86)\Raspberry Pi\recovery,并在此处打开powershell,执行以下指令:

./rpiboot -d recovery

执行结果如下:

PS C:\Program Files (x86)\Raspberry Pi> ./rpiboot -d recovery
RPIBOOT: build-date Dec 16 2022 version 20221215~105525 1afa26c5
Loading: recovery/bootcode4.bin
Waiting for BCM2835/6/7/2711...
Loading: recovery/bootcode4.bin
Sending bootcode.bin
Successful read 4 bytes
Waiting for BCM2835/6/7/2711...
Loading: recovery/bootcode4.bin
Second stage boot server
Loading: recovery/config.txt
File read: config.txt
Loading: recovery/pieeprom.bin
Loading: recovery/pieeprom.bin
Loading: recovery/pieeprom.sig
File read: pieeprom.sig
Loading: recovery/pieeprom.bin
File read: pieeprom.bin
Second stage boot server done

执行完毕后active灯将每隔0.5s闪烁,HDMI输出绿色为升级成功。短闪两下,长闪一下, HDMI输出红色为升级失败。升级失败需要重新来过。

 

参考:

https://www.raspberrypi.com/documentation/computers/compute-module.html#cm4bootloader

https://wiki.seeedstudio.com/Raspberry_pi_CM4_update_eeprom/

https://www.jeffgeerling.com/blog/2022/how-update-raspberry-pi-compute-module-4-bootloader-eeprom