[Solved] Raspberry Pi 4 (Model B) with (Free/Open)BSD does not work over serial (or anything, really)

Hewwo OwO~nyaaa~~!! :wave:

(alright, I’ll stop that)

I bought myself a Raspberry Pi 4 (TIFC00091-2) almost half a year ago with the intent of working on some personal projects. Unfortunately, life got in the way and aside from me buying it, placing a passive metal heatsink on it and running Manjaro KDE off it once, I didn’t do much.

I’d say it was an okay experience, realized that my power supply wasn’t powerful enough and bought the official power supply from Amazon but otherwise, it was a computer. 11/10.

Now, I’ve been having some more time on my hands and I’ve been wanting to use my RPi for more “esoteric” projects. I’ve been wanting to daily drive a BSD-like operating system and do kernel and driver development on it as an exercise in learning about low level systems (also because I want to daily drive GNUStep and do stuff without risking my work^TM machine)

(I’m giving the model numbers for everything in case I’ve fucked up because I bought the wrong stuff)

So, I go on to download FreeBSD 13.0-RELEASE and, unpack the xz archive with unxz and dd if=...'d it onto my known-good SanDisk SDSQXA1-128G-GN6MN (I’m using my SDDR-A631-GNGNN for this).

FreeBSD does two things, runs sshd by default with password authentication enabled (source) and the default config.txt reads like this…

init_uart_clock=3000000
enable_uart=1
kernel=u-boot.bin
kernel7=u-boot.bin
dtoverlay=mmc

So, I should be able to communicate with FreeBSD via serial using pins 5VO, GND, TXDO and RXDO with my PL2303TA (I’m using Cutecom) and connect via SSH.

But, nothing shows up. When I connect the RPi to the serial adapter, it for some reason has both red and green indicators glow. I don’t think much of it and then plug in the power cable.

Nothing, no serial output.

So I figure serial is funky and abandon it, connect my Ethernet cable wired directly to my router, unplug and replug the power cable and see what happens. After using an IP Scanner a few times and seeing nothing, I got fed up.

I unplugged everything, connected only power and mini-HDMI to my monitor and saw that there was nothing.

So, the problem might just be FreeBSD. I go to their website and of course, I’m supposed to use a FreeBSD 14 snapshot because…

The u-boot.bin used when creating 13.0-RELEASE image was too old to support newer RPi4 hardware revision. (source)

So, I do exactly that, download 14.0-CURRENT-20220407 (the latest during the writing of this post), dd'd it and tried again. Nothing. No serial, no video output, no SSH (or DHCP registration for that matter, checked with my router).

Then I tried OpenBSD 7.0 as to the best of my knowledge, they seem to have relatively complete support for it (source). Same problem.

Now I’m thinking my RPi might have breathed its last and so I download Raspberry Pi OS (64-bit) and tried booting it up again. No serial, no video but it does register on my router and an IP scan shows that the device exists.

Where do I go from here? What BSD works best with Raspberry Pi 4? This doesn’t seem like RPi problem but more a FreeBSD/OpenBSD problem but I’m a novice to the platform so I’m not sure if that’s the case.

Are there any resources you’d recommend to someone who is trying to use not-Linux on an ARM SBC?

TL;DR: At the end, I installed NetBSD with help for a guide (source), using arm64.img.gz from build 202204190030Z (source) and the pftf’s UEFI firmware v1.33 (source)!

Now, as to what lead me here.

When booting NetBSD-CURRENT, I was given a Error: start4.elf is not compatible - This board requires newer software, which, based on some advice on the internet, made me install Raspbian 11 (64-bit) and update the firmware by switching it to the stable branch (the default being the critical branch) and running rpi-eeprom-update -d -a.

That fixed nothing. The problem wasn’t the firmware on the EEPROM, it was the firmware that’s on the EFI partition as that was the one that would outdated (that by the way, stores more than just EFI data, I’m today years old knowing that).

So I went to download the latest revision of official firmware (source), overwrote all the files the partition contained with files from this archive while maintaining the original directory structure and decided to try again.

Now, NetBSD booted, I got stuff out of the serial port but it was all gibberish. I tried different baud rates and even different applications, trying even different RS485-to-USB devices, nothing. It’s all nonsense.

Going to config.txt, with the power of the internet, I cobbled up something like this…

enable_uart=1
core_freq=250 # https://github.com/raspberrypi/linux/issues/4123
init_uart_baud=115200
init_uart_clock=48000000
uart_2ndstage=1

uart_2ndstage=1 is important cause now when I powered up the Raspberry Pi, I finally got to see something human-readable, albeit from the second boot stage (so now I know my RS485 works for sure!) but I eventually still got reverted to gibberish.

I give up on NetBSD (for now) and try OpenBSD. It doesn’t boot, so I substitute the firmware files with whatever I got from that firmware archive and I get somewhere.

No gibberish this time, but I got a boot loop that has already been documented (source), figuring it’s perhaps bwfm0: failed loadfirmware of file brcmfmac43455-sdio.raspberrypi,4-model-b.bin the line that caused the bootloop, alongside disable-bt.dtbo, I add the disable-wifi.dtbo overlay to the appropriate folder and update config.txt to try and bypass the error.

