FreeBSD for RK3568?

Hi All,
I build EDK2 UEFI for Radxa Rock-3A.
Can anyone try to write it to an SD card and try to run it?

https://personalbsd.org/download/UEFI-RK356x/ROCK-3A_EFI.img

The console port speed is 115200, this is a little different from the usual.
I do not rule out that HDMI, and USB hd & keyboard can work. :wink:

1 Like

I will give it a try tonight…

I have a serial cable and some blank emmc/uSD cards so I can give it a try this weekend.

I’m 90% sure that HDMI will work.
It remains to select those USB ports that will be active for connecting a USB keyboard and USD disk.
This weekend I can prepare a FreeBSD Boot Image for Rock3A.
Let me know if you are interested and ready to test.
It’s better to use Linux for UEFI build.
I completely reworked the UEFI source code…

Sorry for the late reply, had some other things I’m working on.

Anyway, long story short I couldn’t get it to boot or the HDMI to work. I didn’t even sees anything over the Serial connection. I’ll see if I can get another micro SD to try, I might also try to write the img file with a different utility instead of dd.

Hi !

In the latest build of EDK2 UEFI for Rock3A
Serial/HDMI/USB/Ethernet work.
Tested on VMware ESXi/Fedora/FreeBSD/NetBSD
The source code can be viewed here

3 Likes

Nice,
I’ll give it a shot and hook up my usb to serial adapter.
Thanks for the update btw.

EDIT:
maybe I will test later, still waiting download, and it doesn’t look like it will finish for another 16 hours.

2 Likes

@lenzo1337
My HDMI monitor also works with Rock3A. :wink:

ROCK-3A EDK2 UEFI BootLoader

FreeBSD-aarch64-14.0-CURRENT-Rock-3A-20230530.img.xz

You need to write UEFI to sdcard, and OS to USB flash disk.

Console port speed 115200.
ssh enabled by default.
root without password.

Login via ssh
Username: admin
Password: admin

OPNsense test on Rock 3A

2 Likes

I cant wait for opnsense with both lan working at its max speed 2.5g

Pcie/eth support when?

@spikerguy

1GbE on Rock-3A works. If you speak about FreeBSD on E23/E25 and about RTL8125BG, 2.5 GbE support then we need to add PCIe3 support to EDK2 UEFI.

And this is the shortest and easiest way to solve the problem.

I’m posting this to draw attention to the possibility of solving it this way.
There are already several UEFI repositories for RockChip RK35xx.

And the more participants in such projects, the faster we will get the result.

If anyone knows of other public EDK2 UEFI repositories for the RockChip SOC,
please post links here.

after dd into sdcard/usb stick, need fdisk to fix gpt.

HDMI Monitor work, Network work, but USB mouse/keyboard didn’t

I can see “login:” in HDMI monitor, “Rock3a” in router, and connect by ssh.

I found the user/password in telegram. admin/admin
thank you very much.

2 Likes

@lin

after dd into sdcard/usb stick, need fdisk to fix gpt.

There is no urgent need for this.
UEFI will work without it.
FreeBSD will do this automatically on first boot and will expand the root partition to the maximum size, everything will happen automatically.

Not all USB connectors work correctly, it’s true.
I am using a wireless keyboard/mouse.
Just try switching the keyboard to another connector, experimenting, it should work.
Enjoy FreeBSD.

Good luck.

1 Like

Hi All!

You can test FreeBSD on Radxa E25 and Radxa Rock-3A.

For the Radxa E25, I created a test FreeBSD boot image.
It can simply be written to an SD card and run.

Bootable SD card image for E25
FreeBSD-aarch64-14.0-CURRENT-Radxa-E25-20230511.img.xz

Bootable SD card image for Rock-3A
FreeBSD-aarch64-14.0-CURRENT-Rock-3A-20230531.img.xz

UEFI binary images are here
Tianocore EDK2 UEFI repository here. https://github.com/S199pWa1k9r/rk356x-uefi

Generic USB flash image:
FreeBSD-aarch64-14.0-CURRENT-GENERIC-RK356X-20230516.img.xz

EDIT:
pcie30 works in UEFI, so it is possible to boot the system directly from NVMe on Rock-3A.

2 Likes

NMVe on Radxa Rock-3A

2 Likes

HI @SleepWalker,

first, thanks a lot for your work!
I’ve been trying your rock3a sdcard image, it boots, even the nvme gets detected, but then the boot process hangs after initializing the usb hub. See bootlog here:

