OrangePi Zero2w

0x00 又闲了

前几天闲着没事,买了个OrangePi Zero2w玩。虽然性能一般般,但胜在便宜。

⚠买来才发现Linux下没有GPU驱动,视频都看不利索。想硬解视频必须得用Android。

因为板子需要TF卡启动,到手以后又着急想玩,于是跑到家附近的DAISO随便买了一张TF卡,32G,550日元。

结果没玩两天卡就坏了,本来想试着修修,结果插电脑上没任何反应,白瞎550。当时手头没有其他SD卡了,但是有个性能很强的U盘,于是就想要不用它试试?

看了一遍官方文档,没有提及能否从USB引导。用balenaEtcher写了个系统到U盘,插上开机,也确实没能启动,直接进到了板载NOR的迷你Linux里。

✳后来去秋叶原,闪迪64G的High Endurance才550,感觉自己更2B了。

0x01 换个思路 (Thinking out of the box)

TF卡的可靠性还是不太行,既然板子上有一块16M的NOR FLASH,不然用它装个u-boot从USB引导试试?

Since TF card is so unstable, what if I put a uboot on the NOR FLASH, and boot from there?

1. 修改系统配置 (Edit system config)

想读写这个NOR FLASH,首先还是得从TF启动一个Linux系统,从这个系统里修改硬件配置才可以。

Before r/w that NOR, you first need to boot a Linux system from the TF card, and then modify the hardware configuration from that system using "orangepi-config".

1
orangepi-config → System → Hardward

激活spi0-spidev 重启

Enable spi0-spidev and reboot.

config

重启完成后,手动确认spi设备是否存在。

After reboot, check if spi device exist.

1
ls /dev #查看是否有/dev/spidev0.0

2. 获取u-boot (Get u-boot)

查看uboot文件是否已经存在,存在时会输出以下结果

Check if uboot file exist.

1
2
3
4
5
6
apt search linux-u-boot-orangepizero2w-next

Sorting... Done
Full Text Search... Done
linux-u-boot-orangepizero2w-next/now 1.0.4 arm64 [installed,local]
Uboot loader 2024.01

如果不存在的话,需要执行

If not, run

1
apt install linux-u-boot-orangepizero2w-next

安装完成后,执行。应该会存在一个u-boot-sunxi-with-spl.bin文件。

After installation, check if u-boot-sunxi-with-spl.bin file exist.

1
2
3
ls -l /usr/lib/linux-u-boot-next-orangepizero2w_1.0.4_arm64/

-rw-rw-r-- 1 root root 832621 Oct 9 05:38 u-boot-sunxi-with-spl.bin

3. 制作u-boot启动镜像 (Create u-boot image)

创建一个空文件夹,用于存放接下来需要用到的文件

Create a empty folder, for next steps.

1
mkdir /home/orangepi/uboot

执行以下命令 Run the following

1
2
3
4
cd /home/orangepi/uboot #切换至刚刚创建的目录
dd if=/dev/zero count=16384 bs=1K | tr '\000' '\377' > uboot.img #因为Zero2W的NOR FLASH是16MB大小,所以创建一个16MB的全0xFF空白文件,用于后期写入
dd if=/usr/lib/linux-u-boot-next-orangepizero2w_1.0.4_arm64/u-boot-sunxi-with-spl.bin of=uboot.img bs=1k conv=notrunc #将u-boot-sunxi-with-spl.bin文件写入uboot.img
flashrom -p linux_spi:dev=/dev/spidev0.0 -w uboot.img #将uboot.img写入NOR FLASH

顺利写入完成后会出现Verifying flash... VERIFIED.

4. 测试 (Test)

将OrangePi关机,拔掉TF卡,用balenaEtcher将系统镜像写入U盘,把U盘插到Zero2w上开机。

Shut down the OrangePi, remove the TF card, use balenaEtcher to make a bootable usb device, then plug the USB drive into the Zero2w and boot it up.