Find all your DIY electronics in the MakerShed. 3D Printing, Kits, Arduino, Raspberry Pi, Books & more!

Beagle Board Trainer

The Beagle Board Trainer from Tin Can Tools is a nifty daughterboard for the Beagle Board, offering level shifters for the built-in outputs such as GPIO, I2C, and SPI. This enables you to talk to 3.3v and 5v devices (the Beagle Board works with 1.8v signaling). Tin Can Tools sent me a Trainer board to take out for a spin.

My favorite part of the Beagle Board Trainer is the built-in Arduino-compatible subsystem. It’s got an ATMega328 loaded up with the Arduino bootloader, all of the standard Arduino pins exposed, and you can talk to it over the Beagle Board’s second serial UART (/dev/ttyS1).

Setting up the Trainer and the Beagle Board
I soldered some female headers onto the Trainer so I could stuff wires and components in and play with them, then I assembled the Trainer as directed in the Embedded Linux Wiki. Once I had the Trainer and Beagle Board connected, I was ready to install my kernel and root file system.

Although I use a Mac for day-to-day work, I keep a Linux virtual machine handy for projects whose instructions assume (or require) access to a Linux system. I use VMware Fusion, but this should work equally well with Parallels or the free VirtualBox on Mac or Windows. It might be possible to do this without a virtual machine, but it does require you to format an SD card with the ext2, which is tricky on a non-Linux system.

I followed the instructions to create a bootable SD card. To connect my SD card to my Linux virtual machine, I unmounted it in Mac OS X and went back to VMware, where I selected Virtual Machine→USB→Connect Apple Internal Memory Card Reader. Once I did that, I was able to access my SD card from Linux as though it were connected to a real machine.

My Beagle Board wouldn’t boot correctly until I followed the steps from another set of instructions on Setting up the boot args. Once I did this, everything worked OK.

Sending Arduino Sketches to the Beagle Board
Now that I had a working Beagle Board connected to the Trainer, I had to figure out how to load an Arduino sketch onto it. The tricky part was figuring out how to generate a .hex file from Arduino. The Arduino IDE normally generates this in the course of loading it to your Arduino board, but it doesn’t leave the .hex file laying around.

I used Martin Oldfield’s instructions and Makefile for using Arduino from the command line. I opened the Arduino Fade example in the Arduino IDE (File→Examples→1.Basics→Fade) and saved it to my Arduino directory. Because the GND pin on the Trainer is so far from the Arduino-compatible pins, I added a couple of lines to Fade’s setup() routine, which makes pin 10 a ground pin:

pinMode(10, OUTPUT);
digitalWrite(10, LOW);

Next, I created a Makefile that looked like this and put it in the sketch directory (/Users/bjepson/Documents/Arduino/Fade on my computer). You may need to change the setting of ARDUINO_DIR, and you will need to change the last line that starts with include:

ARDUINO_DIR = /Applications/Arduino.app/Contents/Resources/Java

TARGET       = Fade
MCU          = atmega328p
F_CPU        = 16000000
ARDUINO_PORT = /dev/cu.usb*
ARDUINO_LIBS = LiquidCrystal

include /Users/bjepson/src/arduino-mk-0.4/Arduino.mk

Then I went into the Terminal, used cd to change to the sketch directory, and typed make. When I was done, there was a file called Fade.hex in the build-cli subdirectory. I powered down the Beagle Board, put the SD card back in my computer, and copied Fade.hex to the root of the root file system. I also copied the avrgal binary, which is a lightweight alternative to avrdude. I unmounted the SD card, plugged it back into the Beagle Board, and powered the Beagle Board up again. After it started up, I logged in as root, used cd to switch to the directory where I copied avrgal and Fade.hex, then ran this command as I pressed the reset button next to the ATMega328 (not the Beagle Board’s reset button): ./avrgal Fade.hex. Here’s the output I saw:

Uart port used                      : /dev/ttyS1
Autodetect for Fade.hex             : Intel Hex
Acquire SYNC with AVR               : Passed
Uploading and writing to flash      : Passed

When I was done, I connected an LED to pin 9 (the positive, longer lead) and to pin 10 (negative lead). The LED faded just like it should. Now I’ve got a low-power Linux system with an Arduino-compatible peripheral hardwired to it. There are a lot of possibilities with that combo.

Brian Jepson

I’m a tinkerer and finally reached the point where I fix more things than I break. When I’m not tinkering, I’m probably editing a book for Maker Media.


Related

In the Maker Shed