BPI-R4 U-Boot BananaPi FreeBSD pkg

Good Afternoon, :grinning:

I am trying to build a OPNSense image for the BPI-R4 and have made some headway, I’m running into issues regarding booting due to u-boot not being found/recognized correctly. Can someone please confirm for me if the “u-boot-bananapi” pkg in FreeBSD is the correct one I should be using, and if not could someone point me in the correct direction for a compatible u-boot image I can use either in the creation itself or somehow inject into the opnsense.img I have compiled

Kind Regards

I’m nearly sure freebsd does not support r4 yet. Uboot patches are mainline,but you need to set the right dts and drivers for a specific board. It is not like linux where you can compile all in and hw can be detected…

Thank you for the heads up, from what I understand the CPU should be compatible I am just having issues trying to get u-boot integrated in the build in the correct location. Could you point me in the correct location regarding getting it setup?

Uboot needs to be packed into vendor specific atf and called by bl2 which needs to be compiled with specific options

You can see details of compiling and image creation in my atf build.sh

Just out of curiosity could either your build script or one of the prebuilt images be able to be injected into an existing img written to a SD card? i.e [“bpi-r4_sdmmc_bl2.img” + “u-boot-r4_2024.01-bpi-arm64-sd.bin” + “OPNSense.img”] Or would I have to try incorporate adding them to the makefile for the opnsense image I build myself?

Basicly you could use bpi-r4_sdmmc.img.gz as base if my uboot already includes all necessary for freebsd

By following the instructions you’ve written here? building and flash image Is it possible to do something similar from a windows host (i.e windows subsysytem for linux) or does it need to be done using a linux machine? (sorry for all the questions, I’m new to dealing with uboot and its causing me headaches)

Cause right now I’ve got a EFI bootable Aarch64 opnsense img, which when written to a sd card it creates a partition called MSDOSBOOT with a bootaa64.efi in it

I have not used WSL yet so i cannot answer this,but at least i think flashing directly in windows should work if you unpack the gz first.

For boot process you need at least bl2.img at offset 0 and then the fip needs to be flashed in a gpt partition named “fip” all other parts are optional.

Thanks for the information, I’ve tried both native windows and WSL and no luck, I can flash the bl2.img and fip fine but naming the partition has been causing me issues, I know it works cause when I plug it into the bpi4 it boots then cant find the fip partition. I don’t suppose you have an idiots guide on how to do it in either Ubuntu or FreeBSD?

Okay I’ve tried for a few days now and I am not making any progress, when running the following code below from a Ubuntu box I get the generic system halt error on the bpi4

sudo sgdisk -o /dev/sdb
sudo sgdisk -a 1 -n 1:34:17424 -A 1:set:2 -t 1:8300 -c 1:"bl2" /dev/sdb
sudo sgdisk -a 1 -n 2:17425:35840 -A 2:set:63	-t 2:8300 -c 2:"fip" /dev/sdb
sudo sgdisk -a 1024 -n 3:35841:${bootend}	-t 3:8300 -c 3:"boot" /dev/sdb

sudo dd if=bpi-r4_sdmmc_bl2.img of=/dev/sdb1 conv=notrunc,fsync #1> /dev/null 2>&1
sudo dd if=bpi-r4_sdmmc_fip.bin of=/dev/sdb2 conv=notrunc,fsync #1> /dev/null 2>&1
sudo dd if=OPNsense-202402200813-arm-aarch64-bananapi4.img of=/dev/sdb3 conv=notrunc,fsync #1> /dev/null 2>&1


Am I missing something or doing something wrong?

Based on output bl2 is not found. The output is only bootrom.

So either the bootswitches are wrong (both down for sd),card is not recognized (inserted correctly,maybe unsupported/damaged card) or flashed bl2 is wring file (without sdmmc_boot header) or on wrong position (emmc needs different bl2 in boot0 part).

So do you believe the logic and the commands I’m running are correct and its just the bl2 file that is the problem?

Have you taken bl2 file from my repo or self compiled?

You could try flashing the bpi-r4_sdmmc.img (unpack of gz needed) to card to check the bootswitches and card support. Then you can change partitions after fip for your needs.

Thanks for the heads up regarding bpi-r4_sdmmc.img, I originally took the bl2 file from your repo

I can confirm it boots successfully using the bpi-r4_sdmmc.img image so the SD card works, however I’ve had no luck getting anything booted when flashing to partition 6 using dd image

Kernel (default bpi-r4.itb) has to be on p5…this is loaded by my uboot before accessing the rootfs on p6

So it will be possible to run opnsense or pfsense on bpi r4?

pfSense will be harder as one of the package maintainers recently reported that the pfSense team has taken some source code into a private repository which means building pfSense CE (the open source version) isn’t currently possible. I don’t know if this situation will change.

I’m actively trying to get OPNSense running but as you can see I’m hitting some walls :smiley:

Do you have a prebuilt pbi-r4.itb kernel on any of your git repo’s? If not is there a way to build one?

I have no pipeline yet which builds for r4 yet,but you can use some branches to build it like 6.8-dango (which is newest one and already configured for r4 in build.conf).

Just use build.sh with importconfig param and without to build,pack to get a tar.gz with all needed binaries