Any news on OpenBSD? (Update: it works now)

I read here that a port of OpenBSD to MNT Reform was in progress.

Have there been any advancements in this regard ?

1 Like

also interested. whom do we pay?

not sure about current port status but I know @jcs has one coming as part of this post-crowdfund batch (or at least, so I assume from his tweets a month or two ago) so I imagine there’ll be a writeup and/or patches and/or other updates from him once he has the device

Wondering about this myself… although, not sure how it will happen given the license of the firmware required to run it…
Unless, this is an unofficial port… I think?

Bump. Anyone heard anything about OpenBSD for Reform?

This was posted just now, so there seems to be progress:

Yes, as of last night, it is possible to run OpenBSD on MNT Reform, thanks to the work of bluerise, cinap_lenrek and sigrid.

Currently you need to do some manual steps to try it out, which will be automated further in the future. Here’s a recipe that assumes you are booting your normal system from eMMC. If your Reform is set to boot from SD card, adjust some steps (we can actually make a fully automatic SD card image later, or someone can help out?).

(Edit: swapped step 1 and 2, that way it makes more sense).

1. Get OpenBSD for aarch64

Get an OpenBSD aarch64 image. For testing I used miniroot72.img from Index of /pub/OpenBSD/snapshots/arm64/

And flash it to SD card (you can also go with a USB stick, but haven’t tested for now):

dd if=miniroot72.img of=/dev/sdx status=progress

2. Build and flash our latest u-boot with support for graphical console and keyboard:

git clone https://source.mnt.re/reform/reform-boundary-uboot
cd reform-boundary-uboot
cp mntreform-config .config
./build.sh

This will yield flash.bin. On your Reform, install it on eMMC (Warning: this might make your Reform unbootable from eMMC if something is done wrong, and will need to be recovered via SD card):

echo 0 > /sys/class/block/mmcblk0boot0/force_ro
dd if=flash.bin of=/dev/mmcblk0boot0 bs=1024 seek=33
echo 1 > /sys/class/block/mmcblk0boot0/force_ro

To flash u-boot to an SD card instead, do:

dd if=flash.bin of=/dev/sdx bs=1024 seek=33

(where sdx has to be replaced with your SD card device.)

3. Place a modified DTB file

There’s a hang related to PCIe in the OpenBSD boot process that needs to be fixed. For now, we use a DTB with disabled PCIe. You can download it here: openbsd-support/imx8mq-mnt-reform2.dtb · master · Reform / reform-boundary-uboot · GitLab

Mount the boot partition of your OpenBSD SD card and copy the imx8mq-mnt-reform2.dtb file onto it.

4. Boot it

Reboot your Reform. You should see an MNT logo and some u-boot output. Interrupt the boot process with a keypress. This will get you to the u-boot console.

Perform these steps to load the modified DTB and boot OpenBSD from the SD card (Edit: sorry, kernel and fdt addresses were swapped here):

load mmc 1:1 $fdt_addr_r imx8mq-mnt-reform2.dtb
load mmc 1:1 $kernel_addr_r efi/boot/bootaa64.efi
bootefi $kernel_addr_r $fdt_addr_r 

Normally this can work automatically (because we support distroboot) but we have to manually load the modified DTB for now.

This will launch the OpenBSD bootloader. We have to set a variable so quickly press space when the boot> prompt appears.

Then enter:

set tty fb0

And press enter again to boot.

8 Likes

Has anyone tried this with an sdcard?

I wrote miniroot72.img to /dev/sda, then dd flash.img, then mounted /dev/sda1 and copied the .dtb file.

I can boot and see the uboot console, but openbsd fails to boot with an “invalid device tree” error.

Suggestions?

Sorry, I realize I swapped the arguments to bootefi in my writeup. It should be:

bootefi $kernel_addr_r $fdt_addr_r

It works! Thanks.

Should step 1 be after step 2?

1 Like

Yes, if you put them on SD card, that is true. I will shuffle the steps.

Hope it work on i.MX8MPlus chip set out of the box.

