FreeBSD 13-CURRENT on Rock Pi4

Hi @aguapi,

The standard scenario for installing a system on EMMc, USB, SATA or NVMe looks like this

  1. Starting the system with my u-boot (it correctly generates smbios variables for bsdinatall to work).
  2. Login with superuser rights
  3. Run bsdinstall and install
  4. Tuning - if needed, and reboot.

I want to warn you that in the process, badinstall updates u-boot on EMMc even if you chose to install on EMMc, unfortunately this is the case
.
But at the same time, it will write spi u-boot to the efi section of emmc as a separate file and you can rewrite it yourself to spi.
instructions will be in /usr/local/share/u-boot/u-boot-rock-pi-4/README

To install this bootloader on an SPI flash just do:
=> load mmc 0 ${kernel_addr_r} u-boot-spi.bin
=> sf probe
=> sf update ${kernel_addr_r} 0 ${filesize}

To run my u-boot from an SD card, you should use mask rom mode.

Hello. Thanks for answering. Why put another bootloader if the Armbian one worked fine so far?

It is a standard process and there are multiple uboot maintain by every distro.

So it make everything work out of the box it is preferable to follow a standard process.

I just donā€™t know how bsdinstall will behave if itā€™s an Armbian u-boot.
My u-boot generates special kernel variables that can be viewed with the kenv command,
they are parsed by bsdinstall and this allows us to understand that we are dealing with Radxa-Pi-4
and do the right thing, since RK3399 needs a special breakdown of EMMc in order for the system to boot.
You can just try. If you install the system on NVMe, then most likely it will be fine.
I only recommend the path Iā€™m 99.99% sure of :wink:

So having this perfectly running on a Rock Pi4, how to upgrade to FreeBSD 13.1? Has this been done already ?

freebsd-update -r 13.1-RELEASE upgrade

Read man freebsd-update

Hi there Iā€™m trying this out on a Rockpi 4b, and wondering if USB OTG is supported?

I see on the bootlog of the announcement that it probably is. Is there some clues somewhere about how to enable the board to boot to that mode?

gpio0: mem 0x2000a000-0x2000a0ff irq 86 on simplebus0
gpioc0: on gpio0
gpiobus0: on gpio0
gpio1: mem 0x2003c000-0x2003c0ff irq 87 on simplebus0
device_attach: gpio1 attach returned 6
gpio1: mem 0x2003e000-0x2003e0ff irq 88 on simplebus0
device_attach: gpio1 attach returned 6
gpio1: mem 0x20080000-0x200800ff irq 89 on simplebus0
device_attach: gpio1 attach returned 6
dwcotg0: <DWC OTG 2.0 integrated USB controller> mem 0x10180000-0x101bffff irq 48 on simplebus0
usbus0 on dwcotg0
dwcotg1: <DWC OTG 2.0 integrated USB controller> mem 0x101c0000-0x101fffff irq 49 on simplebus0
usbus1 on dwcotg1
uart0: <16650 or compatible> mem 0x20064000-0x200643ff irq 68 on simplebus0
uart0: console (115200,n,8,1)
Timecounters tick every 10.000 msec
usbus0: 480Mbps High Speed USB v2.0
usbus1: 480Mbps High Speed USB v2.0
ugen1.1: at usbus1
uhub0: <DWCOTG OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
ugen0.1: at usbus0
uhub1: <DWCOTG OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
random: unblocking device.
Release APs

I have tried also using the dwc3 usb driver, with no better results. It seems to be in host mode, not device mode no matter what position the physical switch is in.

Iā€™m using this documentation to try to make an iSCSI target accessible as a USB mass storage device to whatever host I plug it in to.

Hi @Curtman.

Hi there Iā€™m trying this out on a Rockpi 4b, and wondering if USB OTG is supported?

This is a very interesting question.
And the answer to that is No, it canā€™t without changes to the FreeBSD source code.
The fact is that now FreeBSD has a dwc_otg driver, but it will be activated only if the DTS file of the board contains ā€œsnps,dwc2ā€ and we have ā€œsnps,dwc3ā€ on RockPi 4.
You can try changing the source code.

I have tried many ways to install FreeBSD-13.0 and FreeBSD-13.1 images but without any luck. My board is the rock-pi-4-se version. Should I be able to use a modification of this (change the Makefile) mentioned by Ashley_Mills?
When the system boots into u-boot it shows
; MODEL: Radxa ROCK PI 4B
I have no issues when installing debian or ubuntu.

SleepWalkerā€™s FreeBSD-aarch64-13.0-RELEASE-p8-Rock-Pi-4-20220316.img image (from personalbsd.org) worked for me on my Rock 4 SE but I had to get on the serial console and set the ā€˜mediaā€™ and ā€˜mediaoptā€™ using ā€˜ifconfig dwc0ā€™ (see https://forums.freebsd.org/threads/rockpro64-network-adapter.83789/) before the ethernet would work. Hope that helps.

1 Like

Very little information about Rock 4 SE.
And I donā€™t have Rock 4 SE in my hands, itā€™s hard to advise.
But in theory, all problems can be solved with the help of building a custom u-boot that will have the correct DTB.

FYI, https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268068 Looks like jontheil submitted a bug report.

SleepWalker, have you been able to get a WiFi driver to work on any of these boards? Looks like a Broadcom BCM43456 (AMPAK AP6256) according to the wiki page: https://wiki.radxa.com/Rock4/hardware

Looks like FreeBSD lacks the driver. OpenBSD has it: https://man.openbsd.org/bwfm.4 Maybe if I find the time Iā€™ll look at what it would take to pull this over. This driver may work for the RPi 4 too.

1 Like

Hi @sson.
I havenā€™t tested this yet.
It would be great if you could help Bjoern Zeeb with his work on SDIO and WiFi.

I would like to contribute, but I donā€™t know how. I donā€™t quite understand the u-boot mechanism and how the device tree is picked up. It seems like the debian installation has a lot of dtb files in its EFI partition. It actually contains 151 different files in there. I cannot tell which one is picked up. My debug shell is not working (I canā€™t get correct baud speed on my prolific adapter).
Please let me know how I can contribute :slight_smile:

@jontheil
To work with the console port, you will need a USB serial to TTL adapter on the FDT or CH340 chipset, because the port speed is 1500000.
You can send me a private message and I will try to help.

I canā€™t seem to find the original dts file for Rock 4 SE.
Tell me where to find it

@jontheil
Make sure you have a USB to TTL adapter that has a genuine FDTI FT232RL chip. The less expensive ones wonā€™t do 1500000 baud. The one I use: https://www.amazon.com/dp/B075N82CDL See https://wiki.radxa.com/Rockpi4/dev/serial-console for additional information.

1 Like

@SleepWalker
If you look in /boot/armbianEnv.txt on Armbian the Rock 4 SE uses rk3399-rock-pi-4b.dtb for the flattened device tree which may explain why your image worked.

A quick update:

Eventually I got the board booting into FreeBSD 14-CURRENT. I had to build the rk3399-rock-pi-4b.dtb myself. After copying this to the EFI partition at /EFI/dtb/rockchip I was able to boot the system.

The details of building the missing module can be seen at FreeBSD Bugzilla.

I also succeeded in installing FreeBSD 13.1-RELEASE the same way.

Not all of the hardware is working for me at the moment. I guess I have to read up on the differences between the 4b and the SE version.