Introduction to BeagleBoard
All those features have to managed by an operating system in order to use them in an efficient way. The best option for BB is Linux, mainly because there is an active project supporting BB which includes working drivers for the features listed above, a good toolchain (GCC based) and many common packages ready to build and install into BB. In this document you will find the steps to get a fully functional Linux running on your BB and an introduction on how to put your own software into BB.
Before you can start, you will need the following items: Power adaptor1 5V (min. 2W) or a standard-A to mini-A USB cable A serial adaptor for the BB A computer with a terminal program such as HyperTerminal or minicom
After that, connect the serial cable to your computer and open a serial terminal, using the following settings: Speed: 115200 bps 8 Bits, 1 Stop bit, No parity No flow control
After that you can power on BB either by using the power adaptor or the USB cable. You should see some messages from the board in your terminal like these:
Texas Instruments X-Loader 1.4.2 (Feb 19 2009 - 12:01:24) Reading boot sector Loading u-boot.bin from nand U-Boot 2009.06-rc2 (Jul 17 2009 - 11:23:49) OMAP3530-GP ES3.0, CPU-OPP2 L3-165MHz OMAP3 Beagle board + LPDDR/NAND DRAM: 256 MB NAND: 256 MiB In: serial Out: serial Err: serial Board revision C Die ID #5ac400030000000004013f8901001001 Hit any key to stop autoboot: 0 OMAP3 beagleboard.org #
If you see these messages in your terminal it means that BB is alive and you are ready to continue,
1 Remember that maximum voltage input is 5.2V so check that your power supply is stable and clean
When you power on the BB you do not get into an operating system directly but into a bootloader as you have just seen. BB comes with a flashed bootloader by default (Texas Instruments X-Loader) which runs automatically the U-Boot environment. This is known as a multi-stage boot. U-Boot can be loaded in many different ways and orders2 as suggested in Illustration 2. U-boot is a basic boot environment that will let you to run the operating system, insert boot arguments, update flash contents with new versions of the bootloader and many more things3.
Linux on BeagleBoard
Linux alone is no more than an operating system kernel, which is an essential piece but not enough to get a fully functional system. You usually will need a shell and a basic toolbox giving you access to functions such as browse directories, read and write files, etc. After that many extra packages can be installed on your file system, even your own software.
First you will need to get the OE metadata from their GIT repository (information, recipes, tools, etc.). Remember that you need to have GIT installed before typing the following commands.
$ export OE_HOME="/path/you/want/for/OE" $ mkdir -p ${OE_HOME} && cd ${OE_HOME} 2 Refer to BeagleBoard Reference Manual, 5.14 3 Refer to Annex 1 Basic operation with U-Boot for detailed information
When you have downloaded all metadata files, you need to set up OE indicating your target board, directory of OE recipes, etc. While inside OE root folder, create a new folder tree:
$ mkdir -p build/conf
Inside conf folder, create a file named local.conf and write these lines:
# Recipes, distro and target board BBFILES = "/path/you/want/for/OE/openembedded/recipes/*/*.bb" DISTRO = "angstrom-2008.1" MACHINE = "beagleboard" # Use N threads (write only if you have a multicore machine) # Change N for the number of your processor cores BB_NUMBER_THREADS = "N" PARALLEL_MAKE = "-j N"
Finally, on your OE root folder, create a file named profile with these lines:
#Paths export OE_HOME=/path/you/want/for/OE export BBPATH=${OE_HOME}/build:${OE_HOME}/openembedded export PATH=${OE_HOME}/openembedded/bitbake/bin:$PATH #Make shell look better.. if [ "$BASH" ]; then export PS1="\[\033[01;32m\]BB:\[\033[00m\] ${PS1}" fi
The profile is a file that is need to be run every time you want to start using OE environment. It basically sets the working directories so OE tools can find all files.
Step 3: Build software using OpenEmbedded
Now you are ready to start building software for your BB using OE configured to use Angstrom distribution. OE uses bitbake as a package builder and manager. Using the previously downloaded recipes, a set of instructions to build a package, it will make everything for you when you need to build a package, even solve dependencies. When you run bitbake for first time it caches all recipes and it downloads a cross-toolchain so it has a cross-compiler to build other packages. The first thing you should build is a base operating system for your BB. In the case of Angstrom, there are 3 options: 6 Base Image: A minimal operating system
Introduction to BeagleBoard Console Image: A basic operating system including some extra tools (ex. networking) X11 Image: An operating system including graphical interface
You can choose whatever you want depending on your needs. First, load the profile (remember to do that every time you start working with OE):
$ source profile
Build process will take a long time (about 6 hour for console-image) as it needs to download many packages from the net and build them. All files involved in build process (sources, logs, object files...) will be placed in tmp folder, and final packages will be normally inside tmp/deploy. Note that you can also build packages alone using bitbake (ex. bitbake -f nano).
Step 4: Format your memory card
Memory card (SD or MMC) is usually partitioned in 2 partitions to use with BB. The first one is a small FAT partition where Linux Kernel will be placed as U-Boot only reads FAT partitions, and a second one formatted with ext2/3 used for the root file system. To format your memory card, first plug it into your computer and to determine drive name, type:
$ dmesg | tail
As you can see, in this case sdc is the drive name. If your memory card has any partition and it is automatically mounted, unmount it before continuing. First, run fdisk to work with your drive name:
$ sudo fdisk /dev/sdc
After that, list all existing partitions and delete them (note that fdisk commands are in brackets):
Command (m for help): [p] Disk /dev/sdc: 2021 MB, 2021654528 bytes
Now create the first partition (FAT32) to allocate the Linux Kernel. A size of 50MB is fine. When it is done, mark it as bootable:
Command (m for help): [n] Command action e extended p primary partition (1-4) [p] Partition number (1-4): [1] First cylinder (1-245, default 1): [(press Enter)] Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-245, default 245): [+50] Command (m for help): [t] Selected partition 1 Hex code (type L to list codes): [c] Changed system type of partition 1 to c (W95 FAT32 (LBA)) Command (m for help): [a] Partition number (1-4): [1]
After the first partition, create the root file system partition (ext2/3):
Command (m for help): [n] Command action e extended p primary partition (1-4) [p] Partition number (1-4): [2] First cylinder (52-245, default 52): [(press Enter)] Using default value 52 Last cylinder or +size or +sizeM or +sizeK (52-245, default 245): [(press Enter)] Using default value 245
Finally, quit fdisk and format each partition. You can put the label you want.
Introduction to BeagleBoard
$ sudo mkfs.msdos -F 32 /dev/sdc1 -n LABEL1 ... $ sudo mkfs.ext3 -L LABEL2 /dev/sdc2 ...
First, while in OE root directory, copy the Linux Kernel image to the first partition using the name uImage.bin, the default name used by U-Boot.
$ cp tmp/deploy/glibc/images/beagleboard/uImage-beagleboard.bin /media/LABEL1/uImage.bin
Finally, unplug your memory card and plug it into BB. If you power on the board you should see the bootloader messages and at the end, the Linux Kernel messages, that will finally prompt a login screen. Login as root user and you will be in your new system!
... Booting from mmc ... ## Booting kernel from Legacy Image at 80200000 ... Image Name: Angstrom/2.6.29/beagleboard Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2546852 Bytes = 2.4 MB Load Address: 80008000 Entry Point: 80008000 Verifying Checksum ... OK Loading Kernel Image ... OK Starting kernel ... Uncompressing Linux............................................................. [ 0.000000] Linux version 2.6.29-omap1 (gerard@linmacbook) (gcc version 4.3.9 [ 0.000000] CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), cr=10c5387f .... Starting syslogd/klogd: done .-------. | | .-. | | |-----.-----.-----.| | .----..-----.-----. | | | __ | ---'| '--.| .-'| | | | | | | | |--- || --'| | | ' | | | | '---'---'--'--'--. |-----''----''--' '-----'-'-'-' -' | '---' The Angstrom Distribution beagleboard ttyS2 Angstrom 2009.X-stable beagleboard ttyS2 beagleboard login: root root@beagleboard:~#
After that, you can copy files from host to BB or from BB to PC by typing:
scp /file/in/host/pc user@$bb_ip:/destination/in/bb
Example:
scp gpslogger root@192.168.2.67:/home/root/programs
If you want to avoid SSH password prompts, you can create certificates.
A Hello World program is basically a program that says Hello. In our case, it is written in C language.
#include <stdio.h>
10
Introduction to BeagleBoard
int main() { printf("Hello from BeagleBoard!\n"); } return 0;
A Makefile is a file that helps in build process by making everything automatic. Explain how Makefiles are made is not the purpose of this document, but a basic example is provided. It offers the basic functions like compile and upload.
# Makefile for BeagleBoard
# Remote deploy (Use keys to avoid password prompts!) SSH_IP = 192.168.2.67 SSH_USER = root SSH_DIR = /home/root/programs # Project specific PROJ_NAME = project_name # Compiler options CC = arm-none-linux-gnueabi-gcc CFLAGS = -Wall -O2 -mcpu=cortex-a8 -march=armv7-a $(INCLUDE) # It will compile ALL *.c files in the folder OBJFILES := $(patsubst %.c,%.o,$(wildcard *.c)) # Libraries and header folders LIBS = INCLUDE=\ -I. # RULES all: $(PROJ_NAME) load: all @echo "Copying to BeagleBoard..." scp $(PROJ_NAME) $(SSH_USER)@$(SSH_IP):$(SSH_DIR) @echo "Done!" $(PROJ_NAME): $(OBJFILES) $(CC) -o $(PROJ_NAME) $(OBJFILES) $(LIBS) %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< clean: rm -f $(OBJFILES) rm -f $(PROJ_NAME)
11
The Makefile written above offers three basic options that will let you to put your program into BB.
make make load make clean
Compiles all C source files in the directory Loads compiled files using SSH (if they're not there they'll be compiled) Cleans all object and binary files
If everything goes right, you should be able to see something like this:
12
Introduction to BeagleBoard
Bibliography
Boot Linux on the BeagleBoard, OSIER-MIXON Jeffrey M., IBM http://www.ibm.com/developerworks/linux/library/l-beagle-board/ Building Angstrom, KOOI Koen http://www.angstrom-distribution.org/building-ngstrm Linux Boot Disk Format, BeagleBoard Wiki Pages http://code.google.com/p/beagleboard/wiki/LinuxBootDiskFormat
13