1 Like

May I ask how’s the general performance of OpenBSD on imx8mq? Does Xenocara is in a usable state?

As far as I know the Vivante GC7000 series GPU driver haven’t been port to OpenBSD so there will be no GPU. acceleration and I only found a video about OpenBSD on raspberry pi 4(it’s a 22 second video not a lots of information in it).

Happy new year everyone!

I wanted to reply to Ichika. I tried running the most recent version of OpenBSD, 7.4 on reform following the instructions on this post. It turns out after running syspatch after the first boot, there is a kernel panic on reboot. I’ve detailed the steps in my bug report which can be found here

https://marc.info/?l=openbsd-bugs&m=170189272731225&w=2

if someone can attempt the same steps and see if they get the same results I’m sure it would help to determine if this was an error on my part.

has anyone made any progress with openbsd beyond the above?

Hello fellow MNT enthusiasts!

Some of you might have seen my fedi post, but I spent some time working on getting OpenBSD 7.4 running on my Reform with 2.0 motherboard and iMX8MQ module, and indeed got it running.

Firstly, I want to say that all of the hard work on getting OpenBSD running on Reform was done by other members of this community, I just put things together - bluerise has done a lot of work getting Reform support into mainline u-boot, for example, and was very helpful in helping me understand the current state of things. I’ve also seen sigrid and cinap’s work on 9front referenced in a lot of places, which I also understand was pivotal in improving the u-boot and device trees for Reform as well. So I want to thank everyone involved in that work, also those who I did not mention who worked on it.

So, I’ve been able to boot OpenBSD 7.4 using the stock install74.img file for arm64. The panic on boot mentioned in this thread is due to the older version of u-boot and the way in which the u-boot/UEFI memory map is translated into the OpenBSD page table. Using a newer u-boot with the mainline device tree file fixes this and the page table mapping works correctly. Additionally, it is no longer required to disable NVMe - NVMe works fine.

A non-exhaustive list of things which work:

  • Display
  • Keyboard
  • Trackball
  • Ethernet
  • NVMe storage
  • Full disk encryption

A non-exhaustive list of things which do not work

  • Automatic power-off on shutdown
  • PCIE WiFi card (not detected)
  • Accelerated video & 3D, the u-boot framebuffer is used for video. The performance is pretty good though!

A list of things I haven’t tested yet

  • Inbuilt sound chip
  • Suspend or resume
  • Various sensors
  • Battery level information
  • Building firmware for or flashing various Reform components

To get this booting, the following steps are required. I can share the binary with those who need it or can’t compile u-boot though (maybe ask on IRC). Perhaps MNT will want to host it somewhere also?

Steps:

  • Download arm64 install74.img from cdn.openbsd.org
  • Write it to an SD card
  • Clone the mnt branch of bluerise’s u-boot repo with git clone -b mnt https://github.com/bluerise/u-boot
  • Also clone the mnt boundary uboot repo with git clone https://source.mnt.re/reform/reform-boundary-uboot somewhere, as you’ll need the binary blobs for DDR training, and the bl31 binary.
  • Copy *.bin from the reform-boundary-uboot repo into the u-boot directory which you cloned from bluerise’s project
  • Switch to the mainline/bluerise u-boot project checkout directory
  • Run ln -s bl31-iMX8MQ.bin bl31.bin to make sure u-boot knows how to find the bl31 binary. There’s probably a more elegant way to handle this.
  • Apply the patch from commit cff1714a875a94ca483a69ad1a3c39bff2dab3a2 from reform-boundary-uboot to your checkout of bluerise’s u-boot source. This allows modifier keys (shift, for example) to work in u-boot and the OpenBSD bootloader. I’m working out how best to handle this patch so we can either mainline it or no longer need it. Maybe some changes to the keyboard firmware are possible.
  • Make sure you have the dependencies installed for building u-boot, documented here
  • Run make imx8mq_reform2_defconfig, you can also tweak the config if you like
  • I cross-compiled, so I ran ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- make flash.bin - but CROSS_COMPILE will vary a little based on which aarch64 compiler you have installed. If you compile natively on arm64, you don’t need ARCH or CROSS_COMPILE specified.
  • You should have a flash.bin now, so write it to the SD card with dd if=flash.bin of=/dev/<name of your SD card device> bs=1k seek=33
  • Install the SD card in your reform (assuming you have the boot switch set to SD) and you should be presented with u-boot, which will boot into the OpenBSD bootloader. Interrupt the OpenBSD bootloader and type “set tty fb0”, then press enter to boot the installer.
  • Install OpenBSD as normal, you should be able to install to NVMe without issue. Full disk encryption also works, as well as unlocking the disk in the bootloader.
  • At the end of the install, don’t select reboot, instead choose shell. In the shell run echo "set tty fb0" > /mnt/etc/boot.conf to make sure the framebuffer console is used on boot

