You are on page 1of 13

Introduction to BeagleBoard

Gerard Marull Paretas Universitat Politècnica de Catalunya, September 2009

Published under Creative Commons (Attribution – Share Alike) Some pictures come from documents .

The best option for BB is Linux. SPI.. which is one of the good reasons to choose it. 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. mouse.) DVI-D digital output and S-VIDEO (NTSC/PAL) output Stereo audio output and microphone input Multiplexable expansion header: I2C. BB comes with a full set of opensource tools. fan-less single board computer equipped with a powerful microprocessor giving laptop-like performance. keyboard. UART. 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. mainly because there is an active project supporting BB which includes working drivers for the features listed above. Illustration 1: A detailed view of BB 3 . a good toolchain (GCC based) and many common packages ready to build and install into BB. 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. can be used as OS file system. GPIO. 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.Introduction to BeagleBoard Description and features BeagleBoard (BB from now on) is a low-cost. file storage and more USB Host port which gives the option to connect a full set of peripherals using a hub (ethernet adaptor..

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.06-rc2 (Jul 17 2009 . 1 Remember that maximum voltage input is 5. 1 Stop bit.2V so check that your power supply is stable and clean 4 . using the following settings: • • • Speed: 115200 bps 8 Bits. 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.Universitat Politècnica de Catalunya First steps with BeagleBoard Connecting BeagleBoard Before you can start. No parity No flow control After that you can power on BB either by using the power adaptor or the USB cable. connect the serial cable to your computer and open a serial terminal.12:01:24) Reading boot sector Loading u-boot.bin from nand U-Boot 2009.11:23:49) OMAP3530-GP ES3.4.2 (Feb 19 2009 . You should see some messages from the board in your terminal like these: Texas Instruments X-Loader # If you see these messages in your terminal it means that BB is alive and you are ready to continue. you will need the following items: • • • Power adaptor1 5V (min.

recipes. tools. however this document is focused on Ångström. You usually will need a shell and a basic toolbox giving you access to functions such as browse directories. U-boot is a basic boot environment that will let you to run the operating system. $ export OE_HOME="/path/you/want/for/OE" $ mkdir -p ${OE_HOME} && cd ${OE_HOME} 2 Refer to BeagleBoard Reference Manual.14 3 Refer to Annex 1 “Basic operation with U-Boot” for detailed information 5 . This is known as a multi-stage boot. 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.Introduction to BeagleBoard if not check your cables or your terminal settings. basic tools and even a package manager to install software from a repository. etc. There are other options available. U-Boot can be loaded in many different ways and orders2 as suggested in Illustration 2. read and write files. It uses the OpenEmbedded (OE from now on) platform. update flash contents with new versions of the bootloader and many more things3. Step 1: Get OpenEmbedded metadata First you will need to get the OE metadata from their GIT repository (information. 5. a toolchain that makes crosscompiling and deploying packages easy for embedded platforms. Remember that you need to have GIT installed before typing the following commands. 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. a base file system. Illustration 2: Boot Sequence Linux on BeagleBoard Linux alone is no more than an operating system kernel.). The Ångström distribution and OpenEmbedded Ångström is complete Linux distribution: includes the kernel. insert boot arguments. which is an essential piece but not enough to get a fully functional system. even your own software. After that many extra packages can be installed on your file system. etc. BB comes with a flashed bootloader by default (Texas Instruments X-Loader) which runs automatically the U-Boot environment.

It basically sets the working directories so OE tools can find all files. even solve dependencies.Universitat Politècnica de Catalunya $ $ $ $ $ git clone git://git. a set of instructions to build a package. on your OE root folder. While inside OE root folder. then export PS1="\[\033[01. you need to set up OE indicating your target board. if [ "$BASH" ]. create a file named “local.. create a new folder tree: $ mkdir -p build/conf Inside conf folder. directory of OE" 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"" DISTRO = "angstrom-2008. etc. OE uses bitbake as a package builder and manager. In the case of Angstrom. 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.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.conf” and write these lines: # Recipes. Step 3: Build software using OpenEmbedded Now you are ready to start building software for your BB using OE configured to use Angstrom distribution.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.openembedded. The first thing you should build is a base operating system for your BB. distro and target board BBFILES = "/path/you/want/for/OE/openembedded/recipes/*/*. it will make everything for you when you need to build a package. 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. there are 3 options: • 6 Base Image: A minimal operating system . Using the previously downloaded recipes.

logs. bitbake -f nano).215653] 6854. 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. load the profile (remember to do that every time you start working with OE): $ source profile Now.. All files involved in build process (sources. Step 4: Format your memory card Memory card (SD or MMC) is usually partitioned in 2 partitions to use with BB. first plug it into your computer and to determine drive name.215659] 6854. First. unmount it before continuing. and final packages will be normally inside “tmp/deploy”.215650] 6854.218079] 6854. object files. If your memory card has any partition and it is automatically mounted. 2021654528 bytes 7 . networking) X11 Image: An operating system including graphical interface You can choose whatever you want depending on your needs. and a second one formatted with ext2/3 used for the root file system. in this case sdc is the drive name. Note that you can also build packages alone using bitbake (ex.. First.) will be placed in “ tmp” folder. type: $ dmesg | tail You should get something like this: [ [ [ [ [ 6854. you can build Ångström 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.Introduction to BeagleBoard • • Console Image: A basic operating system including some extra tools (ex. To format your memory card. The first one is a small FAT partition where Linux Kernel will be placed as U-Boot only reads FAT partitions.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.

A size of 50MB is fine. 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. 200. Finally. 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. 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. 63) logical=(245. 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. When it is done. 254. default 1): [(press Enter)] Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-245.Universitat Politècnica de Catalunya 255 heads. quit fdisk and format each partition. default 52): [(press Enter)] Using default value 52 Last cylinder or +size or +sizeM or +sizeK (52-245. 8 . You can put the label you want. 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. 63 sectors/track. 19) Command (m for help): [d] Selected partition 1 System W95 FAT32 (LBA) Now create the first partition (FAT32) to allocate the Linux Kernel.

..6.. unplug your memory card and plug it into BB... $ cp tmp/deploy/glibc/images/beagleboard/uImage-beagleboard.. ## Booting kernel from Legacy Image at 80200000 . OK Starting kernel .-.-----..-'| | | | | | | | |--.. copy the Linux Kernel image to the first partition using the name “uImage.. while in OE root directory.. extract the root file system: $ sudo tar -jxvf tmp/deploy/glibc/images/beagleboard/base-imagebeagleboard...tar. Booting from mmc ....Introduction to BeagleBoard $ sudo mkfs..6. | | |-----... Starting syslogd/klogd: done .. $ sudo mkfs.bin /media/LABEL1/uImage.. cr=10c5387f .000000] Linux version 2.bin”.... OK Loading Kernel Image ..-------.----...| ..X-stable beagleboard ttyS2 beagleboard login: root root@beagleboard:~# 9 ..... | | ....000000] CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7)...... the default name used by U-Boot...-----..3...29-omap1 (gerard@linmacbook) (gcc version 4.... Login as “root” user and you will be in your new system! .bin After that...9 [ 0..msdos -F 32 /dev/sdc1 -n LABEL1 . the Linux Kernel messages....4 MB Load Address: 80008000 Entry Point: 80008000 Verifying Checksum ........ Uncompressing Linux. If you power on the board you should see the bootloader messages and at the end.ext3 -L LABEL2 /dev/sdc2 . | | | __ | ---'| '--.-----.... Image Name: Angstrom/2...bz2 /media/LABEL2 Finally.-----...... Step 5: Install and boot Ångström First...... [ 0.|| --'| | | ' | | | | '---'---'--'--'--..| | .. |-----''----''--' '-----'-'-'-' -' | '---' The Angstrom Distribution beagleboard ttyS2 Angstrom 2009.29/beagleboard Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2546852 Bytes = 2. that will finally prompt a login screen....

Just install it and you'll have complete toolchain that will let you to cross-compile for BB (C and C++ programs).67:/home/root/programs If you want to avoid SSH password prompts.codesourcery.Universitat Politècnica 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. You must connect host PC and BB to your local network. 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. you can create certificates. In the case of BB you can use a USB to Ethernet adapter. The best option is to use SSH transfers. 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.h> 10 . Upload your programs to BeagleBoard When you get the binary from the cross-compiler. The C and C++ compilers are named arm-none-linuxgnueabi-gcc and arm-none-linux-gnueabi-g++ . but as you could imagine it is a slow way. There are many options. You can download it from http://www. Step 1: The “Hello World” program A “Hello World” program is basically a program that says “Hello”.com/sgpp/lite/ arm (Target: GNU/Linux).168. Dropbear is a good choice for BB: opkg install dropbear After that. In our case.2. 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. but it is not recommended for large projects because BB processor is not as powerful as your host PC. An example Makefile is also included to automate the process of compiling and uploading with a few commands. one is to copy it into a flash portable memory from host PC and then download it to BB. you need to put into your BB Ångström Linux file system in order to run it. After that. #include <stdio. it is written in C language. It is the recommended toolchain for BB. 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. 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. you must install a ssh server/client in both host and BB.

2.c)) # Libraries and header folders LIBS = INCLUDE=\ -I.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 *. # RULES all: $(PROJ_NAME) load: all @echo "Copying to BeagleBoard. but a basic example is provided.c $(CC) $(CFLAGS) -c -o $@ $< clean: rm -f $(OBJFILES) rm -f $(PROJ_NAME) 11 ..o: %.%." scp $(PROJ_NAME) $(SSH_USER)@$(SSH_IP):$(SSH_DIR) @echo "Done!" $(PROJ_NAME): $(OBJFILES) $(CC) -o $(PROJ_NAME) $(OBJFILES) $(LIBS) %. Explain how Makefiles are made is not the purpose of this document.Introduction to BeagleBoard int main() { printf("Hello from BeagleBoard!\n").$(wildcard *. It offers the basic functions like compile and upload.c. # Makefile for BeagleBoard # Remote deploy (Use keys to avoid password prompts!) SSH_IP = 192.o.. } return 0.c files in the folder OBJFILES := $(patsubst %. Step 2: A basic Makefile for process automation A Makefile is a file that helps in build process by making everything automatic.168.

Universitat Politècnica 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 .

IBM http://www.angstrom-distribution. OSIER-MIXON Jeffreyångström “Linux Boot Disk Format”.com/developerworks/linux/library/l-beagle-board/ “Building Angstrom”.Introduction to BeagleBoard Bibliography “Boot Linux on the BeagleBoard”. BeagleBoard Wiki Pages http://code. KOOI Koen 13 .ibm.