OpenBSD on Pine A64

Install OpenBSD

Install miniroot64.fs on a SD card from ThinkPad x201i (OpenBSD) which includes a SD card port. Note that you will need a microSD to SD card adapter.

wget https://ftp.eu.openbsd.org/pub/OpenBSD/6.2/arm64/miniroot62.fs
dd if=miniroot62.fs of=/dev/rsd1c bs=1m

Connect over serial console using USB to serial TTL converter.

Connect it as follows.

pine_console.png

And connect from laptop as follows. Check which port using dmesg.

cu -l cuaU0 -s 115200

Ethernet Problem

It seems that ethernet isn't working with existing u-boot.

U-Boot 2017.11 (Dec 02 2017 - 03:51:46 -0700) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: Pine64
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   No ethernet found.
starting USB...
USB0:   USB EHCI 1.00
USB1:   USB OHCI 1.0

It should say somethink like

...
Net:   phy interface7
eth0: ethernet@01c30000
starting USB...

Seems to be a difference between Pine64 (Realtek 8201FN) and Pine64+ (Realtek 8211E).

Trying a Linux image

Try the minimal supported Ubuntu based image

wget https://github.com/ayufan-pine64/linux-build/releases/download/0.6.2/xenial-minimal-pine64-bspkernel-0.6.2-77.img.xz
xz --decompress xenial-minimal-pine64-bspkernel-0.6.2-77.img.xz
doas dd if=xenial-minimal-pine64-bspkernel-0.6.2-77.img of=/dev/rsd1c bs=1m

Doesn't find device tree. Try another image ...

gunzip xubuntu-xenial-mate-20161215-longsleep-pine64-8GB.img.gz
doas dd if=xubuntu-xenial-mate-20161215-longsleep-pine64-8GB.img of=/dev/rsd1c bs=1m

Ethernet works with xubuntu image, but its not up to date. Try Arch ...

xz --decompress archlinux-xfce-pine64-20171225-1.img.xz
doas dd if=archlinux-xfce-pine64-20171225-1.img of=/dev/rsd1c bs=1m

Arch halts on boot ...

OpenBSD 6.3 should work!

pine64 - works well!

Is it only the difference in pine64 and pine64+ or is it something else.

Possible hardware issues

See armbian on pine64 / Armbian running on Pine64

Raspian

Download raspian server edition

Unzip and check checksum.

7z e Armbian_5.38_Pine64_Ubuntu_xenial_default_3.10.107.7z
sha256 Armbian_5.38_Pine64_Ubuntu_xenial_default_3.10.107.img
cat sha256sum.sha

Write image file to SD card.

doas dd if=Armbian_5.38_Pine64_Ubuntu_xenial_default_3.10.107.img of=/dev/rsd1c bs=1m

Boot from SD. This is the first version that seems to work fine!

DietPi

Try this new options at some point DietPi Images

Install OpenBSD 7.3 on Pine64

Finally I had some success on OpenBSD on the old Pine A64 board.

Looking at the main resource, INSTALLATION NOTES for OpenBSD/arm64 7.3 you should do as follows.

First install miniroot file system. Assuming sdcard is installed to OpenBSD box and enumerated as sdX (X is typically 1).

dd if=miniroot73.img of=/dev/rsdXc bs=1m

miniroot73.img you can get from any mirror e.g. https://ftp.eu.openbsd.org/pub/OpenBSD/7.3/arm64/.

But then we have the problem with a suitable flattened device tree (FDT).

The miniroot has a few default FDT's, but they only support Raspberry Pi's.

You can understand this if you mount the sdcard after miniroot has been written to it.

mount /dev/sd1i /mnt/

You will see a number .dtb files, but only for Raspberry Pi.

So we will have to "Add a board specific DTB file". But where do you get them?

Following on "first install the u-boot-aarch64 and dtb packages" ...

pkg_add u-boot-aarch64
pkg_add dtb

After that different sample .dtb files will be available on your development machine.

mount /dev/sd1i /mnt/
mkdir /mnt/vendor
cp /usr/local/share/u-boot/board/u-boot-sunxi-with-spl.bin /mnt/vendor

I think its very unclear to see how u-boot select a suitable .dtb file.

Raspberry Pi files were placed directly in root. But I also added to these places ...

/mnt/dtbs/vendor
/mnt/dtb/current/vendor
/mnt/dtb/current

But before this we need to install u-boot itself. This is just described as a dd command.

dd if=/usr/local/share/u-boot/board/u-boot-sunxi-with-spl.bin of=/dev/sdXc bs=1024 seek=8

But under /usr/local/share/u-boot/ there is only pine64-lts and pine64_plus and I have the original pine64 so which to choose?

I also tried NetBSD version ...

mkdir netbsd
cd netbsd 
wget http://netbsd.ftp.fu-berlin.de/pub/NetBSD/pkgsrc/packages/NetBSD/amd64/9.1/All/u-boot-pine64-2018.11nb5.tgz
tar xzf u-boot-pine64-2018.11nb5.tgz
cd ..