Please feel free to let me know if you have any questions. I’ll continue to test & work on various improvements as I can. I hope this information helps someone.

3 Likes

Hi everyone, we’re in the process of rebasing this on the latest mainline u-boot, so if you check out bluerise’s current mnt branch it won’t work, there’s an issue with the OpenBSD bootloader detecting/reading the NVMe and booting the installer. For now, you can use the pre-compiled image here if you want to give this a try.

1 Like

another update, bluerise has kindly reverted the mnt branch so the above instructions for building should work again.

1 Like

thanks for this effort!

following this method i can boot to an install prompt, but my nvme (and wifi) is not detected.

http://mnt.stanleylieber.com/reform/openbsd/dmesg

1 Like

Update 2024/02/07: I’ve made this a lot simpler and @minute has been kind enough to set up a project on source.mnt.re so no manual patching and binary blob copying is needed. Also, PCIe WiFI is working with a simple device tree patch to enable the second PCIe port.

A non-exhaustive list of things which work:

  • Display
  • Keyboard
  • Trackball
  • Ethernet
  • NVMe storage
  • Full disk encryption
  • PCIe WiFi (I have tested AR9280)

A non-exhaustive list of things which do not work

  • Automatic power-off on shutdown
  • Accelerated video & 3D, the u-boot framebuffer is used for video. The performance is pretty good though!

A list of things I haven’t tested yet

  • Inbuilt sound chip
  • Suspend or resume
  • Various sensors
  • Battery level information
  • Building firmware for or flashing various Reform components under OpenBSD

I’m working on setting up a CI build for the flash.bin and a pre-patched OpenBSD install image. For now, the instructions to build a flash.bin and install OpenBSD are below:

Steps:

  • Download arm64 install74.img from cdn.openbsd.org
  • Write it to an SD card
  • Clone the main branch of the reform-openbsd repo with git clone https://source.mnt.re/reform/reform-openbsd
  • Make sure you have the dependencies installed for building u-boot, documented here
  • Run make imx8mq_reform2_defconfig, you can also tweak the config if you like
  • I cross-compiled, so I ran ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- make flash.bin - but CROSS_COMPILE will vary a little based on which aarch64 compiler you have installed. If you compile natively on arm64, you don’t need ARCH or CROSS_COMPILE specified. There is a nix.shell file if you use NixOS to compile, you can run nix-shell to get a shell with the right deps.
  • You should have a flash.bin now, so write it to the SD card with dd if=flash.bin of=/dev/<name of your SD card device> bs=1k seek=33
  • Install the SD card in your reform (assuming you have the boot switch set to SD) and you should be presented with u-boot, which will boot into the OpenBSD bootloader. Interrupt the OpenBSD bootloader and type “set tty fb0”, then press enter to boot the installer.
  • Install OpenBSD as normal, you should be able to install to NVMe without issue. Full disk encryption also works, as well as unlocking the disk in the bootloader.
  • At the end of the install, don’t select reboot, instead choose shell. In the shell run echo "set tty fb0" > /mnt/etc/boot.conf to make sure the framebuffer console is used on boot
4 Likes