Anda di halaman 1dari 13

Introduction to BeagleBoard

Gerard Marull Paretas Universitat Politcnica de Catalunya, September 2009

Published under Creative Commons (Attribution Share Alike)


Some pictures come from BeagleBoard.org documents

Introduction to BeagleBoard

Description and features


BeagleBoard (BB from now on) is a low-cost, fan-less single board computer equipped with a powerful microprocessor giving laptop-like performance. BB comes with a full set of opensource tools, which is one of the good reasons to choose it. Development costs decrease as there is no need to buy any compiler or programming tools. The main features of BB are listed below: OMAP3530 Microprocessor 1200 DMIPS, based on ARM Cortex-A8 running at 600Mhz TMS320C64x+ DSP for versatile signal processing at up to 430MHz Memories: 256MB of NAND Flash, 256MB of SDRAM SD/MMC Card slot, can be used as OS file system, file storage and more USB Host port which gives the option to connect a full set of peripherals using a hub (ethernet adaptor, keyboard, mouse...) DVI-D digital output and S-VIDEO (NTSC/PAL) output Stereo audio output and microphone input Multiplexable expansion header: I2C, SPI, UART, GPIO, SD/MMC Typical power consumption: 2W (at 5V)

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.

Illustration 1: A detailed view of BB 3

Universitat Politcnica de Catalunya

First steps with BeagleBoard


Connecting BeagleBoard

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

Introduction to BeagleBoard if not check your cables or your terminal settings.


Boot sequence

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.

Illustration 2: Boot Sequence

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.

The ngstrm distribution and OpenEmbedded


ngstrm is complete Linux distribution: includes the kernel, a base file system, basic tools and even a package manager to install software from a repository. It is optimized for low-power microcontrollers like the one in BB and intends to be small and basic system to modify on your needs. It uses the OpenEmbedded (OE from now on) platform, a toolchain that makes crosscompiling and deploying packages easy for embedded platforms. There are other options available, however this document is focused on ngstrm.
Step 1: Get OpenEmbedded metadata

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

Universitat Politcnica de Catalunya


$ $ $ $ $ git clone git://git.openembedded.org/openembedded.git openembedded cd openembedded git checkout origin/stable/2009 -b stable/2009 cd ${OE_HOME}/openembedded git pull

Step 2: Configure OpenEmbedded

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

Now, you can build ngstrm by typing:


$ bitbake -f base-image $ bitbake -f console-image $ bitbake -f x11-image

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

You should get something like this:


[ [ [ [ [ 6854.215650] 6854.215653] 6854.215659] 6854.218079] 6854.218135] sd 7:0:0:0: sd 7:0:0:0: sdc: sdc1 sd 7:0:0:0: sd 7:0:0:0: [sdc] Mode Sense: 0b 00 00 08 [sdc] Assuming drive cache: write through [sdc] Attached SCSI removable disk Attached scsi generic sg2 type 0

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

Universitat Politcnica de Catalunya


255 heads, 63 sectors/track, 245 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id /dev/sdc1 * 1 246 1974240+ c Partition 1 has different physical/logical endings: phys=(244, 254, 63) logical=(245, 200, 19) Command (m for help): [d] Selected partition 1 System W95 FAT32 (LBA)

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

Now you need to apply changes to your memory card:


Command (m for help): [w] The partition table has been altered! Syncing disks.

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 ...

Step 5: Install and boot ngstrm

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

After that, extract the root file system:


$ sudo tar -jxvf tmp/deploy/glibc/images/beagleboard/base-imagebeagleboard.tar.bz2 /media/LABEL2

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:~#

Universitat Politcnica de Catalunya

Build your own software for BeagleBoard


OE is a good toolchain but it may be too big for little and simple programs when you start to develop for BB, because you first need to create the recipes for bitbake and it is easier to install a simple toolchain (which in fact is the same) and create a basic makefile that will be clearer for newbies. It is also possible to install a native toolchain into BB that will let you to write and compile your programs in the same board, but it is not recommended for large projects because BB processor is not as powerful as your host PC.

CodeSourcery GNU Toolchain


CodeSourcery is an enterprise which offers embedded solutions and it also offers a free toolchain for ARM (EABI) based on GNU tools including some patches and optimizations. It is the recommended toolchain for BB. You can download it from http://www.codesourcery.com/sgpp/lite/ arm (Target: GNU/Linux). Just install it and you'll have complete toolchain that will let you to cross-compile for BB (C and C++ programs). The C and C++ compilers are named arm-none-linuxgnueabi-gcc and arm-none-linux-gnueabi-g++ .

Upload your programs to BeagleBoard


When you get the binary from the cross-compiler, you need to put into your BB ngstrm Linux file system in order to run it. There are many options, one is to copy it into a flash portable memory from host PC and then download it to BB, but as you could imagine it is a slow way. The best option is to use SSH transfers. You must connect host PC and BB to your local network. In the case of BB you can use a USB to Ethernet adapter. After that, you must install a ssh server/client in both host and BB. Dropbear is a good choice for BB:
opkg install dropbear

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.

Example Hello World including a Makefile for process automation


A good way to see if you are ready to develop for BB is to create a simple Hello World program. An example Makefile is also included to automate the process of compiling and uploading with a few commands.
Step 1: The Hello World program

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;

Step 2: A basic Makefile for process automation

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

Universitat Politcnica de Catalunya


Step 3: Build and upload

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:

Illustration 3: A "Hello World" program running on BB

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

Anda mungkin juga menyukai