There you have

netbsd/share/u-boot/pine64/u-boot-sunxi-with-spl.bin

Also with-spl means that u-boot includes a first bootloader (SPL) which is needed to boot u-boot itself.

Another very confusing thing is that u-boot is written directly to the sd-card image (seek=8). This is because board boot process expects boot to be located at this specific address.

With OpenBSD variant

doas dd if=/usr/local/share/u-boot/pine64_plus/u-boot-sunxi-with-spl.bin of=/dev/sdXc bs=1024 seek=8

With NetBSD variant

doas dd if=netbsd/share/u-boot/pine64/u-boot-sunxi-with-spl.bin of=/dev/sdXc bs=1024 seek=8

Not sure which I used in the end. Unmount sdcard and try to boot from sdcard on Pine64 ...

umount /mnt

I thinks its very unclear during boot how FDT files are searched and possibly selected during u-boot.

But its possible to do some debugging during boot. Press any key during boot to get to u-boot prompt.

Then you may do some debugging

=> help
=> env print

I finally realized that ftdfile could be forced.

=> fatls mmc 0:1 /
=> env set fdtfile /sun50i-a64-pine64.dtb
=> boot

This finally worked out and OpenBSD could be installed.

Take a look at this forum thread for some general explanations.

First reboot after successful install of OpenBSD 7.3.


Exit to (S)hell, (H)alt or (R)eboot? [reboot] 
syncing disks... done
rebooting...

U-Boot SPL 2021.10 (Feb 11 2023 - 18:47:12 -0700)
DRAM: 2048 MiB
Trying to boot from MMC1
NOTICE:  BL31: v2.7(debug):2.7.0
NOTICE:  BL31: Built : 18:06:17, Feb 11 2023
NOTICE:  BL31: Detected Allwinner A64/H64/R18 SoC (1689)
NOTICE:  BL31: Found U-Boot DTB at 0x2098c70, model: Pine64+
INFO:    ARM GICv2 driver initialized
INFO:    Configuring SPC Controller
INFO:    PMIC: Probing AXP803 on RSB
INFO:    PMIC: dcdc1 voltage: 3.300V
INFO:    PMIC: dcdc5 voltage: 1.360V
INFO:    PMIC: dcdc6 voltage: 1.100V
INFO:    PMIC: dldo1 voltage: 3.300V
INFO:    PMIC: dldo2 voltage: 3.300V
INFO:    PMIC: dldo4 voltage: 3.300V
INFO:    PMIC: fldo1 voltage: 1.200V
INFO:    PMIC: Enabling DC SW
INFO:    BL31: Platform setup done
INFO:    BL31: Initializing runtime services
INFO:    BL31: cortex_a53: CPU workaround for 843419 was applied
INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
INFO:    BL31: cortex_a53: CPU workaround for 1530924 was applied
INFO:    PSCI: Suspend is unavailable
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x4a000000
INFO:    SPSR = 0x3c9