Bootlog
U-Boot SPL board init
U-Boot SPL 2017.09-gaaca6ffec1-211203 #zzz (Dec 03 2021 - 18:42:16)
unknown raw ID phN
/  ______               ____   _____ _____  
  |  ____|             |  _ \ / ____|  __ \ 
  | |___ _ __ ___  ___ | |_) | (___ | |  | |
  |  ___| '__/ _ \/ _ \|  _ < \___ \| |  | |
  | |   | | |  __/  __/| |_) |____) | |__| |
  | |   | | |    |    ||     |      |      |
  |_|   |_|  \___|\___||____/|_____/|_____/      ```                        `
                                                s` `.....---.......--.```   -/
 /---------- Welcome to FreeBSD -----------\    +o   .--`         /y:`      +.
 |                                         |     yo`:.            :o      `+-
 |  1. Boot Multi user [Enter]             |      y/               -/`   -o/
 |  2. Boot Single user                    |     .-                  ::/sy+:.
 |  3. Escape to loader prompt             |     /                     `--  /
 |  4. Reboot                              |    `:                          :`
 |  5. Cons: Serial                        |    `:                          :`
 |                                         |     /                          /
 |  Options:                               |     .-                        -.
 |  6. Kernel: default/kernel (1 of 1)     |      --                      -.
 |  7. Boot Options                        |       `:`                  `:`
 |                                         |         .--             `--.
 |                                         |            .---.....----.

   Autoboot in 0 seconds. [Space] to pause 

Loading kernel...
/boot/kernel/kernel text=0x2a8 text=0x843dc0 text=0x1f3cdc data=0x1248b8 data=0x
0+0x285000 0x8+0x11bdb8+0x8+0x141ae5|
Loading configured modules...
can't find '/etc/hostid'
can't find '/boot/entropy'
Using DTB provided by EFI at 0xef021000.
---<<BOOT>>---
GDB: debug ports: uart
GDB: current port: uart
KDB: debugger backends: ddb gdb
KDB: current backend: ddb
Copyright (c) 1992-2023 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 14.0-CURRENT #0 main-n262795-3e696dfb7009-dirty: Thu May 11 14:53:08 MSK 2023
    root@honeycomb.local:/usr/crochet/work/obj/usr/crochet/src-current-14.0/arm64.aarch64/sys/EXPERT arm64
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
VT: init without driver.
real memory  = 8292986880 (7908 MB)
avail memory = 8062509056 (7689 MB)
Starting CPU 1 (100)
ctarting CPU 2 (200)
hStarting CPU 3 (300)
 FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
