Você está na página 1de 7

LAB1:GettingstartedwithBeagleBone

A) SETTINGUPTHEBEAGLEBONE
BeagleboneshouldhaveshippedwithamicroSDcardandaUSBcable.TheSDcardcontainsthe
default Angstrom distribution of Linux. Angstrom is built specifically for platforms like the
Beaglebone.Itisfastandreliable.ThereareotherLinuxdistributionsfortheBeaglebonesuchas
UbuntuandAndroidbuttheycanbesignificantlyslowerthanAngstrom.
InserttheSDcardintotheslotunderneaththeboardnexttotheUSBport.NexthookuptheUSB
cabletoyourBeagleboneandcomputer,supplyingitpower.Youshouldseetheboardlightupand
starttoblink.IfadrivelabeledBeagleboneappearsonyourcomputer,ejectit.

USB cable

You can now access your Beaglebone through a serial terminal program such as screen or
Minicom.Toconnectusingscreentype:
sudo screen /dev/ttyUSB1 115200
ifyoudonotalreadyhavescreeninstalledtype:
sudoaptgetinstallscreen
Thenumber115200referstotheBaudrateoftheconnectionorhowmanybitscanbesentper
second.The/dev/ttyUSB1referstothedriverthatwilltalkwiththeBeagleboneandmayvary
frommachinetomachine.If/dev/ttyUSB1doesnotworktype:

dmesg | grep tty


andyoushouldseesomeoutputsimilartoo:
samir@samir-desktop:~$ dmesg | grep tty
[

0.000000] console [tty0] enabled

0.700412] 00:05: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

[ 23.631740] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB0
[ 23.632327] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB1
[ 23.632430] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB2
[ 752.508271] usb 1-8.1: FTDI USB Serial Device converter now attached to ttyUSB3
samir@samir-desktop:~$

Thelastlinetellsyouwhichusbtouse.Oncethatisdoneandyouhavescreenopenpressenter
andyoushouldseetheAngstromloginscreen:

Thedefaultuseris"root"withnopassword.Sotaperoottologin.
Toconnectusingminicomtype:
minicom -s
ifyoudonotalreadyhaveminicominstalledtype:
sudoaptgetinstallminicom

Checktheserialsetupsettings:
Serialdevice:/dev/ttyS0
Bps/Par/Bits:1152008N1
NoHardwareFlowControl/Softwarecontrol

SaveandexitAngstromwillbeloadedonBeagleBoard.Loginasroot.
B) GPIOVIATHESHELLCOMMANDLINEANDSYSFS
TheeasiestwaytodogeneralpurposeI/O(gpio)ontheBeagleisthroughaterminalwindowand
ashellprompt. InLinux,almosteverythingistreatedasafile,eventhingsthataren'tfiles.Inour
classwe'lluseavirtualfilesystemcalledsysfs.sysfsexposesthedriversforthehardwaresoyou
caneasilyusethem.Trythis,openaterminalandtype:
beagle$ cd /sys
beagle$ ls -F
block/ bus/ class/ dev/ devices/ firmware/ fs/ kernel/ module/ power/
Hereweseeseveraldirectoriesthatrepresenthardwarewecancontrol.Exploreabitandseewhat
youfind.
Nowtry:
beagle$ cd /sys/class
beagle$ ls -F
backlight/

graphics/

mem/

rtc/

tty/

bdi/

hwmon/

misc/

scsi_changer/

ubi/

block/

i2c-adapter/

mmc_host/

scsi_device/

udc/

bluetooth/

i2c-dev/

mtd/

scsi_disk/

usb_device/

bsg/

input/

net/

scsi_generic/

vc/

devfreq/

lcd/

power_supply/

scsi_host/

video4linux/

display/

leds/

pwm/

sound/

vtconsole/

firmware/

mbox/

regulator/

spi_master/

gpio/

mdio_bus/

rfkill/

spidev/

C) FLASHINGTHEUSERLEDS
TheBeaglehasfouruserLEDS,usr0tousr3,thatyoucancontrol.Trythis:
beagle$ cd /sys/class/leds
beagle$ ls -1F
beaglebone:green::usr0@
beaglebone:green::usr1@
beaglebone:green::usr2@
beaglebone:green::usr3@
Here you see the directories for controlling each of the user LEDs. By default, usr0 flashesa
heartbeatpatternandusr1flasheswhenthemicroSDcardisaccessed.Let'scontrolusr0.