Did it work? Of course not! Now it just stopped at gpio at bcmgpio0 not configured, which is also documented (source). Well, fuck me sideways.

So, OpenBSD isn’t it either. Let’s go back to FreeBSD-13-RELEASE. Re-reading their wiki (source), it turns out I downloaded their armv6 image instead of their aarch64 variant (and I’ve been downloading the correct variant for NetBSD and OpenBSD, I went back and checked)

So, I download both FreeBSD 14.0-CURRENT and 13.0-RELEASE (aarch64) and place my earlier downloads elsewhere, flash 13.0-RELEASE and replaced the firmware with updated versions from the archive.

Serial works, it’s plugged in, it’s booting and… kernel panic!

There seem to be some dumps that look similar (source) with the closest happening on an RPi 3 (source), it’s possible that these kernel panic reports are barely related but that’s what some Google-fu gave me and I didn’t save the dump as I never really planned on making a follow-up post.

Reading the wiki again, I see this line…

The u-boot.bin used when creating 13.0-RELEASE image was too old to support newer RPi4 hardware revision.

and now go forth and seek this u-boot.bin from the FreeBSD Ports (source) and don’t see a download option. I googled the SHA256 hash and got nowhere in that regard.

Maybe I’m stupid, maybe I’m not looking in the right places but no matter, I don’t have a possible fix and I need it.

So I setup a VM running GhostBSD (that had its own set of problems, namely installing VirtIO drivers and the installation process for some reason not creating my user account but also not allowing me to login as root due to securetty restrictions forcing me to go into single-user mode and creating an account that was in the staff and wheel group) and go on my (not) merry way.

I get my hands on u-boot.bin (located at /usr/local/share/u-boot/u-boot-rpi4/u-boot.bin), mounted my SD card, dealt with bugs relating to that and the mv'ing it onto the partition, overwriting the existing u-boot.bin file.

So, after playing the firmware equivalent of Ghosts N’ Goblins, do I get anywhere?

Nope! It still panics on me.

So I try the same steps as above (after copying that u-boot.bin into a folder where I’m archiving all the previous failures so I can copy files as I need them without pulling my hair out) with 14.0-CURRENT and… got the same error.

At this point nothing worked for me. Then I thought about the very first change I made, the EEPROM firmware upgrade. So, I proceeded to downgrade the firmware (source) to the last critical release and so I flashed Raspbian 11 again to do exactly that.

Nothing changed.

When re-doing the same Google searches I made, I came across references to the pftf UEFI firmware but had no idea what to do with with it… until I found the Rosetta Stone (source) and with that, I flashed NetBSD 10.0-CURRENT (not the same snapshot, I redownloaded the latest snapshot that had no build failures), mounted the FAT partition and deleted everything except EFI and put the contents of the pftf firmware archive onto the partition et voila!

It works now!

2 Likes

Great adventure. Well I have no experience with any BSD on ARM, but thanks for the write-up and not just “n/m works now! *close*” :slight_smile:

1 Like

Look, I really appreciate your detailed notes and that you did finally get NetBSD working on your Raspberry Pi 4B. Your persistence shows through your efforts. I tried FreeBSD org where the aarch64 FreeBSD 14.0 snapshot image to write into a USB flash drive and boot.
download freebsd org snapshots arm64 aarch64 ISO-IMAGES 14.0

ghostbsd-arm64 blogspot com 2021 02 download-freebsd-140-current-version html
I had problems with USB keyboard not working in February 2021 FreeBSD 14.0 image version of FreeBSD 14.0 downloaded from the snapshots

Here is a method of audit checking the MD5 checksums for the files that make up the boot image you have downloaded. Use this to check what has been changed
ghostbsd-arm64 blogspot com 2021 05 audit-your-boot-files-with-md5deep.html

ghostbsd-arm64 blogspot com 2022 09 freebsd-140-compiling-kernel-for.html Here I show how to write a snapshot image into a USB flash drive, boot that up, connect an external USB to SATA SSD drive and use bsdinstall to download FreeBSD over the internet and install to the 500 GigaByte SSD drive. Power down, remove the USB flash drive and have a booting FreeBSD 14.0 O/S. I then show how to add an VCHIQ audio patch file to get HDMI Audio to play out the HDMI TV speakers. WooHoo YouTube is playing audio in FireFox browser now!!

Again, thanks for your efforts to share your horrible experience. I hope others trying OpenBSD, NetBSD, FreeBSD on Raspberry Pi 4B hardware have a better experience than you or I did. Keep trying chap. You will find a method to make it work, eventually.

wiki radxa com rock5 some nice hardware coming down the line with 8 cpu cores and 16GB of Ram, plus a M.2 PCIe SSD.
FreeBSD arm arm64 mailing list, view subscription , browse the archives
** lists freebsd org subscription freebsd-arm**

Despite what people think the RPi Foundation/Broadcom do very little for support in terms of providing documentation for their hardware. The bulk work in Linux is provided by those two simply because they have documentation which probably will cause issues when interest/efforts cools off. Both Allwinner and Rockchip are much better solutions of you want better support in general.