Jump to content

U-boot 'partition 0' + FAT partition 1 + Btrfs partition 2 (+ reserved partition 3) + swap partition 4


Recommended Posts

Posted

As listed in the topic, this is my desired and actual partition table setup for a lot of my computers. The U-boot 'partition 0' is typically somewhere in sector 1 till where partition 1 starts and only for SoCs/boards that do not understand any filesystem, like Allwinner and Rockchip based platforms. Also old BIOS PCs actually. It can be MBR or GPT (+hybrid) if more than 4 partitions are needed, for multi-boot, like adding Linux to a new Win11 pre-installed PC. The FAT is ESP or just type 0x0c/0x0700.

 

Now I am struggling a bit with the case where a preinstalled ROCK 3A (RK3568, board ordered, not delivered yet) image has FAT mounted in /boot. RaspberryPi and UEFI PC have 1st FAT mounted on /boot/firmware and /boot/efi usually. For fast and easy multi-kernel management, I want to have the kernel file/image to be there as vmlinuz-<version> on Btrfs as master/base and not as file "Image" on the FAT.

 

For my NanoPi-R6C (RK3588s) I made and extra multi-OS capable script that copies files from Btrfs to FAT as I see no way the default Armbian methods can handle this correctly. Maybe I miss some info, but I needed to fix bootup several times as something related to boot.cmd and/or armbianEnv.txt was not correct. To not risk any actions from existing tools (on any OS) I use /boot/uboot to mount the FAT partition 1. I also have /boot/tftp and /boot/vfat, for other purposes and workarounds, but that is another story.

 

By having an own hook script for dracut and/or initramfs, I could leave the out-of-the box FriendlyElec Android/OpenWRT u-boot loader (2017.x) in the first 32k sectors as is, without knowing much about Rockchip ROM loader and offsets etc. AFAIK, the default 24.10 U-boot config is to not have Btrfs included, so I kept it like this so far. I have build own U-boot with Btrfs, removed the FAT and made Btrfs partition 1 as test for 64-bit QEMU imagefile and 32-bit AllwinnerH3 SD-card. So then the symlinks for kernel, uInitrd, DTB are used without any further changes in Armbian scripts or so.

However, that same OS image (whole SD-card or as image file) does not boot in a VM then (virt-manager, EFI needed). I normally add grub-efi etc so there is a /boot/efi/EFI/... to do a default UEFI boot with the same mainline based rockchip-rk3588 kernel. That is really great option to do some initial config and so on before writing SD-card (and going outside where the real board is / will be).

 

So the question is now: How can I keep the desired partitioning scheme and filesystem formatting, but get rid of my own initramfs hook and double/extra boot.cmd ?

 

My current own script (pseudo-code) does not use optional moves but always copies (see /etc/initramfs/post-update.d/99-uboot for original):

# $1 is kernelversion string

echo "update-initramfs: U-boot: copy DTBs to boot partition" >&2
rsync -ac /usr/lib/linux-image-$1/ /boot/uboot/dtb/

echo "update-initramfs: U-boot: copy kernel to boot partition" >&2
rsync -ac /boot/vmlinuz-$1 /boot/uboot/Image

echo "update-initramfs: U-boot: copy uInitrd to boot partition" >&2
cp -a /boot/uInitrd-$1 /boot/uboot/uInitrd

echo "update-initramfs: U-boot: done." >&2


U-boot by default does not scan all disks AFAIK, it only wants/sees boot.scr on partition 1. An workaround is to place the FAT after the rootfs, so partition number 2-128 (or 2-4 in case MBR). That works for UEFI based, but not for RaspberryPi3 and older. For RPi4 I am not sure.

 

<
Posted

Indeed not really a tutorial. Also ROCK 3A has SPI, which is a not the case for my BananaPi M1, NanoPi-NEO, NanoPi-R6C. I'll see what that brings.

But the issue is generic Armbian, personally for me like 2+ years or so that I am trying to figure out the best way of working.

For my 5x NanoPi-NEO I have simply cloned the first part of the SD-card long time ago, split/resized the root Ext4 into bootfs (Ext4) and rootfs (Btrfs), so standard Armbian/Debian kept working. I also tested with an EFI+GRUB layer (openSUSE) which then offers easy multi-kernel at boot via grub serial console, but I did not figure out how to enable S/P DIF and 1-wire and other GPIO's there.

Posted

I did some experimenting, looking mainly for a kernelversion selection and u-boot serial console. Is with Radxa Rock3a where I put and Armbian default U-boot 2024.10 version in de SPI-flash. Then stop at autoboot and run 'bootflow scan':

 

=> bootflow list
Showing all bootflows
Seq  Method       State   Uclass    Part  Name                      Filename
---  -----------  ------  --------  ----  ------------------------  ----------------
  0  efi_mgr      ready   (none)       0  <NULL>
  1  extlinux     ready   mmc          1  mmc@fe2b0000.bootdev.part /extlinux/extlinux.conf
  2  script       ready   mmc          1  mmc@fe2b0000.bootdev.part /boot.scr
  3  efi          ready   mmc          1  mmc@fe2b0000.bootdev.part /EFI/BOOT/BOOTAA64.EFI
  4  pxe          ready   ethernet     0  ethernet@fe010000.bootdev extlinux/extlinux.conf
---  -----------  ------  --------  ----  ------------------------  ----------------

This is SD-card inserted and also a big SATA HDD is connected. That HDD could be the sole local storage, but currently only for data. (It shows a Uclass scsi when a boot.scr is found).

 

The extlinux I remembered from long time ago and seems a good option for what I want I think. I can rather easily script it a bit I think.

The pxe also work and is best if it is difficult to remove storage when kernel crash; then just powercycle select pxe with known good kernel from NAS/TFTPboot

The efi is grub based, has some hicup on Rock3a, maybe due to Noble, I have it working OK with Bookworm on NanoPi-R6C. But overlays is an issue I think.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines