Build armbian with GPT support

With the updated u-boot on SPI, it seems only Guid Partition Table based images are supported in boot, if we want to boot armbian images, either we have to erase SPI or short pin 23, 25 to skip the bootloader on it, but is there way to build own customized latest armbian images in GPT format? There is the building guide using compile.sh script, but I cannot find the instruction on how to configure the GPT image output, while I find one armbian image is with that format:
https://dl.radxa.com/rockpi/images/third-party/Armbian_5.67_Rockpi4b_Debian_stretch_default_4.4.154_desktop_20181210-gpt.img.gz
I thought there should be ways to do that, but anyone can help here?

You can repack a image of armbian with the help of my script

The --uboot-file option takes the MBR armbian image or only radxa ubuntu gpt image?
How to understand the --boot-size option, what does 128, or 512 mean?

Try armbian. It does not matter what type of partition table is on the original image

I set 256 everywhere, on LibreELEC - 512. To save space, you can set 128, but then you need to monitor the place and delete old versions of the kernels if they are updated.

I tried:
make_multiboot_dev.sh --device /dev/mmcblk1 --uboot-file Armbian_20.02.7_Rockpi-4b_buster_current_5.4.28_desktop.img
I got:
Warning: the resulting partition is not properly aligned for best performance: 64s % 2048s != 0s
Ignore/Cancel? Ig


-= All OK =-

When I try:
make_multiboot_dev.sh --device /dev/mmcblk1 --boot-size 256 --image-file Armbian_20.02.7_Rockpi-4b_buster_current_5.4.28_desktop.img
I got:
[Error] This filename from unknown OS !

hm … uname -a ?

p.s. while you can rename file to Armbian.img

I am on Manjaro Arm host system but with kpartx installed, I assume that should fulfill the script pre-conditions?
Changing the img to Armbian.img doesn’t fly as well.

I understand that Manjaro-ARM-kde-rockpi4-19.06 is used? … I will try to test on it when there is time

There is Manjaro 20.04 released actually, while I am currently with 20.02, but will switch to 20.04 soon.
Hope your script will be as general as possible (even consider to support MacOS).

Use a different version of u-boot for SPI and you will get a normal launch of any version of Armbian from any media, including USB and NVMe.

Do you have a link reference to a proven working SPI u-boot version other than the one provided by radxa wiki page?

Armbian

https://forum.armbian.com/topic/12162-single-armbian-image-for-rk-aml-aw/?do=findComment&comment=96341

I flashed the spi image from the provided link (replace the spi image and md5 file in default location, comment out debsum check section in /usr/local/sbin/rockpi4b_write_spi_flash.sh), it seems I still cannot start armbian from usb (I have eMMC installed with manjaro, tf card install with ubuntu 18.04 official image, then flashed armbian 4.4 desktop into a tf card and put it into a usb adaptor plugged into lower USB3 port), when I boot the rockpi4b, it still start from internally installed tf card with ubuntu 18.04 system…

I tried the script under ubuntu, but it still cannot boot armbian, what I did:

sudo su
#---- Make GPT and flash uboot
make_multiboot_dev.sh --device /dev/sdb  --uboot-file Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img
#---- Flash 1 OS
make_multiboot_dev.sh --device /dev/sdb  -i Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img

All finished with -=All OK=-, then I put the microSD card into rockpi, it just doesn’t boot. Any ideas?

There may be problems with the name of the fdt file. Here now new version Test image file

make_multiboot_dev.sh -t  -i Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img

if there is no rk3399-rockpi4b.dtb file among those found, then you need to edit the extlinux.conf file
… you can simply rewrite it again with the new version of the script, it already takes into account this change of file names.

make_multiboot_dev.sh -d /dev/sdb  -n 4  -m 5  -i Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img

-n -m part numbers of the boot and root, compare with yours!

I got below output with the new linked script, still cannot boot from the microSD card, script output:

root@rockpi4:/home/rock# ./make_multiboot_dev.sh --device /dev/sda -u Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img
[Warning] —=== All data on device /dev/sda will be deleted !!! ===—
Type Y/y to continue or Ctrl-C to abort.
y
16+0 records in
16+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 0.0558389 s, 300 MB/s
Warning: The resulting partition is not properly aligned for best performance.
32704+0 records in
32704+0 records out
16744448 bytes (17 MB, 16 MiB) copied, 1.93561 s, 8.7 MB/s
-= All OK =-
-= End Of Script =-
root@rockpi4:/home/rock# ./make_multiboot_dev.sh --device /dev/sda -i Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img

Size of image ROOT partition is 3188 MiB
it flash into partition with size 4096 MiB

Type Y/y to continue or Ctrl-C to abort.
y
Work with partitions …
++++++++++++++++++++++++++++++++++++++++++++++++++++
Attention! If the program does not end with the phrase ‘End Of Script’ then manually do ‘umount /tmp/{1…4}’, ‘rmdir /tmp/{1…4}’
and remove partions: /dev/sda4 /dev/sda5
++++++++++++++++++++++++++++++++++++++++++++++++++++
Files are copied, wait …
---------/boot/*Env.txt :
verbosity=1
overlay_prefix=rockchip
rootdev=UUID=b949b043-f2d0-46ad-9616-0820b739a0f4
rootfstype=ext4
---------found RockPi4 fdt files :
/dtb-4.4.213-rockchip64/rockchip/rk3399-rockpi4b.dtb
/dtb-4.4.213-rockchip64/rockchip/rk3399-rock-pi-4.dtb
--------- extlinux.conf :
LABEL Armbian
LINUX /Image
INITRD /uInitrd
FDT /dtb/rockchip/rk3399-rockpi4b.dtb
APPEND root=UUID=25d39b65-af2d-4baa-8958-b628107dc414 rootflags=data=writeback rw console=uart8250,mmio32,0xff1a0000 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0
---------- /etc/fstab :
UUID=25d39b65-af2d-4baa-8958-b628107dc414 / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,nosuid 0 0
UUID=ca700fc3-5901-47bf-af21-26982b68caa4 /boot ext2 defaults 0 0

loop deleted : /dev/loop0
-= All OK =-
-= End Of Script =-

It seems to be Armbian image uboot issue, below command will result in a not bootable microSD:

./make_multiboot_dev.sh --device /dev/sda -u Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img
./make_multiboot_dev.sh --device /dev/sda -i Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img

While radxa stock ubuntu image uboot using below command will result in a bootable armbian microSD:

./make_multiboot_dev.sh --device /dev/sda -u rockpi4b-ubuntu-bionic-minimal-20191127_1942-gpt.img
./make_multiboot_dev.sh --device /dev/sda -i Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img

So it looks I cannot get a uboot to make booting from USB possible (neither modified SPI from @balbes-150, nor writing Armbian image uboot (providing boot from USB support) into microSD using script from @rua1 ), but so far with radxa SPI (with NVME support) uboot + script from @rua1, at least I can boot Armbian from microSD, and the script goes well to get multi boot setup (I tried Armbian + Manjaro) work, and toggling system by using gparted setting boot flag on right boot partition is quite convenient.

I only tested a short time spi uboot and thought that when it is used, the uboot recorded on the microsd does not matter. I was wrong.
To replace uboot no need replale all . To work only with uboot area there are options --backup-uboot, --write-uboot and --zeroing-uboot

 ./make_multiboot_dev.sh --device /dev/sda  -u rockpi4b-ubuntu-bionic-minimal-20191127_1942-gpt.img --write-uboot

and only uboot replaced

Is below command actually creating still MBR partition table by using Armbian image as uboot input?

./make_multiboot_dev.sh --device /dev/sda -u Armbian_20.02.11_Rockpi-4b_bionic_legacy_4.4.213_desktop.img

Or we can say Armbian uboot is not working together with SPI uboot from radxa, we have to use radxa ubuntu uboot to boot Armbian if SPI uboot from radxa is present?

new gpt create … warning is displayed “[Warning] —=== All data on device /dev/sda will be deleted !!! ===—”

You can still test --zeroing-uboot

./make_multiboot_dev.sh --device /dev/sda   --zeroing-uboot

then only will work spi uboot