raspberry pi 4

Robert Crowston crowston at protonmail.com
Wed Aug 28 21:41:07 UTC 2019


Alright, I hoped to have time to make this pretty but I didn't, so here is what I have:

You'll need an SD card with a ~ 50 MB FAT partition and plenty of space for a UFS partition.

You'll want the aarch64 gcc build tools. I did experiment with clang but it was too much of a diversion.

For multiprocessor support, you need this (note, I just updated Oleksandr Tymoshenko's original work, no original thought was required):
https://github.com/gonzoua/rpi3-psci-monitor/compare/master...RobCrowston:rpi4

Compiling that will produce armstub8.bin. Put it on the SD card.

Then you need to build u-boot. Again, just building on the work of others with some small tweaks:
https://github.com/RobCrowston/u-boot/tree/rpi4-freebsd

Copy the built u-boot.bin onto the FAT partition. And copy the dt.dtb file emitted to broadcom/bcm2711-rpi-4-b.dtb.

Then you need to create a config.txt. Mine looks like this:

arm_control=0x200
armstub=armstub8.bin
arm_64bit=1
enable_gic=1
device_tree_address=0x4000
enable_jtag_gpio=1
enable_uart=1
kernel=u-boot.bin

Some of those lines may be redundant; e.g., you probably don't need jtag enabled. Enabling uart here lets you interact with the boot sequence on your serial line but has a weird side effect after boot (discussed below).

Finally you need to grab the remaining files from the official rpi4 repository and place them on the SD card. Note they are not BSD licensed.

bcm2711-rpi-4-b.dtb
bootcode.bin
fixup4.dat
start4.elf

I think(?) this is the minimum set to boot but you can always take the rest if that's not enough. If you don't get the rainbow screen on the HDMI out, you're missing something.

Note that it seems you do need the official bcm2711-rpi-4-b.dtb in the root of the partition, not the one compiled by u-boot, which you should put in broadcom/. The pi4 seems to be pretty sensitive about wanting the original dtb during pre-boot. FreeBSD will look into broadcom/bcm2711-rpi-4-b.dtb to find the dtb it uses during boot, so after u-boot runs it will use the dtb file you compiled.

For the kernel sources, the only serious change I had to make was to the SD card driver. I also had to comment out some code to make various things work, in particular I disabled DMA in the SD card driver for reasons unknown and I removed the HTTP boot loader because u-boot passes a bad pointer to some http-related functions which causes a segfault on boot.

My kernel source is here: https://github.com/RobCrowston/freebsd/tree/rpi4-sdhci

I use the FreeBSD crochet tool against this source, to produce the UFS partition and the EFI/ directory for the FAT partition.

If you set enable_uart=1 in config.txt and you boot with -D, there is a weird condition where immediately after /sbin/init runs, the serial speed on the client needs to be doubled from 115200 to 230400. I assume that's something to do with both freebsd and the firmware trying to do serial emulation at the same time. I haven't had time to investigate.

Caveats: most hardware still not working, including USB, PCI-E, and ethernet. RAM detection is incorrect on my 2 GB Pi. Witness complains about lock reversals in the sd driver. Basically, we are some distance from tier 1.

Robert Crowston.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, 12 August 2019 20:58, Nick Wolff <darkfiberiru at gmail.com> wrote:

> Robert,
>
> Definitely excited to see any patches or if you have a github branch that even better.
>
> Thanks,
>
> Nick Wolff
>
> On Mon, Aug 12, 2019 at 5:20 AM Mark Linimon <linimon at lonesome.com> wrote:
>
> > On Sun, Aug 11, 2019 at 10:14:33AM +0000, Robert Crowston via freebsd-arm wrote:
> > > I don't know.  This is just a hobby.  I am not part of the FreeBSD
> > > Foundation.
> >
> > You don't have to be a member of the Foundation (or even employed there)
> > to contribute to FreeBSD :-)  The Foundation exists to hold the copyrights,
> > perform advoacy, own equipment, and so forth.
> >
> > Everything else is done by individual participants -- a few are funded by
> > the companies they work for, but the vast majority are individual volunteer
> > contributors.
> >
> > So if there are patches or documentation that can help move Rpi4 support
> > along, please feel free to share them.
> >
> > mcl
> > _______________________________________________
> > freebsd-arm at freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-arm
> > To unsubscribe, send any mail to "freebsd-arm-unsubscribe at freebsd.org"


More information about the freebsd-arm mailing list