BPI-R3 u-boot build help (with NVMe support, hopefully)

Hi all,

My setup currently loads uboot and the kernel from the sd-card (or eMMC, usb) and the kernel modules and the rest of the rootfs from the nvme. I would prefer to have just uboot on the sd-card. For me this makes more sense because I like to keep my kernel/fs fairly updated whereas I don’t feel the same about u-boot.

A more important issue though is about backup/restore and failures where you have a clear separation between uboot and the rest, which is not true if the kernel is on one drive (sd) and the kernel modules (and rootfs) are in a different place (nvme).

I think having nvme support in uboot would definitely make the bpi-r3 platform more reliable and maintainable as it would be more modular, but I admit my issues are mostly quality-of-life related.

Thanks @ericwoud for your suggestion. I don’t immediately see the benefits of using kexec in my situation (because it introduces another layer of complexity and a secondary kernel to keep track of) but I’m sure people with different requirements will find it usefull (e.g. sd-card wear and tear related concerns)

So, I am assuming PCIE and NVME u-boot support is still not coming for the BPI-R3. A bit of a shame really…

@ericwoud, do you have a repo link, and/or can you provide some instructions on how to set up the kexec chainloading setup you mentioned? I would be willing to give that a try.

I am quite fed up with having my kernel and rootfs (i.e kernel modules) on separate storage devices. Makes restoring the system from backups a real pain.

I tried, but it did not work. I have not looked into why not…

Good news, at first glance, it does work! Still need a lot of testing, but looks promising.

OpenWrt just announced this for their birthday:

We will use M.2 with M-key for NVMe storage. There is a work-in-progress patch to make PCIe work inside the U-Boot bootloader. This will allow booting other Linux distributions such as Debian and Alpine directly from NVMe.

If I understand that correctly, that would benefit every board using U-Boot?

I know that there is some work on mt7986 pcie support,but currently there are problems on recognizing nvme. Each soc needs a matching driver for pcie so this is a board specific feature

@meehien

This will be the way to install my archlinuxarm image to have it chainloading. I still have to add the code to the initrd, but I need a few days to develop/test this part.

Setup booting from NVME on R3/R3mini/R4, using chain-loading kernel on emmc fip partition

But anyway, good news that u-boot pcie support is coming for the R3 also.

Wow, these are some nice updates. Thanks @ericwoud for setting up the tutorial. I am also a big fan of Archlinux so this is quite fortuitous. Definitely saves me a lot of time migrating things.

@ericwoud , @frank-w. If/when the u-boot driver becomes available would you mind posting a message here? I have been checking the commit history @GitHub - frank-w/u-boot: U-Boot-Bootloader for BananaPI-R2/R64/R2Pro/R3 regularly (hoping for a stealthy pcie driver update), but some commits are quite large and difficult to follow.

So anyway, the kexec experiment stranded at pcie not initializing correctly. Although a have a custom ‘hack’ / feature in mind of arm trusted firmware, to do something similar as kexec. But more of a proof of concept and for my own use and anyone interested

Best way, indeed wait for pcie uboot support.

In case, porting GitHub - open-power/petitboot would be very nice.

got info from john, bug seems fixed and he will cleanup the pcie patch and send it soon to upstream uboot

So I have the atf based ‘kexec’ functional. Can now boot with bootfiles on nvme, without using u-boot. But this is an experimental proof of concept.

Still easier to use u-boot with pcie support though…

Hi @ericwoud. I had a look at your guide and I’d like to try the “2. ATF - KERNEL using boot partition.” boot method. However I do have three questions before I start and mess up my system.

  1. All the code references in https://github.com/ericwoud/buildR64arch/blob/main/README.md#setup-booting-from-nvme-on-r3r3minir4-using-boot-partition-on-emmc refer to the r64. I have a bpi-r3, do I have to change anything, or the r64 and the r3 have the same codebase/configs?
  2. I would like to attempt this first on a sd-card. I feel like that is easier to swap-in/out while I test out things. Do you think your guide will work with that? (I plan to run the commands manually first to figure out what happens, and can swap emmc references with the sd-card).
  3. I am building my own kernel and would like to keep using that if possible. Do I need any specific config enabled in the kernel to support the ATF - KERNEL method or your method will work with any kernel itb image (assuming things are configured correctly)?

Hi Meehien,

I will answer your question here:

Would it be possible to write step by step instructions for us simple users? Please… I would like to try this. Thanks!

i’m about to add this patch and the config-options to my uboot-repo (2024-01-bpi) tree…already cleaned it in my r3mini test-branch.

edit: added…when pipeline finished you can update uboot (at least on my images) with the built one

@frank-w you might also add something along the lines of the patch attached in the uEnv_r3. u3dev.patch (1.5 KB)

Also, going a bit off-topic here, but I think the NOR memory would be perfect for this. I have been trying to follow your tutorial at en:bpi-r3:uboot [FW-WEB Wiki] but can’t seem to get a bootable NOR setup. Do you think I need to change anything from the linked tutorial, or it should work as is?

If i not miss anything it should work as such,make sure you use the bl2.img to have the bootrom header. What happens when you try to boot nor? Make sure all bootswitches are right.

And you have to erase the parts written later.

Why have you changed useinitrd in your patch? It then misses the “root=/dev/ram rw”