U-Boot 2021.10 (Feb 11 2023 - 18:47:12 -0700) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: Pine64+
DRAM:  2 GiB
MMC:   mmc@1c0f000: 0
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... In:    serial
Out:   serial
Err:   serial
Net:   phy interface10
eth0: ethernet@1c30000
starting USB...
Bus usb@1c1a000: USB EHCI 1.00
Bus usb@1c1a400: USB OHCI 1.0
Bus usb@1c1b000: USB EHCI 1.00
Bus usb@1c1b400: USB OHCI 1.0
scanning bus usb@1c1a000 for devices... 1 USB Device(s) found
scanning bus usb@1c1a400 for devices... 1 USB Device(s) found
scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
scanning bus usb@1c1b400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0 
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Scanning disk mmc@1c0f000.blk...
Found 3 disks
No EFI system partition
BootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootaa64.efi
214136 bytes read in 14 ms (14.6 MiB/s)
Booting /efi\boot\bootaa64.efi
disks: sd0*
>> OpenBSD/arm64 BOOTAA64 1.16
boot> 
booting sd0a:/bsd: 10397372+2488344+294060+837636 [792814+91+1207920+723433]=0x11ad960
[ using 2725040 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
	The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2023 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 7.3 (GENERIC.MP) #2080: Sat Mar 25 14:20:25 MDT 2023
    deraadt@arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/GENERIC.MP
real mem  = 2027786240 (1933MB)
avail mem = 1930911744 (1841MB)
random: good seed from bootblocks
mainbus0 at root: Pine64
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: 512KB 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: 512KB 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: 512KB 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: 512KB 64b/line 16-way L2 cache
cpu3: CRC32,SHA2,SHA1,AES+PMULL,ASID16
efi0 at mainbus0: UEFI 2.8
efi0: Das U-Boot rev 0x20211000
smbios0 at efi0: SMBIOS 3.0
smbios0: vendor U-Boot version "2021.10" date 10/01/2021
smbios0: Unknown Unknown Product
apm0 at mainbus0
"display-engine" at mainbus0 not configured
"opp-table-gpu" at mainbus0 not configured
"osc24M_clk" at mainbus0 not configured
"osc32k_clk" at mainbus0 not configured
"pmu" at mainbus0 not configured
simpleaudio0 at mainbus0
agtimer0 at mainbus0: 24000 kHz
simplebus0 at mainbus0: "soc"
sxisyscon0 at simplebus0
sxisid0 at simplebus0
sxiccmu0 at simplebus0
sxipio0 at simplebus0: 103 pins
sxitwi0 at simplebus0
iic0 at sxitwi0
ampintc0 at simplebus0 nirq 224, ncpu 4 ipi: 0, 1, 2: "interrupt-controller"
sxirtc0 at simplebus0
sxiccmu1 at simplebus0
sxipio1 at simplebus0: 13 pins
sxirsb0 at simplebus0
axppmic0 at sxirsb0 addr 0x3a3: AXP803
"bus" at simplebus0 not configured
"dma-controller" at simplebus0 not configured
"lcd-controller" at simplebus0 not configured
"lcd-controller" at simplebus0 not configured
"video-codec" at simplebus0 not configured
sximmc0 at simplebus0
sdmmc0 at sximmc0: 4-bit, sd high-speed, mmc high-speed, dma
"crypto" at simplebus0 not configured
"mailbox" at simplebus0 not configured
"usb" at simplebus0 not configured
"phy" at simplebus0 not configured
ehci0 at simplebus0
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 simplebus0: version 1.0
ehci1 at simplebus0
usb1 at ehci1: USB revision 2.0
uhub1 at usb1 configuration 1 interface 0 "Generic EHCI root hub" rev 2.00/1.00 addr 1
ohci1 at simplebus0: version 1.0
"timer" at simplebus0 not configured
sxidog0 at simplebus0
"dai" at simplebus0 not configured
"codec" at simplebus0 not configured
sxitemp0 at simplebus0
com0 at simplebus0: dw16550
com0: console
dwxe0 at simplebus0: address 02:ba:e5:48:b7:4b
rgephy0 at dwxe0 phy 1: RTL8169S/8110S/8211 PHY, rev. 5
"gpu" at simplebus0 not configured
"dram-controller" at simplebus0 not configured
"deinterlace" at simplebus0 not configured
"hdmi" at simplebus0 not configured
"hdmi-phy" at simplebus0 not configured
sxirintc0 at simplebus0
"codec-analog" at simplebus0 not configured
gpio0 at sxipio0: 32 pins
gpio1 at sxipio0: 32 pins
gpio2 at sxipio0: 32 pins
gpio3 at sxipio0: 32 pins
gpio4 at sxipio0: 32 pins
gpio5 at sxipio0: 32 pins
gpio6 at sxipio0: 32 pins
gpio7 at sxipio0: 32 pins
gpio8 at sxipio1: 32 pins
usb2 at ohci0: USB revision 1.0
uhub2 at usb2 configuration 1 interface 0 "Generic OHCI root hub" rev 1.00/1.00 addr 1
usb3 at ohci1: USB revision 1.0
uhub3 at usb3 configuration 1 interface 0 "Generic OHCI root hub" rev 1.00/1.00 addr 1
"opp-table-cpu" at mainbus0 not configured
"hdmi-connector" at mainbus0 not configured
scsibus0 at sdmmc0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0: <SD/MMC, SS16G, 0080> removable
sd0: 15193MB, 512 bytes/sector, 31116288 sectors
vscsi0 at root
scsibus1 at vscsi0: 256 targets

TODO

U-boot still seems wrong because it believes that it is a Pine A64+ with 2GB RAM.

I think this is a Pine A64 with 0.5 GB RAM which is specified with old u-boot tried before with OpenBSD 6.4.

U-Boot 2017.11 (Dec 02 2017 - 03:51:46 -0700) Allwinner Technology

CPU:   Allwinner A64 (SUN50I)
Model: Pine64
DRAM:  512 MiB

So I think I need to find another u-boot and/or FDT file to fix this ...

But from Pine64 the same u-boot might work

Mainline U-Boot

The board is fully supported since v2017.07. Use the pine64_plus_defconfig target to build a U-Boot image. 
This includes support for the 512MB "non-plus" version, which will be detected at runtime. 
You need an ARM Trusted Firmware build (bl31.bin, see below), which will be included in the FIT image.

Trying to build my own u-boot as well ...

General build/install instructions for u-boot

https://u-boot.readthedocs.io/en/latest/build/gcc.html#prerequisites

Board specific tools needed for Pine64: binman and crust (optional)

https://u-boot.readthedocs.io/en/latest/board/allwinner/sunxi.html

Finally, to build u-boot for pine64(+) ...

make pine64_plus_defconfig
CROSS_COMPILE=aarch64-linux-gnu- make

References