Running OpenBSD 7.8 on ODROID HC4
809 words, 4 minutes
Some times ago, I acquired an ODROID HC4 arm64 board and installed OpenBSD 7.2 on it. I used it for a moment but there were issues when running with two disks so I stopped using it.
For $reasons, I took it out of its box and gave it another try using OpenBSD 7.8.
The board is used with an USB keyboard and an HDMI moniter plugged in. You don’t really need it for daily usage but installation is easier this way - if you don’t have serial console cable.
Removing Petitboot
The board comes with Petitboot. But OSes seem to expect u-boot and it’s always a problem to have Petitboot installed. So I just wipe it out.
From the Petitboot prompt, select “Exit to shell” and type the
following commands:
# flash_eraseall /dev/mtd0
# flash_eraseall /dev/mtd1
# flash_eraseall /dev/mtd2
# flash_eraseall /dev/mtd3
Turn the HC4 off and proceed to assembling the OpenBSD installation media.
PS: The Petitboot restore procedure is still valid ; in case it is needed.
Building u-boot
The OpenBSD installer won’t boot on the card as-is. There is a need to
add u-boot to the installer image. I used to use the one available
here
but now that I understood how to build a more recent one, I choose to do
so.
<sidenote>
BTW, if you need up-to-date Linux stuff for this card, this
website
is a
golden mine. Thanks a lot Johan.
</sidenote>
From a Debian GNU/Linux instance, install the development tools, grab
and compile the sources, and generate the u-boot.bin.sd.bin file.
# apt install -y git build-essential \
bison flex gcc-aarch64-linux-gnu \
libssl-dev libgnutls28-dev
# git clone https://source.denx.de/u-boot/u-boot
# cd u-boot
# make CROSS_COMPILE=aarch64-linux-gnu- odroid-hc4_defconfig
# make CROSS_COMPILE=aarch64-linux-gnu- -j$(nproc)
# git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
# cd amlogic-boot-fip
# mkdir my-output-dir
# ./build-fip.sh odroid-hc4 ../u-boot.bin my-output-dir
# file my-output-dir/u-boot.bin.sd.bin
my-output-dir/u-boot.bin.sd.bin: data
I choose to use Johan Gunnarsson’s sources rather than the one from Hardkernel just because he provides more recent ones.
Transfer the u-boot.bin.sd.bin to the system you’ll use to write the
OpenBSD installer. I’m keeping a backup copy of that file
here
in case in doesn’t build in the
future.
Preparing the OpenBSD installer
The official installer media has to be updated to boot using the
relevant u-boot stuff that was just built. I also modify it to use the
HDMI output rather than the serial console. I write the installer to an
SD-card as neither the USB port, nor the SATA ones work for installation.
# doas dd if=miniroot78.img of=/dev/rsd2c bs=1M
# doas dd if=u-boot.bin.sd.bin of=/dev/rsd2c bs=512 skip=1 seek=1
# doas dd if=u-boot.bin.sd.bin of=/dev/rsd2c bs=1 count=444
# doas mount /dev/sd2a /mnt
# doas mkdir /mnt/etc
# doas sh -c 'echo "set tty fb0" > /mnt/etc/boot.conf'
# doas umount /mnt
Now that the installer is ready, stick the SD-card in the HC4 and power it up.
Installing OpenBSD
The OpenBSD installer proceeds as usual.
Regarding install destination, I could neither choose the eMMC, nor the SD-card. The only working option is a SATA disk. I have plugged an old 128GB SATA SSD that works well enough and don’t use that many watts.
I noticed that the installer defaults to MBR. This works with disks up to 2TB. With bigger disks, GPT would be required.
When installation is done, don’t halt or reboot the machine but “Exit to (S)hell” and configure the usage of the HDMI; unless you have a
serial console adapter ;-)
# echo "set tty fb0" > /mnt/etc/boot.conf
# halt -p
Then, turn the HC4 off.
As the board doesn’t know how to boot from the SATA disks and we have
wiped out Petitboot, a u-boot instance is required to boot OpenBSD.
The SD-card that was used to install OpenBSD can now be turned into a
simple u-boot device.
Take the SD-card that ran the installer and wipe it off by writing the
whole u-boot.bin.sd.bin file that we build on it.
# doas dd if=u-boot.bin.sd.bin of=/dev/rsd2c
Once plugged back into the HC4, the machine properly boots OpenBSD.
Running OpenBSD
OpenBSD 7.8 seems to support using two disks now, which is great.
Unexpectedly, the first disk (sd0) is the one connected on the “front”
of the case - identified by “CON6B”. The second disk (sd1) is the
one further in the back of the case - identified by “CON6A”. If you
install OpenBSD with a single disk plugged in the back and add another
disk in the front socket later on, boot won’t happen anymore…
When IDLE, with two 2.5" SSD connected, the whole machine uses 6.7W.
When running openssl speed, it uses 6.8W. With a single SSD connected,
this little machine idles at 5W and never went above 6W during an hour
of compiling stuff. Compared to my APU4D4, this board is faster, has
more memory and uses a bit less energy.
🐰 That’s All Folks!