beagle$ cd beaglebone\green::usr0
beagle$ ls -F
brightness

device@

max_brightness

power/

subsystem@

trigger

uevent

Seewhat'sinbrightness,max_brightnessandtriggerbyusingthecatcommand.Forexample:
beagle$ cat trigger
none nand-disk mmc0 mmc1 timer oneshot [heartbeat] backlight gpio cpu0 default-on transient

Thisshowstriggercanhavemanyvalues.Thepresentvalueisheartbeat.ChecktheLED,isit
beating?Youcanstoptheheartbeatvia:
beagle$ echo none > trigger
beagle$ cat trigger
[none] nand-disk mmc0 mmc1 timer oneshot heartbeat backlight gpio cpu0 default-on transient

Diditstopbeating?Youcannowturnitonandoffwith:
beagle$ echo 1 > brightness
beagle$ echo 0 > brightness
Isitrespondingcorrectly?TheBonehasmoretriggeroptions.Try:
beagle$ cat trigger
[none] nand-disk mmc0 mmc1 timer oneshot heartbeat backlight gpio cpu0 default-on transient

beagle$ echo timer > trigger


beagle$ ls -F
brightness delay_on max_brightness subsystem@ uevent
delay_off device@ power/ trigger
beagle$ echo 100 > delay_on
beagle$ echo 900 > delay_off
Whatdoesthisdo?
D) CROSSCOMPILATION:
Crosscompilationiscreatinganexecutableforaplatform(ARM)otherthanonwhichitisrun
(x86)
RequiredTools:
Binarytools:Binutils,Ld,as,nm,readelf
StandardClibs:glibc,uClibcoreglibc
C/C++compiler:gcc,g++
MathLibraries
Debugger:gdb
Acompletepacketconsistingofallthenecessarytoolsforcrosscompilationiscalledastoolchain.

Thereareprecompiledtoolchainsavailablelike
armlinuxgcc4.3.2.tar.bz2
CrosscompilationSteps:
1 ConnectthebeaglebonetoyourlaptopviathecrossEthernetcableasmentionedinthe
abovefigure.

Cross Ethernet
cable

USB cable

2 UseifconfigcommandforsettinganinterfacesIPaddressandenablingagiveninterface
2.1

Issueinterminal:
ifconfig eth0 192.168.0.1 up
SimilarlydothesameinBeagleBonewithanotherIPaddresssay,192.168.0.2

2.2

3 Checktheconnectivityusingping command
ping 192.168.0.1
CreateasampleCprogramonyourhostsysteminyour/homedirectory,
saysumof2.c
#include<stdio.h>
voidmain()
{
inti,j,k;
printf("givefirstinteger\t");

scanf("%d",&i);
printf("givesecondinteger\t");
scanf("%d",&j);
k=i+j;
printf("thesumis:%d\n",k);
}
NowweneedtocompilethisprogramandcreateanARMexecutableonHostmachine.
Inx86weuseagcccompilertocompileaprogramandcreateanIntelx86executable.
Issuethecommand:
gcc o sumof2 sumof2.c
sumof2
Checkthetypeofthefilecreatedafterthecompilationusingfilecommand
file sumof2
issuethefollowingcommandinterminalonyourhostmachinetoinstallarmlinuxgcctoolchain.
sudo apt-get install gcc-arm-linux-gnueabi
Issuetheterminalissuethefollowing:
arm-linux-gcc -o sumof2 sumof2.c
ThiscommandwillcompilethecodeforARMand linkitto createan ARMexecutable. You can
checkbyfilecommand.NowthatwehaveanARMexecutablewithus,weneedtoexecuteiton
ARMboard(Beaglebone).NowletustransfertheARMexecutabletotheBeagleBone through
Ethernet
Issuethecommandinyourhostshell:
scp sumof2 root@ 192.168.0.2:
Thiswillcopythefilesumof2(ARMexecutable)underrootdirectoryofyourBeagleBone.
ExecutetheARMexecutablefileonBeaglebone
./sumof2

Você também pode gostar