random: unblocking device.
random: entropy device external interface
MAP ae0000 mode 2 pages 32
MAP ec980000 mode 2 pages 128
MAP eca00000 mode 2 pages 48
MAP eca30000 mode 2 pages 64
MAP eca80000 mode 2 pages 32
MAP ecaa0000 mode 2 pages 160
MAP efe20000 mode 2 pages 144
MAP efec0000 mode 2 pages 288
kbd0 at kbdmux0
acpi0: <RKCP RK356X>
acpi0: Power Button (fixed)
acpi0: Sleep Button (fixed)
acpi0: Could not update all GPEs: AE_NOT_CONFIGURED
psci0: <ARM Power State Co-ordination Interface Driver> on acpi0
gic0: <ARM Generic Interrupt Controller v3.0> iomem 0xfd400000-0xfd40ffff,0xfd460000-0xfd51ffff on acpi0
generic_timer0: <ARM Generic Timer> irq 13,14,15 on acpi0
Timecounter "ARM MPCore Timecounter" frequency 24000000 Hz quality 1000
Event timer "ARM MPCore Eventtimer" frequency 24000000 Hz quality 1000
efirtc0: <EFI Realtime Clock>
efirtc0: registered as a time-of-day clock, resolution 1.000000s
pmu0: <Performance Monitoring Unit> on acpi0
cpu0: <ACPI CPU> on acpi0
acpi_tz0: <Thermal Zone> on acpi0
acpi_tz1: <Thermal Zone> on acpi0
ns8250: UART FCR is brokene> iomem 0xfe660000-0xfe660fff irq 1 on acpi0
uart0: console (115384,n,8,1)
ohci0: <Generic EHCI Controller> iomem 0xfd840000-0xfd87ffff irq 3 on acpi0
usbus0 on ohci0
ehci0: <Generic EHCI Controller> iomem 0xfd800000-0xfd83ffff irq 4 on acpi0
usbus1: EHCI version 1.0
usbus1 on ehci0
ohci1: <Generic EHCI Controller> iomem 0xfd8c0000-0xfd8fffff irq 5 on acpi0
usbus2 on ohci1
ehci1: <Generic EHCI Controller> iomem 0xfd880000-0xfd8bffff irq 6 on acpi0
usbus3: EHCI version 1.0
usbus3 on ehci1
xhci0: <Generic USB 3.0 controller> iomem 0xfcc00000-0xfcffffff irq 7 on acpi0
xhci0: 64 bytes context size, 32-bit DMA
usbus4 on xhci0
xhci1: <Generic USB 3.0 controller> iomem 0xfd000000-0xfd3fffff irq 8 on acpi0
xhci1: 64 bytes context size, 32-bit DMA
usbus5 on xhci1
eq0: <RK356x EQOS Gigabit ethernet> iomem 0xfe010000-0xfe01ffff irq 9,10 on acpi0
miibus0: <MII bus> on eq0
rgephy0: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 0 on miibus0
rgephy0:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto
rgephy1: <RTL8169S/8110S/8211 1000BASE-T media interface> PHY 1 on miibus0
rgephy1:  none, 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, 1000baseT-FDX-master, auto
eq0: Ethernet address: ae:ed:72:47:94:77
dwmmc_acpi0: <Synopsys DesignWare Mobile Storage Host Controller> iomem 0xfe2b0000-0xfe2b3fff irq 11 on acpi0
dwmmc_acpi0: Hardware version ID is 270a
mmc0: <MMC/SD bus> on dwmmc_acpi0
sdhci_acpi0: <Rockchip eMMC Controller> iomem 0xfe310000-0xfe31ffff irq 12 on acpi0
Firmware Warning (ACPI): Possibly buggy BIOS with ACPI_TYPE_INTEGER for function enumeration
 (20221020/ACPI-2984)
sdhci_acpi0: RK356x vendor_clock enabled
mmc1: <MMC/SD bus> on sdhci_acpi0
pcib0: <Generic PCI host controller> on acpi0
pci0: <PCI bus> on pcib0
nvme0: <Generic NVMe Device> mem 0xf0000000-0xf0003fff at device 0.0 on pci0
nvme0: unable to allocate MSI-X
nvme0: unable to allocate MSI
armv8crypto0: <AES-CBC,AES-XTS,AES-GCM>
Timecounters tick every 1.000 msec
[nl_generic_kpi] genl_register_family: Registered family nlctrl id 16
[nl_generic_kpi] genl_register_cmds: Adding cmd GETFAMILY(3) to family nlctrl
usbus0: 12Mbps Full Speed USB v1.0
usbus1: 480Mbps High Speed USB v2.0
usbus2: 12Mbps Full Speed USB v1.0
usbus3: 480Mbps High Speed USB v2.0
usbus4: 5.0Gbps Super Speed USB v3.0
ugen0.1: <Generic OHCI root HUB> at usbus0
uhub0 on usbus0
uhub0: <Generic OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
ugen1.1: <Generic EHCI root HUB> at usbus1
uhub1 on usbus1
uhub1: <Generic EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
ugen2.1: <Generic OHCI root HUB> at usbus2
uhub2 on usbus2
uhub2: <Generic OHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus2
ugen3.1: <Generic EHCI root HUB> at usbus3
uhub3 on usbus3
uhub3: <Generic EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus3
ugen4.1: <Generic XHCI root HUB> at usbus4
uhub4 on usbus4
uhub4: <Generic XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus4
usbus5: 5.0Gbps Super Speed USB v3.0
ugen5.1: <Generic XHCI root HUB> at usbus5
uhub5 on usbus5
uhub5: <Generic XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus5
mmcsd0: 32GB <SDHC SM32G 8.0 SN 19781DCD MFG 12/2020 by 3 SD> at mmc0 50.0MHz/4bit/1016-block
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
sdhci_acpi0-slot0: Got command interrupt 0x00000001, but there is no active command.
mmc1: No compatible cards found on bus
CPU  0: ARM Cortex-A55 r2p0 affinity:  0  0
                   Cache Type = <64 byte D-cacheline,64 byte I-cacheline,VIPT ICache,64 byte ERG,64 byte CWG>
 Instruction Set Attributes 0 = <DP,RDM,Atomic,CRC32,SHA2,SHA1,AES+PMULL>
 Instruction Set Attributes 1 = <RCPC-8.3,DCPoP>
 Instruction Set Attributes 2 = <>
         Processor Features 0 = <RAS,GIC,AdvSIMD+HP,FP+HP,EL3 32,EL2 32,EL1 32,EL0 32>
         Processor Features 1 = <PSTATE.SSBS>
      Memory Model Features 0 = <TGran4,TGran64,TGran16,SNSMem,BigEnd,16bit ASID,1TB PA>
      Memory Model Features 1 = <XNX,PAN+ATS1E1,LO,HPD+TTPBHA,VH,16bit VMID,HAF+DS>
      Memory Model Features 2 = <32bit CCIDX,48bit VA,IESB,UAO,CnP>
             Debug Features 0 = <DoubleLock,2 CTX BKPTs,4 Watchpoints,6 Breakpoints,PMUv3 v8.1,Debugv8.2>
             Debug Features 1 = <>
         Auxiliary Features 0 = <>
         Auxiliary Features 1 = <>
