TUTORIAL: Install OpenBSD on a PINE64 ROCK64 media board.
Required hardware
NOTE
In this tutorial I use the Linux distribution openSUSE Leap 15.2. The additional BASH scripts (if you use them) for downloading the toolchains (GCC for AArch64), build ARM-Trusted-Firmware and U-Boot use default Linux commands. There are also some required software which is needed for a successfull build of U-Boot.
ATTENTION
Use 3.3V logic level only, to avoid damages of the board
Required software
NOTE
In this tutorial I use GCC for AArch64 ELF bare-metal targets (aarch64-none-elf). If you use OpenBSD as your hostsystem you can use GCC for AArch64 from the ports.
On OpenBSD:
$ cd /usr/ports/devel/arm-none-eabi
$ doas make install
The port is called arm-none-eabi, but you if you build and install the port, the required aarch64-none-elf-gcc will also be installed.
On OpenBSD:
$ cd /usr/ports/devel/dtc
$ doas make install
On openSUSE:
$ sudo zypper install dtc
On Ubuntu:
$ sudo apt-get install device-tree-compiler
On OpenBSD:
$ cd /usr/ports/devel/swig
$ doas make install
On openSUSE:
$ sudo zypper install swig
On Ubuntu:
$ sudo apt-get install swig
NOTE
You need GNU Make for a successfull build of the ARM-Trusted-Firmware and U-Boot, if you use OpenBSD as your hostsystem.
On OpenBSD:
$ doas pkg_add gmake
To build ARM-Trusted-Firmware and U-Boot use the command gmake instead of make in this tutorial, after you installed the package (GNU Make) on OpenBSD.
You can skip step 1 and step 2, if you want to use my build scripts (initial version) for downloading the required toolchains, build ATF, build U-Boot and generate my U-Boot script for enabling the USB-port, or you can use my prebuilt binaries. If you choose these both ways you can begin at step 3.
To build U-Boot with my scripts:
$ git clone https://github.com/krjdev/rock64_openbsd.git
$ cd rock64_openbsd
$ sh build.sh
The required file(s) for this tutorial are placed in the root directory of the repository. The following files should be successfully created:
This file is the ARM-Trusted-Firmware. It is embedded in the U-Boot binaries. No longer required for this tutorial.
This file ist the U-Boot script binary for enabling one of the USB ports. It's an inital release. Might change on further releases of this tutorial. The reason is, OpenBSD currently doesn't power-on the USB-ports. This script is a workaround as soon as the OpenBSD developers fix this issue.
This is the second stage bootloader. The first stage bootloader is proprietary and resides in the embedded Flash in the used SoC (Rockchip RK3328).
The Device-Tree-Blob. It's the binary version of one or more Device-Tree sources. This file contains information, like embedded interfaces, about the SoC.
This is the third stage bootloader. U-Boot itself.
$ git clone https://github.com/ARM-software/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ git checkout v2.4
$ make distclean
$ make CROSS_COMPILE=/path/to/gcc/bin/aarch64-none-elf- PLAT=rk3328
$ export BL31=/path/to/arm-trusted-firmware/build/rk3328/release/bl31/bl31.elf
NOTE
The previous steps (build ATF) are required to successfully boot OpenBSD. Without these steps, U-Boot will boot but cannot load OpenBSD.
$ git clone https://github.com/u-boot/u-boot.git
$ cd u-boot
$ git checkout v2021.04
$ make mrproper
$ make rock64-rk3328_defconfig
$ make CROSS_COMPILE=/path/to/gcc/bin/aarch64-none-elf-
$ ./tools/mkimage -A arm64 -a 0 -e 0 -T script -C none -n "Enable one USB-port" -d /path/to/u-boot_usb.script boot.scr
$ sudo dd if=/path/to/miniroot69.img of=/dev/sdx bs=1M
$ sudo dd if=/path/to/idbloader.img of=/dev/sdx bs=512 seek=64 conv=sync
$ sudo dd if=/path/to/u-boot.itb of=/dev/sdx bs=512 seek=16384 conv=sync
minicom -8 -D /dev/ttyUSB0 -b 1500000
$ sudo mount -t vfat /dev/sdx1 /mnt
$ cd /mnt
$ sudo mkdir rockchip
$ sudo cp path/to/u-boot/arch/arm/dts/rk3328-rock64.dtb rockchip
$ cd /mnt
$ sudo cp path/to/u-boot/boot.scr ./
$ cd /
$ sudo umount /mnt
rock64# dmesg
OpenBSD 6.9 (GENERIC.MP) #1134: Sun Apr 18 01:53:35 MDT 2021
[email protected]:/usr/src/sys/arch/arm64/compile/GENERIC.MP
real mem = 4209647616 (4014MB)
avail mem = 4003446784 (3817MB)
random: good seed from bootblocks
mainbus0 at root: Pine64 Rock64
psci0 at mainbus0: PSCI 1.1, SMCCC 1.2
cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu0: 256KB 64b/line 16-way L2 cache
cpu0: CRC32,SHA2,SHA1,AES+PMULL,ASID16
cpu1 at mainbus0 mpidr 1: ARM Cortex-A53 r0p4
cpu1: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu1: 256KB 64b/line 16-way L2 cache
cpu1: CRC32,SHA2,SHA1,AES+PMULL,ASID16
cpu2 at mainbus0 mpidr 2: ARM Cortex-A53 r0p4
cpu2: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu2: 256KB 64b/line 16-way L2 cache
cpu2: CRC32,SHA2,SHA1,AES+PMULL,ASID16
cpu3 at mainbus0 mpidr 3: ARM Cortex-A53 r0p4
cpu3: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 D-cache
cpu3: 256KB 64b/line 16-way L2 cache
cpu3: CRC32,SHA2,SHA1,AES+PMULL,ASID16
efi0 at mainbus0: UEFI 2.8
efi0: Das U-Boot rev 0x20210400
apm0 at mainbus0
syscon0 at mainbus0: "syscon"
"io-domains" at syscon0 not configured
"grf-gpio" at syscon0 not configured
"power-controller" at syscon0 not configured
"reboot-mode" at syscon0 not configured
rkclock0 at mainbus0
syscon1 at mainbus0: "syscon"
"usb2-phy" at syscon1 not configured
ampintc0 at mainbus0 nirq 160, ncpu 4 ipi: 0, 1: "interrupt-controller"
rkpinctrl0 at mainbus0: "pinctrl"
rkgpio0 at rkpinctrl0
rkgpio1 at rkpinctrl0
rkgpio2 at rkpinctrl0
rkgpio3 at rkpinctrl0
"opp_table0" at mainbus0 not configured
simplebus0 at mainbus0: "bus"
"dmac" at simplebus0 not configured
"arm-pmu" at mainbus0 not configured
rkdrm0 at mainbus0
drm0 at rkdrm0
agtimer0 at mainbus0: 24000 kHz
"xin24m" at mainbus0 not configured
"i2s" at mainbus0 not configured
"spdif" at mainbus0 not configured
com0 at mainbus0: ns16550, no working fifo
com0: console
rkiic0 at mainbus0
iic0 at rkiic0
rkpmic0 at iic0 addr 0x18: RK805
"spi" at mainbus0 not configured
"watchdog" at mainbus0 not configured
rktemp0 at mainbus0
"efuse" at mainbus0 not configured
"gpu" at mainbus0 not configured
"video-codec" at mainbus0 not configured
"iommu" at mainbus0 not configured
"vop" at mainbus0 not configured
"iommu" at mainbus0 not configured
"hdmi" at mainbus0 not configured
"codec" at mainbus0 not configured
"phy" at mainbus0 not configured
dwmmc0 at mainbus0: 50 MHz base clock
sdmmc0 at dwmmc0: 4-bit, sd high-speed, mmc high-speed, dma
dwmmc1 at mainbus0: 50 MHz base clock
sdmmc1 at dwmmc1: 8-bit, mmc high-speed, dma
dwge0 at mainbus0: address d2:1b:38:c4:44:2c
rgephy0 at dwge0 phy 0: RTL8169S/8110S/8211 PHY, rev. 6
ehci0 at mainbus0
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 configuration 1 interface 0 "Generic EHCI root hub" rev 2.00/1.00 addr 1
ohci0 at mainbus0: version 1.0
"usb" at mainbus0 not configured
"external-gmac-clock" at mainbus0 not configured
"sdmmc-regulator" at mainbus0 not configured
"vcc-host-5v-regulator" at mainbus0 not configured
"vcc-host1-5v-regulator" at mainbus0 not configured
"vcc-sys" at mainbus0 not configured
"ir-receiver" at mainbus0 not configured
"leds" at mainbus0 not configured
graphaudio0 at mainbus0
"spdif-dit" at mainbus0 not configured
"dmc" at mainbus0 not configured
"usb" at mainbus0 not configured
"smbios" at mainbus0 not configured
usb1 at ohci0: USB revision 1.0
uhub1 at usb1 configuration 1 interface 0 "Generic OHCI root hub" rev 1.00/1.00 addr 1
scsibus0 at sdmmc0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: <SD/MMC, SC32G, 0080> removable
sd0: 30436MB, 512 bytes/sector, 62333952 sectors
scsibus1 at sdmmc1: 2 targets, initiator 0
sd1 at scsibus1 targ 1 lun 0: <SD/MMC, NCard, 0000> removable
sd1: 59000MB, 512 bytes/sector, 120832000 sectors
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (e373e55c49f00321.a) swap on sd0b dump on sd0b
WARNING: bad clock chip time
WARNING: CHECK AND RESET THE DATE!
rkdrm0: no display interface ports configured
umass0 at uhub0 port 1 configuration 1 interface 0 "Kingston DT microDuo 3.0" rev 2.10/1.10 addr 2
umass0: using SCSI over Bulk-Only
scsibus4 at umass0: 2 targets, initiator 0
sd2 at scsibus4 targ 1 lun 0: <Kingston, DT microDuo 3.0, PMAP> removable serial.095116a3B031394FDE73
sd2: 29568MB, 512 bytes/sector, 60555264 sectors
rock64#
HDMI output currently not working.
Only one USB port is currently working (step 7) with OpenBSD:
NOTE
See issue #5 for additional information.
Thanks to all people from U-Boot and the OpenBSD project.
TUTORIAL: Install OpenBSD on a PINE64 ROCK64 media board by Johannes Krottmayer is licensed under CC BY 4.0