My script for installing Armbian 5.67 into Phicomm N1

Modified from the original script from Armbian 5.67, credits to them.

It seems that u-boot on Phicomm N1 hardcoded 0x27400000 for reading / storing its environment variables, and is overwritten with default values even when it’s invalid (from u-boot’s parser’s perspective).

Previously it looks like to me that everything after 128M on /dev/mmcblk1 may be overwritten, and now it turns out it’s not. Even if the system boots, data in range [0x27400000, 0x27400000 + 0x800000) might get corrupted by u-boot at any time.

The script works around this by marking sectors used by u-boot for environment variables as bad sectors, preventing them from being used by Linux.

Undoubtedly it would be better if I could change the offset in bootloader to somewhere near the begining, but that would be hard as the bootloader seems to be signed with RSA 2048 (“R2048 check pass”):

Update: This seems not to be the case, as a script here reflashes the u-boot with a seemingly custom one (presumbly compiled by the author?), which I think is not signed by Phicomm. Or Phicomm/Amlogic just published the signature key so that anybody can sign their u-boot binary?

This script is also capable of replacing boot logo (splash) of Phicomm N1. It will write /boot/n1-logo.img to appropriate position on /dev/mmcblk1 and mark those sectors as bad as well, if /boot/n1-logo.img exists. But note that /boot/n1-logo.img may not be greater than 8M, or you will need to modify the script yourself.

As for how to build a customized n1-boot.img, check this.

If you’re interested, I’m using this image as my boot splash. Credits to the creator(s).

The first 100M is used by bootloader and reserved partition. The reserved partition actually contains a (not-used-by-us) partition table, as well as DTB, which is critical for booting the system, and thus cannot be overwritten. (Yes I did tried to overwrite reserved partition, even if I said I was not gonna to do this, and successfully bricked my N1 box.)

1 thought on “My script for installing Armbian 5.67 into Phicomm N1”

Leave a Reply

Your email address will not be published. Required fields are marked *