BPI-R4 U-Boot BananaPi FreeBSD pkg

Good news, I got the kernel built and it seems to work correctly. Bad news is it still can’t boot the OS I’m trying to flash

I believe it is cause it is only trying ext4 filesystems and both OPNSense and FreeBSD use the freebsd-ufs file system. Is there a way to change which file system the kernel tries to use or can I somehow convert the freebsd-ufs to ext4 would you know?

1 Like

You flash an bsd image to p5 of mmc? Is it only a partition image and no diskimage with additional partitions (maybe you need to extract rootfs first)? And as you have compiled kernel by yourself you can maybe add support for this filesystem. And maybe you have to override root in uboot environment in uEnv.txt (root of p5) to not contain fstype which i have set to ext4

Can indeed boot without this option, it will be detected automatically., as long as, like @frank-w mentioned, the filesystem is supported (as buildin, not module).

Having modified that file and removing the section you highlighted it has tried more file systems however it still doesn’t seem to want to boot

I fear the filesystem being freebsd-ufs is something else i.e dos related and thats why it is failing to go further.

Have you added:

CONFIG_UFS_FS=y

To the .config before you build the kernel?

Edit:

It would seem it isn’t added, as it is not in the list of filesystems.

Removing this from my source needs complete compile of uboot+atf and reflash…thats why i guggested adding this line to your own uEnv.txt without fstype.

You can check in uboot cli with printenv if it is applied (it is loaded before bootmenu is shown so just select exit and run “printenv root”,you can also use setenv to set this var to your desired value.

But please check if p6 is really the filesystem you think and no disk (with own partitiontable) inside partition :stuck_out_tongue:

I’m not sure linux mainline support this bsd specific filesystem

Which kernel is being used here? Does freebsd run on a Linux kernel?

The SD Card is flashed using bpi-r4_sdmmc.img from Frank’s git repo here, I then in a Ubuntu box build the kernel from here and copy it to partition 5 BPI-BOOT then using dd

I flash an OPNSense image I built using their aarch tools from here

Adding the below to the kernel config and rebuilding has changed the list of bdev filesystems in the previous error to now show ufs but I’m still not able to go further

image

I’m also not 100% sure how to check this

as everytime I try mount the partition it gives a bad fs type/superblock error and refuses to mount. I’ve even go as far as trying to mount the base FreeBSD aarch image FreeBSD-13.2-RELEASE-arm64-aarch64-memstick.img but am unable to get that to work. Can I use dd to flash a iso to a partition?

Yea I’m def not able to see anything in partition 6

image

What if you just format it? If that works, then copy the files over …

But does freebsd run on a Linux kernel?

I can format it in a way I want however I can’t get the files out of the OPNsense or FreeBSD images as everytime I try mount the images I get this error

Which is why I’m trying to flash those images to the sd card on partition 6 and figure out how to boot it, I believe it runs on a dos based system (just from what I can figure out re: partition types)

You cannot mount an image directly and a disk image contains partition table which is invalid if flashed to an partition

For image mounting you can use losetup and partprobe (to scan for partitions in loopdev).

This is probably a disk image, with several partitions.

Did you try something like:

losetup -P -f --show my.img

So first need to find out how to access, then figure out how to access at boot…

Edit:

You should first look into this… It doesn’t look like this is possible. This means you need to port all the drivers to the freebsd kernel…

So I finally figured out how to access the UFS filesystem in the OPNSense img

And was able to copy all the files to partition 6 which allowed me to progress further as it actually “tried” to boot, however its still boot looping

The FreeBSD kernel is a completely different beast to the Linux kernel. It has nothing whatsoever to do with Linux.

Indeed, that is why I am asking the question. This is where this project gets stuck…

I think I need to figure out how to get the kernel that I’ve had to manually build using franks BPI-Router-Linux Git Repo to boot BSD instead of hardcoding booting linux or figure out how to build a bsd kernel for the bpi4 from scratch…

The kernel IS linux :slight_smile: if freebsd userspace cannot work with it you will have no luck

There are no drivers for the mediatek hardware in freebsd, other than the mt76 wifi driver. All the drivers for the SOC are not there… They all need to be ported to bsd kernel. That is not an easy job at all.

So I found out its possible to boot FreeBSD using Grub, so I’m now trying to figure out how to add it to the Ubuntu image I’ve got built at the moment