Thursday 20 June 2013

Minix on the BeagleBoard-xM

Previously I posted about running Minix on the BeagleBone Black (1, 2, 3) and inside a Linaro QEMU virtual machine. Today I'm writing about getting Minix up and running on the BeagleBoard-xM.

You'll obviously need a BeagleBoard-xM for this. In addition to that, you'll need a way to connect to the xM's serial port. If you have an older computer with a serial port, a serial cable will do. Otherwise, you'll need a USB to Serial cable. This will enable you to connect your development machine to the BeagleBoard-xM's serial port via USB. With almost any terminal program you'll be able to interact with the Minix command line interface. While you can power the BeagleBoard-xM over USB, it may be more convenient (and more reliable) to just get an AC adaptor and plug it into mains power. The adaptor I link to below has clips with different prongs for connecting to outlets in different countries. Choose the right one for your country. Lastly, you'll need an SD card with at least 2GB of storage. Fortunately, one comes with the xM.

Shopping List:
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://github.com/tcort/minix-i2c.git
cd minix-i2c
git checkout i2c
The next steps of building a cross compiler, cross compiling Minix, and creating an SD card image have been automated. You just need to set a few environment variables and run a script.

echo "BASE_URL=http://www.minix3.org/arm/beagleboard-xm" > .settings
echo "FLAG=-DDM37XX" >> .settings
echo "CONSOLE=tty02" >> .settings
./releasetools/arm_sdimage.sh
After a lot of compiling, you'll be left with an image file in the current working directory named minix_arm_sd.img

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. Then, write the image to the SD card with dd.
dd if=minix_arm_sd.img of=/dev/sdX bs=1M oflag=direct
After several minutes or more, dd will finish and you can remove the card. I'm not sure if it makes a difference or not, but I usually issue the sync command before removing the card just to make sure that all of the data was actually flushed to the card.

The first step is to take your MicroSD card and insert it into the MicroSD card slot on the bottom side of the board with the label facing up, pads facing down. Next, attach the serial or USB to serial cable to your board and your computer. The driver should be loaded automatically if you're using a USB to serial cable. 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 BeagleBoard-xM to a power supply. This should cause it to start booting. It will default to the MicroSD card and should start Minix automatically. 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