AArch32 Instruction Set Attributes 5 = <RDM,CRC32,SHA2,SHA1,AES+VMULL,SEVL>
AArch32 Media and VFP Features 0 = <FPRound,FPSqrt,FPDivide,DP VFPv3+v4,SP VFPv3+v4,AdvSIMD>
AArch32 Media and VFP Features 1 = <SIMDFMAC,FPHP Arith,SIMDHP Arith,SIMDSP,SIMDInt,SIMDLS,FPDNaN,FPFtZ>
CPU  1: ARM Cortex-A55 r2p0 affinity:  1  0
CPU  2: ARM Cortex-A55 r2p0 affinity:  2  0
CPU  3: ARM Cortex-A55 r2p0 affinity:  3  0
Release APs...done
uhub0: 1 port with 1 removable, self powered
Trying to mount root from ufs:/dev/gpt/install [rw,noatime]...
nda0 at nvme0 bus 0 scbus0 target 0 lun 1
GEOM: mmcsd0: the secondary GPT header is not in the last LBA.
nda0: <KINGSTON SA2000M8500G S5Z42105 50026B7683E1DFF7>
nda0: Serial Number 50026B7683E1DFF7
nda0: nvme version 1.3 x1 (max x4) lanes PCIe Gen3 (max Gen3) link
nda0: 476940MB (976773168 512 byte sectors)
uhub2: 1 port with 1 removable, self powered
uhub4: 2 ports with 2 removable, self powered
uhub5: 2 ports with 2 removable, self powered
uhub1: 1 port with 1 removable, self powered
uhub3: 1 port with 1 removable, self powered
ugen1.2: <Terminus Technology USB 2.0 Hub> at usbus1
uhub6 on uhub1
uhub6: <Terminus Technology USB 2.0 Hub, class 9/0, rev 2.00/1.11, addr 2> on usbus1
uhub6: 4 ports with 4 removable, self powered

It seems like the system fails to

Trying to mount root from ufs:/dev/gpt/install [rw,noatime]...

Do you have any ideas how to fix this?

Also I see

eq0: Ethernet address: ae:ed:72:47:94:77

eq0 is detected, but i don’t see any ‘link up’ messages despite the link being up, given by the hw leds.

Any suggestions are very welcome!

Thanks & best

I know that not all SD cards work the same, some don’t work on Rock-3A under FreeBSD,
although they work fine on Linux. This is to be corrected.

There are 3 possible solutions:

  1. Use another manufacturer of SD cards.
    I tested on SanDisk Ultra 32Gb.
  2. Write the image to SD and USB flash.
    Use USB flash as OS boot device.
  3. Switch to FDT OS startup mode.
1 Like

I’m using a SanDisk Extreme 32Gb, so far never let me down, but I’ll try a different one.

I’d really like to avoid using a USB flash drive. I’ve tested your last build where the USB drive was mandatory, it worked but is not favorable.
As I already have a NVMe in the system, I’ll also try putting the OS image on that, just need a way to get it on there.

If I recall correctly, I already tried that without success, but I’ll test it again to make sure.

Thanks for your suggestions, I’ll report back once I had some time to test.

Hi,

I finally managed to get the image up and running. Had to put it onto the NVMe and change fstab on the SDcard to point to the NVMe, as using the gpt label didn’t work.
Now I’ve run into the next problem:

