Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Aug 2019 21:40:57 +0000
From:      Robert Crowston <crowston@protonmail.com>
To:        "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>
Cc:        Mark Linimon <linimon@lonesome.com>, T W <polymorphics@gmail.com>, Nick Wolff <darkfiberiru@gmail.com>
Subject:   Re: raspberry pi 4
Message-ID:  <ZRAu7dswzh8avcoXhCkshCDMcX3MTDzaAXaH-u4Lb2YyK9tN6HUevF8s5aK71aN-2e4Be8KYR5HxFG2Do1RV_A1GhJ_2mpqJNG_ZXRe4iRg=@protonmail.com>
In-Reply-To: <CACxAneDEJxtNGC%2B6BA2c-z5iG6jzOe-HoUWGKQj2iVgvk0EF_A@mail.gmail.com>
References:  <20190709161243.GC4904@mon.zyxst.net> <HZPxf8oyosxDF2kVxJHXYBDY9ULZtF5VHU8FnEslTS9JS-dMsA1G61OnXEHmL0xUVPqZTeF2Q_Z9F58Su81uDDiX86do5d3mqFG7q4teJlw=@protonmail.com> <y0OsySRDhaQtK8FsGtQSwDgZGfQ3LeIf7w2x-5QIanbhBWwlAuGAXS4ODJZrS7nFm-4zxf2mDvq2wPg40tFCG0Qlidi63Q-n6L40Ro4YU70=@protonmail.com> <34BA723D-D603-4A09-9850-A88E644F0950@kronometrix.org> <KIlWTLvfNxcq3KrR5GvJ3SRj3iG9FmBkL_8vyDnEcG2Hc2txvEY_orF_wDBb9nVrXldzru0LaNoVNvVskoz7aopPx4t7G9A0T-PmxHl3UHk=@protonmail.com> <20190812092026.GA1842@lonesome.com> <CACxAneDEJxtNGC%2B6BA2c-z5iG6jzOe-HoUWGKQj2iVgvk0EF_A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 T=
ymoshenko's original work, no original thought was required):
https://github.com/gonzoua/rpi3-psci-monitor/compare/master...RobCrowston:r=
pi4

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 w=
ith 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=3D0x200
armstub=3Darmstub8.bin
arm_64bit=3D1
enable_gic=3D1
device_tree_address=3D0x4000
enable_jtag_gpio=3D1
enable_uart=3D1
kernel=3Du-boot.bin

Some of those lines may be redundant; e.g., you probably don't need jtag en=
abled. 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 reposit=
ory 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 wo=
rk, 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 s=
ome 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 part=
ition and the EFI/ directory for the FAT partition.

If you set enable_uart=3D1 in config.txt and you boot with -D, there is a w=
eird 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 some=
thing to do with both freebsd and the firmware trying to do serial emulatio=
n at the same time. I haven't had time to investigate.

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

Robert Crowston.

=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me=
ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90
On Monday, 12 August 2019 20:58, Nick Wolff <darkfiberiru@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@lonesome.com> wrote=
:
>
> > On Sun, Aug 11, 2019 at 10:14:33AM +0000, Robert Crowston via freebsd-a=
rm wrote:
> > > I don't know.=C2=A0 This is just a hobby.=C2=A0 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 :-)=C2=A0 The Foundation exists to hold the co=
pyrights,
> > 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 volun=
teer
> > contributors.
> >
> > So if there are patches or documentation that can help move Rpi4 suppor=
t
> > along, please feel free to share them.
> >
> > mcl
> > _______________________________________________
> > freebsd-arm@freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-arm
> > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZRAu7dswzh8avcoXhCkshCDMcX3MTDzaAXaH-u4Lb2YyK9tN6HUevF8s5aK71aN-2e4Be8KYR5HxFG2Do1RV_A1GhJ_2mpqJNG_ZXRe4iRg=>