FreeBSD SPI: how to make kernel and rootfs for flashing?

Hello,

I have a ready-to-use U-boot, and now I want to replicate the Linux steps of cooking kernel and rootfs images for aarch64 FreeBSD. My goal is to flash them to a 16-Mbyte SPI Flash chip.

1) Firstly, would a generic aarch64 FreeBSD release be capable of booting from SPI?
2) Kernel image is usually made of 3 ingredients: "Image.gz", dts and fit-image.its by running "mkimage -f fit-image.its kernel.itb". Then kernel.itb is is written to SPI Flash memory. What is the FreeBSD way for this?
3) How should I get a really tiny rootfs, but with networking and usb support?
 
The best what I could figure out myself atm is to follow the guide to perform compilation of the full aarch64 release with "sudo sh -x release.sh -c arm64/ROCK64.conf". AFAIK, this is going to build a lot more stuff than I need. The hope is that I could re-use the product of some immediate step.
 
AFAIK, this is going to build a lot more stuff than I need.
See src.conf(5). But be warned, there's no check in advance, so the only way to find out you removed something another part depends on is by the build failing somewhere halfway.
 
Interesting, thank you.

To what extent the standalone kernel is usable itsef? I understand that FreeBSD kernel is very much stripped down, by design. But would just the kernel without ports drop me into a functional shell prompt? If yes, I would prefer to get into the target system first, and then use it to compile the ports, should I require any.
 
> Not very useful at all. How are you supposed to run anything?

With a microkernel it could be a problem indeed. However, freebsd-based embedded products such as routers do exist, therefore there must be an approach to couple the freebsd kernel with just e.g. busybox. This is what I'm looking for.

> I think you're not quite understanding what a kernel is and what it does.

Yes, my expectations are biased by Linux, where it is enough to couple the kernel with just a small initrd image, in order to get to a minimally functional command line. What would you recommend to me?
 
However, freebsd-based embedded products such as routers do exist, therefore there must be an approach to couple the freebsd kernel with just e.g. busybox. This is what I'm looking for.
If you add busybox (or something similar) it's not "only" a kernel anymore.

Yes, my expectations are biased by Linux, where it is enough to couple the kernel with just a small initrd image, in order to get to a minimally functional command line.
The initrd image contains more than "only" a kernel.

But I think I understand what you're looking for, you may want to have a look at mfsbsd for example. There's also nanobsd(8).
 
This thread has much good info.

By my approximation it would take an 128MB SPI to run a stripped down FreeBSD base and kernel with FreeBSD 12.
 
FreeBSD's commandline utilities are much slimmer than the GNU versions. The need for special linking and packaging is less than for Linux. As an additional benefit you get the full functionality, unlike busybox.
 
By my approximation it would take an 128MB SPI to run a stripped down FreeBSD base and kernel with FreeBSD 12.
My target is 32 Mbytes SPI, at most. In order to really push to a minimum, I can give up most of the things, in fact it's enough to have just ramdisk, shell, usb and usb serial support.
 
U-boot, EFI will fit. Kernel might not fit (even massively slimmed down) in 32MB.
I can check but 35-40MB was my absolute minimal /kernel build if I remember.
Good Luck it will take some hair pulling.
Fast storage and many cores will help trial and error.
 
I have some MINIMAL kernels from 1.5 years ago -current. The actual kernel file is 11 MB. But I was never able to boot it after putting the drivers in that I need.
 
The actual kernel file is 11 MB.
Thank you, this is the size I would expect.

I would definitely succeed in building some versions. What I'm missing is rather a recipe to get them tested. I'm not going to have any partitioning scheme, no GPT etc. I need a single file image that I could just operate in U-boot with a command similar to

Code:
setenv bootargs earlycon=uart8250,mmio32,0xff130000 console=ttyFIQ0 mtdparts=spi0.0:0x200000(U-Boot),0x500000(Kernel),0x500000(Rootfs),0x100000(Data),-(Unused)  rootfstype=squashfs root=/dev/mtdblock2
setenv bootcmd "sf probe; sf read 0x400000 0x200000 0x500000; bootm 0x400000"
saveenv

I would greatly appreciate your help with figuring out a proper command for flashing and booting just the kernel image. Even if it won't work in the beginning, I should see a tty log of it being booted.
 
Back
Top