root@Rock-3A:~ # service sshd start
Generating RSA host key.
ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libprivateldns.so.5"
ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libprivateldns.so.5"
Generating ECDSA host key.
ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libprivateldns.so.5"
ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libprivateldns.so.5"
Generating ED25519 host key.
ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libprivateldns.so.5"
ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libprivateldns.so.5"
Performing sanity check on sshd configuration.
ld-elf.so.1: Shared object "libssl.so.111" not found, required by "libprivateldns.so.5"
/etc/rc.d/sshd: WARNING: failed precmd routine for sshd

also this:

root@Rock-3A:~ # find
find: Command not found.

there seems to be a some problem with the image ¯\(ツ)

@SleepWalker could you share your build script/poudriere config/whatever you are using to build these images?

Thanks & best

Hello.

@SleepWalker
Thanks for your work on UEFI for Rockchip boards!

I have some issues with UEFI Rock 3a, do you know by any chance what may be the cause?

  1. ethernet on Linux does not work, here is the log
rock3a ❯ root ❯ /root ❯ dmesg | grep eth
[    0.000000] psci: probing for conduit method from DT.
[    9.844244] rk_gmac-dwmac fe010000.ethernet: IRQ eth_lpi not found
[    9.845556] rk_gmac-dwmac fe010000.ethernet: clock input or output? (input).
[    9.845625] rk_gmac-dwmac fe010000.ethernet: TX delay(0x42).
[    9.845634] rk_gmac-dwmac fe010000.ethernet: RX delay(0x28).
[    9.845651] rk_gmac-dwmac fe010000.ethernet: integrated PHY? (no).
[    9.845706] rk_gmac-dwmac fe010000.ethernet: clock input from PHY
[    9.850726] rk_gmac-dwmac fe010000.ethernet: init for RGMII
[    9.857097] rk_gmac-dwmac fe010000.ethernet: User ID: 0x30, Synopsys ID: 0x51
[    9.857124] rk_gmac-dwmac fe010000.ethernet:         DWMAC4/5
[    9.857132] rk_gmac-dwmac fe010000.ethernet: DMA HW capability register supported
[    9.857137] rk_gmac-dwmac fe010000.ethernet: RX Checksum Offload Engine supported
[    9.857141] rk_gmac-dwmac fe010000.ethernet: TX Checksum insertion supported
[    9.857145] rk_gmac-dwmac fe010000.ethernet: Wake-Up On Lan supported
[    9.857237] rk_gmac-dwmac fe010000.ethernet: TSO supported
[    9.857243] rk_gmac-dwmac fe010000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    9.857255] rk_gmac-dwmac fe010000.ethernet: device MAC address 12:a7:45:12:c1:2c
[    9.857264] rk_gmac-dwmac fe010000.ethernet: Enabled RFS Flow TC (entries=10)
[    9.857272] rk_gmac-dwmac fe010000.ethernet: TSO feature enabled
[    9.857277] rk_gmac-dwmac fe010000.ethernet: Using 32/32 bits DMA host/device width
[    9.994921] rk_gmac-dwmac fe010000.ethernet: error -EBUSY: Cannot register the MDIO bus
[    9.994949] rk_gmac-dwmac fe010000.ethernet: error -EBUSY: stmmac_dvr_probe: MDIO bus (id: 0) registration failed
[   10.029150] rk_gmac-dwmac: probe of fe010000.ethernet failed with error -16

Ethernet works fine with uboot. If I add dtb (latest mainline) in bootloader options explicitly, ethernet works, but micro SD card slot stops working.

  1. bootloader fails to read files from emmc randomly
    I am booting systemd-boot (on emmc) from uefi (on spi), and it loads fine, but then systemd-boot sometimes fails to find/read kernel image, or says that initrd crc check failed and halts. That error seems to occur randomly, and unplugging board from power and restarting in a minute seems to fix the issue. Does not matter which emmc chip I use, and have no such issues on uboot, so I don’t think its faulty emmc chip.

  2. is there a way to persist uefi settings (boot timeout, boot entries, boot order, etc.) when booting from UEFI on SPI?

  3. is there a way to enable usb keyboard support in uefi? I am able to enter uefi setup via serial, but usb keyboard is unresponsive.

Thanks!

I think all these problems can be solved with a proper DTB file.
There is currently no SPI support in UEFI, so saving settings to SPI is not possible.