Saturday, 22 June 2013

Netbooting Minix on the BeagleBone Black

This guide will cover how to setup booting Minix on the BeagleBone Black over a wired network. Before you begin, you need to gather some hardware. You'll need a hub or a switch, 2 ethernet cables, a BeagleBone Black, and a server/development machine (it's easier if these are both are the same machine). The first step is to build Minix.

You'll need some sort of Linux or Unix-like system to build Minix. The system should have at least the following tools installed: git, bash, sfdisk, mcopy, dd, wget, mkfs.vfat, make, and a C compiler. Once you've got the tools installed, the next step is to get the source code from my minix-i2c repository on github and checkout the i2c branch.

cd $HOME
git clone git://
cd minix-i2c
git checkout i2c
echo "BASE_URL=" > .settings
echo "FLAG=-DAM335X" >> .settings
echo "CONSOLE=tty00" >> .settings
There is one option you have to add to tell u-boot to boot over the network. Edit $HOME/minix-i2c/releasetools/ (add a -n to the line). That line should end up looking like this:
./releasetools/ -n > ${IMG_DIR}/uEnv.txt
Build an SD card image.
Insert your SD card into your SD card reader/writer. Check the output of `dmesg` to see which device file it was mapped to. If you aren't paying attention here, you could write the SD card image to your hard drive by accident, destroying your partition table and boot sector in the process. If your card had file systems on it previously and your computer auto-mounted them, you should unmount them all after backing up any files you wish to keep. Then, write the image to the SD card with dd using the command below, changing /dev/sdX to match the device file for the SD card.
dd if=minix_arm_sd.img of=/dev/sdX bs=1M oflag=direct
While the card is being written, you can setup the network and the server. Apply power to the hub or switch and connect an ethernet cable to it from the server computer and the BeagleBone Black.

The following instructions are for Gentoo Linux, but there aren't a lot of Gentoo specific commands here. The package installation will be different for different distributions as well as network configuration.

While there are several tftp servers to choose from, I prefer dnsmasq. dnsmasq is easy to configure and provides a lot of other useful services (dns, dhcp, ...), so I chose that one. The built-in tftp and dhcp servers need to be enabled at build time. In Gentoo, you do that by setting tftp and dhcp USE flags in /etc/portage/make.conf:
USE="tftp dhcp"
Then install dnsmasq:
emerge dnsmasq
In the configuration, I chose the network for no other reason than the default configuration for Minix's netboot is designed around that network. The settings can be changed in releasetools/ if you really want something else, but that just adds more steps and potential traps.

The next step is to configure dnsmasq. Set interface to the ethernet interface connected to your netboot network. Optionally set the dhcp pool range if you want to enable dhcp. Finally, enable TFTP and point it to the object directory. It should be called obj.evbearm-el and be placed one level above the Minix source directory (in this case, $HOME/obj.evbearm-el). My /etc/dnsmasq.conf looks like this:

# Listen only to this interface

# Enable DHCP server and define the range of addresses in the pool

# Enable the TFTP server and set the root directory.
Configure the ethernet interface connected to your network. Again, the IP address was chosen because it's the default for Minix netboot and I didn't want to mess with the defaults. On Gentoo, add the following line to /etc/conf.d/net
config_eth0=" netmask brd"
Configure the init system to bring up the NIC and dnsmasq at boot as well as right now.
ln -s /etc/init.d/net.lo /etc/init.d/net.eth0
/etc/init.d/net.eth0 start
rc-update add net.eth0 default
/etc/init.d/dnsmasq start
rc-update add dnsmasq default
Now take your MicroSD card and insert it into the MicroSD card slot on the bottom side of the BeagleBone with the label facing up, pads facing down. Next, attach the FTDI USB-Serial Cable. Be sure you're using the 3.3V version of the cable, and also be sure that it's oriented correctly. Pin 1 is marked on the board with a white dot, it's closer to the ethernet connector than the MicroSD card slot. Pin 1 on the connector is marked with a small arrow and the insulator of the wire going to pin 1 should be black. Now plug the USB side of the USB-Serial cable into your computer. The driver should be loaded automatically. Use `dmesg` or `ls /dev/ttyUSB*` to see what device file to use in the next step. It will most likely be /dev/ttyUSB0 unless you have other USB to Serial adaptors plugged in. You can use pretty much any terminal program. I use picocom for no particular reason other than it is the first one I tried, and it worked. Most programs have the proper default settings except for the baud rate which needs to be set to 115200 BAUD. Here's how to invoke picocom:
picocom -b 115200 /dev/ttyUSB0
The final step, once the terminal program is running, is to plug in the BeagleBone to a power supply. This should cause it to start booting. It will default to the MicroSD card, read the netboot configuration, and should start netbooting Minix automatically. There will be some output from the bootloader and eventually Minix will start loading via TFTP. Here's a snippet of some of the output:
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server; our IP address is
Filename 'kernel.bin'.
Load address: 0x80200000
Loading: #################
     1.2 MiB/s
Eventually, you'll be presented with a login prompt. The default login is "root" with no password. That will give you a shell where you can issue commands. As the project progresses, I'll be making posts explaining how to get started with i2c on Minix. When you're done, you can issue the `halt` command. Minix will stop itself and print a message saying that it's okay to turn off the computer. At this point, you can remove the power supply and unplug the USB cable from your computer.

No comments:

Post a Comment