guest

OpenBSD on BeagleBone Black

Everything I wish I knew before installing the newly renamed armv7 port on a BeagleBone Black.

prep

First, all the assorted hardware you need. The devkit (includes one USB cable for power). The magic USB serial cable. A micro SD card. A powered USB port (I used an old cell phone charger, but there’s some talk of dedicated 5v power supplies working better). Network cable. An OpenBSD PC.

The installation takes a while and you may screw it up, so you probably want to download the OpenBSD sets locally first. This subsequently saved me quite a bit of time. (I use thttpd as a quick server I can run with no config as any user: thttpd -d . -p 8000 will serve the current directory.)

Copy the miniroot fs image onto the SD card using another PC. Somewhat confusingly, the fs image for the Black is not the beagle.fs image, it’s miniroot-am335x-55.fs. sudo dd if=miniroot-am335x-55.fs of=/dev/rsdXc bs=16k (Change the X.)

Put the SD card in the slot and connect all the cables. The serial cable has a tiny arrow on it lined up with the black wire. That wire connects with the pin that has a white dot next to it, closest to the 5v power port. I used the switch on my power strip to control on/off.

Connect to the serial port. sudo tip -115200 /dev/ttyU0. Turn it on and prepare to be blinded by some retina piercing blue LED lights. It should print a whole bunch of stuff on the console and it will eventually land at a login for the preinstalled Linux system. Just checking it works. Turn it off, then turn it back on holding down the tiny button next to the SD slot. It’s really tiny, but it makes a click if you apply the right amount of pressure, like with a fingernail. This should boot from the SD card into the OpenBSD installer.

SD install

The OpenBSD installer is the OpenBSD installer. The trickiest part is realizing that the SD card is sd0 and the internal 2GB flash is sd1. A typical OpenBSD install will probably go onto the SD card, so you can pick sd0. By default the X sets aren’t selected. I’d leave it that way, at least for now. Writing to the SD card is painfully slow, so it’s best to get the system up and running first, then consider installing X later. Once you boot from the SD card, that becomes the default, so future boots will go right into OpenBSD without holding the button.

Be careful about jostling the USB cable. I knocked it loose from my laptop, which sends a break signal, landing in DDB. After continuing, the network interface was extremely unhappy because it missed an interrupt or something (surmising). I had to start over from the beginning, copying a new miniroot onto the SD.

internal install

On the next install, I decided I wanted to run OpenBSD off the internal flash. There are some gotchas here. In the installer, pick sd1. When it’s all over, remove the SD card and reboot. This will probably land you back in the ramdisk installer. What? Exactly. A typical OpenBSD install includes the ramdisk kernel as a way to upgrade or make repairs. But why is it booting by default? Into the rabbit hole.

Now we have to deal with uboot, the “BIOS” of the BeagleBone Black. It’s weird and buggy and pretty user hostile.

The way uboot picks what kernel to load is by reading a file called uenv.txt from a FAT partition. Unfortunately, the OpenBSD installer puts some faulty instructions in there, hard coding boot from SD, and then uboot falls back to default behavior when it doesn’t work, picking a file seemingly at random (alphabetically first?). We need to fix the uenv.txt file, but first we need to get into a real OpenBSD install.

Reboot and watch for the chance to hit any key to stop autobooting. You only have about one second, so be quick. Now you’re at the uboot prompt. We need to run two commands.

U-Boot# fatload mmc 1 ${loadaddr} bsd.umg U-Boot# bootm ${loadaddr}

This should boot the normal kernel. It will ask for the root device. Enter sd0. Note the zero now. Boot proceeds. When you login, mount the FAT partition. mount /dev/sd0i /mnt and edit the /mnt/uenv.txt file. Find the fatload mmc 0 command and change the 0 to a 1. That’s it. Save and reboot.

A few notes on other complications. The OpenBSD kernel can’t see the SD card unless it’s present at boot, and so the internal flash takes over as sd0. If I put the SD card back and reboot, then uboot tries to boot from it. Haven’t figured out which setting it is to change that yet. In the meantime, I’m mounting /home via NFS, which is twice as fast as flash (SD and flash perform the same) and provides even more space, should I want it. Also I have another SD card to put in my camera now.

netboot

uboot also supports netbooting. It’s actually a little easier to configure then pxeboot, I think, because it doesn’t require fiddling with dhcpd.conf. First I copied the bsd.rd.OMAP.umg file to /tftproot on my DHCP server (which also runs tftpd). Hit enter when you get a chance to stop autoboot. Then we run these two commands.

U-Boot# dhcp ${loadaddr} bsd.rd.OMAP.umg U-Boot# bootm

And away we go.

Posted 2014-01-25 17:41:47 by tedu Updated: 2014-02-09 21:11:09
Tagged: gadget openbsd