Banana PI - Network Boot

Hi guys,

I am quite new to Banana PIs but have a lot of experience with Raspberries. Reason why I have obtained a Banana PI is the fact that it provides boards with multiple LAN ports. With the R2 I am planning to replace my Router with an OpenWrt one. The fact that the PI provides 4 LAN ports is even better as I have currently 3 different subnets which I can separate physically also.

Besides the fact that I need to learn how those boards are being fed with software there is one point for which I have not found an answer so far: is it possible to configure the Banana PI to boot from a NFS network mount? All my Raspberries are set up to boot from different folders on a NAS system and I like the fact that I do not need to bother about SD card issues and also the backup/restore is quite easy. How to achieve same/similar setup with a Banana PI and OpenWrt?

Thanks for the help!

Bye

Hello & Welcome to the community,

I see that you have many question but we need to look into it one by one. From my experience with BPI, I dont think there is any way to boot from network

Regarding flashing software to the device it is pretty straight forward, Just to flash it to the sd card or eMMC using the img file from the official Wiki page.

http://wiki.banana-pi.org/Banana_Pi_BPI-R2

1 Like

Hi, you need at least preloader+uboot on local storage (sd/emmc),then you can load linux-kernel (tftp) and rootfs (nfs) via network.on sdcard you need additional bootheaders (sdmmc-boot+brlyt).you can try flashing my debian for first steps (loading kernel from tftp and then rootfs)

I had wrote down my steps quick and dirty in my wiki.

https://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:netboot

My kernel and uboot are prepared for netboot because i often use tftp to load kernel. i tested Rootfs on nfs some time ago but mostly use rootfs on sd

2 Likes

Hi guys,

thank you very much for your answers. I have successfully installed an OpenWrt image on my SD card and can boot the bpir2.

The next step to take is either

  1. move rootfs to nfs share (preferred)
  2. move rootfs to EMMC

For both options I do not have an idea yet how to proceed.

@frank-w: great that there is a way to make the bpi boot from nfs, question is only if I can achieve that also with the OpenWrt image I am currently using. Any ideas from your side?

For the second option, is it possible to “move” the current rootfs content to EMMC and mount this as rootfs upon boot? Or is it not the way the boot process is working on bpi? On an raspberry this is basically what happens: on a boot partition you are configuring (via config.txt) where the rootfs should be loaded from. This is very easy, but I guess not the way bpi works…

Any hints on which option to choose and where to find information about how to do it are very much appreciated!

Thanks!

Bye

For openwrt i have no idea because i don’t use it.

but in debian/ubuntu it’s default to use rootfs from sd/emmc. This is also my current way for testing kernels (kernel/dtb from tftp and local rootfs). You install image the normal way and only change kernel-source in uboot (leave root/bootargs as it is root=/dev/mmcblkxpy to inform kernel where the rootfs is located)

Or you copy rootfs from sd to emmc (rsync) skipping dynamic folders like /proc, /sys,/dev and change fstab to new rootfs-device

Something like this after mounting new rootfs to /mnt/emmc-root):

rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/boot/*"} / /mnt/emmc-root/

Hi Frank,

that was a quick answer :slight_smile:

I have found some examples of how uboot can be configured for nfsroot:

https://wm-help.net/lib/b/book/1434608941/243

but it seems for all these techniques I need access via serial console, is that right? I know that the bootargs-line shown in those examples is similar to the config.txt on a raspberry pi. But as there is no config.txt on bpi I guess only direct access via console will work here. Or are there any linux utilities that allow to change the bootargs from bash?

Thanks!

Bye

uenv.txt is right for uboot, here you can change bootargs (or only root)

it’s better using serial console to see whats going on…but basicly you can edit the file located on boot-partition in linux userspace

in my uboot there is nfs prepared:

simply change these 2 vars and “run bootnet”,this asks for kernel to load from tftp

Hi Frank,

sorry for the late answer, was busy…

I have now setup my bpi-r2 with openwrt 18.06.2 and the configuration seems to work fine. One thing left is to move the rootfs now to NFS or EMMC. Which way should I go here in your opinion? I guess moving it to EMMC will be easier, but I am not sure… I have seen several posts on Google how to transfer rootfs to EMMC but to be hones I am a little bit afraid of blowing everything… What is the simplest way to achieve the moving?

Thank you very much for your help so far!

Bye

for normal linux you can mount it and copy it with above rsync-command. I don’t know if this works for openwrt too…

what about telling the boot loader to consider the rootfs from emmc? Or is it automatically checking on that device, too?

I think you also want to load preloader/uboot from emmc…there you have to say where it should search for kernel and rootfs

Hi Frank,

with the help of some users in the OpenWRT forum I have setup my BPI to boot from NFS successfully. The current configuration loads the kernel from SD and the root file system from the nfs share. This is a setup I can live with. Thank you for your help!

Bye

Can you describe how you have created the openwrt rootfs and how you have configured r2?

Hi Frank,

I have activated nfs root kernel option via “make menuconfig”. Additionally I had to “hardcode” the boot parameters in the kernel itself, it was somehow not working by altering the uEnv.txt:

root=/dev/nfs nfsroot=192.168.XX.XX:/volume1/XXX/XXX,tcp,vers=3 ip=192.168.XX.XX:192.168.XX.X:192.168.XX.X:255.255.255.0:test:lan0:off

the above line needs to replace the “root”-statement in the default kernel boot args. After compiling it I have moved the kernel (7623n-bananapi-bpi-r2-kernel.bin => uImage) to SD card and the root fs to my NFS share.

Today I will check why the kernel args in uEnv.txt are not considered. If I will find out anything useful I will post it here.

Bye

1 Like

Linux kernel has option to use builtin cmdline or the one passed from bootloader. Maybe second is switched off.

How did you created your rootfs with openwrt (or is this selectable from openwrt menuconfig)?

Hi Frank,

yes, it seems to be somehow related to the kernel config, I am trying to figure out which option is the correct one…

Yes, there is an option to create rootfs as archive in menuconfig.

Bye

Maybe CMDLINE_FORCE is set (!=n)

Hi Frank,

with the following kernel boot options the “bootargs” are passed to the kernel:

Hope that helps!

Bye

Mhm,looks goos so far…strange that uboots arguments are not used…i expect error is in uboot config

With the config above uboot args are used. The missing option seems to be the “appended device tree” and its sub elements.

Bye