Sunteți pe pagina 1din 52

OpenBoard-phyCORE-AM335x

Application Devlopment Kit (ADK)

OM !rod"ct #o$ !CM-%5&

Carrier Board !rod"ct #o$ !CM-'5%

Release 1.0 January,2013

www.phytec.in

Revision no. 1.0

In this manual copyrighted products are not explicitly indicated. The absence of the trademark () and copyright ( ) symbols does not imply that a product is not protected. !dditionally" registered patents and trademarks are similarly not expressly indicated in this manual. The information in this document has been carefully checked and is belie#ed to be entirely reliable. $o%e#er" &$'T() (mbedded &#t. *td. assumes no responsibility for any inaccuracies. &$'T() (mbedded &#t. *td neither gi#es any guarantee nor accepts any liability %hatsoe#er for conse+uential damages resulting from the use of this manual or its associated product. &$'T() (mbedded &#t. *td reser#es the right to alter the information contained herein %ithout prior notification and accepts no responsibility for any damages that might result. !dditionally" &$'T() (mbedded &#t. *td offers no guarantee nor accepts any liability for damages arising from the improper usage or improper installation of the hard%are or soft%are. &$'T() (mbedded &#t. *td further reser#es the right to alter the layout and,or design of the hard%are %ithout prior notification and accepts no liability for doing so. )opyright -01. &$'T() (mbedded &#t. *td" /oramangala 0angalore. Rights - including those of translation, reprint, broadcast, photomechanical or similar reproduction and storage or processing in computer systems, in whole or in part - are reserved. No reproduction may be made without the explicit written consent from P !"#$ #mbedded Pvt. %td.

'ddress(

&ndia #urope North 'merica P !"#$ #mbedded Pvt. &$'T() Technologie &$'T() !merica **) %td. $olding !1 -0. &arfitt 9ay 39" th )oramangala * bloc+, Robert2/och23tr. .4 3uite 1100 0ainbridge ,angalore --. 551-4 6ain7 Island" 9! 4:110 ;3! &ndia 1(R6!8' /-1-*0-01102.*3ales4phytec.in http(55www.phytec.in >?4 (:00) 0@?4:.order4phytec.de http(55www.phytec.de 1 (:00) -@:2441. sales4phytec.com http(55www.phytec.com

<rdering Information= 9eb 3ite=

www.phytec.in

Revision no. 1.0

(a)le o* Content+
#mbedded %inux 'ppliation 7evelopment for 8pen,oard-'911.x.................................................. 1. 'pplication development using #clipse &7#................................................................................ 1.1. #clipse &7# &nstallaion......................................................................................................... 1.6. #clipse &7# $onfiguration for 8pen,oard-'911.x..........................................................: 1.6.1. ost 3etup....................................................................................................................: 1.6.6. "arget 3etup..................................................................................................................: 1.6.1.1. 3et the ip for the open board.................................................................................: 1.1. $reating a New Pro;ect........................................................................................................2 1.1.1. ow to open eclipse.....................................................................................................2 1.1.6. <elcome to #clipse......................................................................................................* 1.1.1. 8pen a new pro;ect.......................................................................................................* 1.1.0. 3elect $ Pro;ect............................................................................................................1.1... 3elect the $ross =$$...................................................................................................1.1.:. 3elect 7ebug >acilities...............................................................................................10 1.1.2 "oolchain Prefix ? Path..............................................................................................10 1.1.*. 8pen new $ source file..............................................................................................11 1.1.-. <rite simple ello 'pplication..................................................................................16 1.1.10. 9odify Post build steps............................................................................................16 1.1.11. >inally ,uild the pro;ect...........................................................................................10 1.0. $hanging the 7emo 'pplication........................................................................................10 1.0.1. 8pen "arget ,oard using 9inicom............................................................................1: 1... %ed ,lin+ing 'pplication...................................................................................................12 1...1. 3elect the $ross =$$.................................................................................................12 1...6. 3elect 7ebug >acilities...............................................................................................1* 1...1. "oolchain Prefix ? Path.............................................................................................1* 1...0. 8pen new $ source file..............................................................................................11..... <rite %ed 'pplication................................................................................................60 1...:. <rite 8pen ,oard eader..........................................................................................61 1...2. 9odify the %ibrary Path.............................................................................................61 1...*. 9odify Post build steps..............................................................................................60 1...-. Remote 3ystem 'ccess using #clipse........................................................................6. 1...10. $reate New $onnection for Remote 3ystem login..................................................62 1...11. 3et the ost Name and &P.........................................................................................6* 1...16. %aunch the Remote "erminal...................................................................................11 1...11. &nsert the driver using the Remote "erminal............................................................16 1...11. >inally ,uild the pro;ect...........................................................................................11 1.:. 7ebugging an example pro;ect...........................................................................................10 1.:.1. 3tarting the =7, server on the target........................................................................10 1.:.6. $onfiguring and starting the debugger in #clipse......................................................1. 1.:.1. 3etting a ,rea+point...................................................................................................00 1.:.0. 3tepping and <atching @ariable $ontents.................................................................01 1.:... 3tepping and <atching @ariable $ontents.................................................................01 1.:.:. Asing the 9emory 9onitor........................................................................................00 6. 'pplication development using $onsole "erminal....................................................................02 6.1. Aser %#7B3........................................................................................................................0* 6.1.1. Pre-ReCuists................................................................................................................0* 6.1.6.$ompiling Aser %ed 'pplication................................................................................0* 6.1.6.1. ost 3ide.............................................................................................................0* 6.1.6.6. "arget 3ide..........................................................................................................0* 6.6. Aser ,A""8NB3................................................................................................................0-

www.phytec.in

Revision no. 1.0

6.6.1. Pre-ReCuists................................................................................................................06.6.6. $ompiling Aser 3witch 'pplication...........................................................................06.6.6.1. ost 3ide.................................................................................................................06.6.6.6. "arget 3ide..........................................................................................................06.1. '7$....................................................................................................................................0 6.1.1. Pre-ReCuists.................................................................................................................0 6.1.6. $ompiling Aser '7$ 'pplication..............................................................................0 6.1.6.1. ost 3ide..............................................................................................................0 6.1.6.6. "arget 3ide...........................................................................................................1

www.phytec.in

Revision no. 1.0

Em)edded ,in"x Appliation Development *or OpenBoardAM335x


&n this 9anual we are going to describe how to use this 8pen ,oard for application development. 8ur first chapter is dealing with the instalation of eclipse and how a user can developed his own application which would run on open board easilly with the help of eclipse. &n our second chapter we will describe how to write an application using console terminal. 'fter going through this manual you will not only familiar with 8pen board as well as you will also have an idea how to use eclipse and console terminal for application development.

1. Application development using Eclipse IDE


With the help of example projects, we will teach you how to work with eclipse. First we take a look on the C programming language. At the end of this chapter we explain how to debug your written programs when running on the target.

&-&- Eclip+e .DE .n+tallaion


>irst of all get the latest eclipse i.e, Eclipse IDE for C/C++ Developers and install it. Eclipse IDE for C/C++ Developers http(55www.eclipse.org5downloads5pac+ages5eclipse-ide-cc-developers5;unosr1 Eclipse IDE for C/C++ Developers for Windows 32-bit http(55www.eclipse.org5downloads5download.phpD fileE5technology5epp5downloads5release5;uno53R15eclipse-cpp-;uno-3R1-win16.Fip Note: Eclipse required j v lso so we need to inst ll t!e j v " http(55www.oracle.com5technetwor+5;ava5;avase5downloads5;re2-downloads-1**06:1.html Eclipse IDE for C/C++ Developers for Windows #$-bit http(55www.eclipse.org5downloads5download.phpD fileE5technology5epp5downloads5release5;uno53R15eclipse-cpp-;uno-3R1-win16-x*:G:0.Fip Eclipse IDE for C/C++ Developers for %inu& 32-bit http(55www.eclipse.org5downloads5download.phpD fileE5technology5epp5downloads5release5;uno53R15eclipse-cpp-;uno-3R1-linux-gt+.tar.gF Note: Eclipse required j v lso so we need to inst ll t!e j v usin' t!is co(( nd" sudo apt-get install open;d+-2-;d+ open;d+-2-;re Eclipse IDE for C/C++ Developers for %inu& #$-bit http(55www.eclipse.org5downloads5download.phpD fileE5technology5epp5downloads5release5;uno53R15eclipse-cpp-;uno-3R1-linux-gt+-x*:G:0.tar.gF Eclipse IDE for C/C++ Developers for ) c *+ ,-Coco 32. http(55www.eclipse.org5downloads5download.phpD fileE5technology5epp5downloads5release5;uno53R15eclipse-cpp-;uno-3R1-macosx-cocoa.tar.gF

www.phytec.in

Revision no. 1.0

Eclipse IDE for C/C++ Developers for ) c *+ ,-Coco #$. http(55www.eclipse.org5downloads5download.phpD fileE5technology5epp5downloads5release5;uno53R15eclipse-cpp-;uno-3R1-macosx-cocoax*:G:0.tar.gF

&-/- Eclip+e .DE Con*i0"ration *or OpenBoard-AM335x


1.2.1. Host Setup /oolc! in: >or $ompiling the 'pplication we need the toolchain which you can easilly download from the below lin+. 0or %inu&: ftp(55ftp.phytec.de5pub5Products5&ndia58pen,oard-'911.x5%inux5latest5tools5toolchain5armcortexa*-linux-gnueabi.tar.bF6 Antar the toolchain first the prefix of the toolchain is r(-corte& 1-linu&-'nue bi0or Window: http(55sourcery.mentor.com5public5gnuGtoolchain5arm-none-linux-gnueabi5arm-6016.0--:0-armnone-linux-gnueabi.exe Install the toolchain the prefix of the toolchain is arm-none-lin"x-0n"ea)i- and default path is C:\Program Files\CodeSourcer \Sourcer !Code"enc#!$ite!%or!A&'!()*!$inu+\,in 1.2.2. -arget Setup Connect the power adaptor, serial cable, ethernet cables to the open board. oot the open board. &-/-&-&- et the ip *or the open )oard!o see all the interfaces present on the open board " ifconfig #a After this we got the particular interface then we ha$e to configure it. " ifconfig eth% &'(.&)*.&.&& up where eth% is the interface name. Again check whether it is configured or not " ifconfig #a !hen we ha$e to set the gateway

www.phytec.in

Revision no. 1.0

" route add default gw &'(.&)*.&.& !o see the change in the gateway. " route

&-3- Creatin0 a #e1 !ro2ect

In this section you will learn how to create a new project with +clipse and how to configure the project for use with the ,-. C/C00 cross de$elopment toolchain. Click the +clipse icon to start the application. 1ou can find this icon where you ha$e extracted the +clipse I2+ for C/C00 2e$elopers . 1...1. Ho/ to open eclipse

$onfirm the wor+space directory with 8)

www.phytec.in

Revision no. 1.0

1...2. 0elcome to Eclipse

Close the 3Welcome to +clipse3 screen by clicking on the 3,o to the workbench3 button

1..... 1pen a ne/ pro2ect

www.phytec.in

Revision no. 1.0

4 5elect File 6 -ew 6 7roject from the menu bar A new dialog opens. 1...3. Select C Pro2ect

5elect C 7roject and click -ext 1...4. Select t#e Cross (CC

www.phytec.in

Revision no. 1.0

+nter the project name my8elloWorld and !oolchain as Cross ,CC then click -ext 1...5. Select De,ug Facilities

Click -ext 1...6 -oolc#ain Pre%i+ 7 Pat#

www.phytec.in

10

Revision no. 1.0

5elect the Cross Compiler 7refix as arm-cortexa3-lin"x-0n"ea)iand Cross Compiler 7ath as 9path of toolchain bin: #ote; for window you ha$e to select the arm-none-lin"x-0n"ea)i- and the appropriate path of the toolchain. 1...8. 1pen ne/ C source %ile

1ou will see the C/C00 I2+ with the my8elloWorld project. <ight#click on 8elloWorld project 5elect File 6 -ew 6 5ource file from the menu bar In 5ource file write my8elloWorld.c and click on finish

www.phytec.in

11

Revision no. 1.0

1...9. 0rite simple Hello Application

Write a simple 8ello Application in C. !o compile your project for the =pen ,-. C/C00 cross compiler. 1...1:. 'odi% Post ,uild steps oard#A>??@A instead, you will ha$e to use the

www.phytec.in

16

Revision no. 1.0

<ight#click the my8elloWorld project and chose 7roperties !he 7roperties dialog appears. 5elect C/C00 uild ####: 5etting #######:5elect the uild 5teps tab +nter the following command in the 7ost#build steps Command input field; +cp -4my5ello6orld root7&'/-&83-&-&&$4home4- 9++h root7&'/-&83-&-&& -4my5ello6orld #ote$ .* yo" are "+in0 6indo1 machine then there i+ no "+e o* 1ritin0 the a)ove line it 1ill thro"0h error +o yo" have to "+e 6in+cp or directly copy the )inary into tar0et )oard "+in0 pen drive or +d card1ou can download the winscp from the below link; http;//download.winscp.net/download/files/(%&?%((B&&@'a@e%d'e&'??B?cacc'''*a(df(* ?e&'a/winscp@&Csetup.exe Click Apply Click =D 5elect 7roject 6 uild project from the menu bar !he project will be built. 5elect the Console tab. if no errors occur while building the project, you will see the following output; #ote$ .* yo" are "+in0 6indo1 machine then yo" need the ma:e "til+ "+in0 te )elo1 lin: yo" can do1nload it. ftp;//ftp.eEuation.com/make/?(/make.exe

www.phytec.in

11

Revision no. 1.0

1...11. Finall "uild t#e pro2ect

&-;- Chan0in0 the Demo Application


Now we will extend the my ello<orld application. "he extended my ello<orld application will write an output to the first serial interface as well as to the standard output. 8pen #clipse if it is not opened yet 7ouble-clic+ ello<orld.c in the my ello<orld pro;ect >irst include the following two additional header files(
#include <unistd.h> #include <fcntl.h>

"hen add the function writeGttyHI, which writes n bytes to the first serial interface Hwhich, on the 8pen-,oard-'911.x, is connected to the system console 5dev5consoleI(
void write_tty (char *buffer, int count) { int out; out = o en (!"dev"console!, ###); write(out, buffer, count); close(out); $

www.phytec.in

10

Revision no. 1.0

#nter the following two lines in the mainHI function to declare the buffer and call the writeGttyHI function.
char buf %& = { !'elco(e to the 'orld of the ) en*+oard*,-../01 (serial)2n! $; write_tty(buf, si3eof (buf) * 4);

&n the next screenshot you can see the complete program.

3ave your program after changing the code. "he application will be compiled, built, copied to the target and executed.

www.phytec.in

1.

Revision no. 1.0

1.3.1. 1pen -arget "oard using 'inicom 8pen the terminal using minicom J minicom -7 5dev5ttyKK &f you are not logged in, enter root and press #nter then type ls to see all the file. J ls "ype .5my ello<orld to start the application .5my ello<orld ello <orld <elcome to the <orld of the 8pen-,oard-'911.xL HserialI close minicom. &n this section you have changed an existing application. !ou also learned how to access the serial interface. >irst you called the function openHI on the device 5dev5console. "he return value of this function was a file descriptor. <ith the file descriptor you called the function writeHI to send n bytes to the device 5dev5console. 'fter that, the file descriptor was closed with the function closeHI.

www.phytec.in

1:

Revision no. 1.0

&-5- ,ed Blin:in0 Application


&n this section we are dealing with some hardware such as led on th e 8pen ,oard. >or writing an application for led first follows 3tep 1.1.1. to 3tep -1.1.0. as discuss above. 'fter then 1.4.1. Select t#e Cross (CC 4 5elect File 6 -ew 6 C 7roject from the menu bar A new dialog opens.

+nter the project name myled and !oolchain as Cross ,CC then click -ext

www.phytec.in

12

Revision no. 1.0

1.4.2. Select De,ug Facilities

Click -ext 1.4... -oolc#ain Pre%i+ 7 Pat#

5elect the Cross Compiler 7refix as arm-cortexa3-lin"x-0n"ea)iand Cross Compiler 7ath as 9path of toolchain bin:

www.phytec.in

1*

Revision no. 1.0

1.4.3. 1pen ne/ C source %ile

1ou will see the C/C00 I2+ with the led project. <ight#click on led project 5elect File 6 -ew 6 5ource file from the menu bar In 5ource file write myled.c and click on finish

www.phytec.in

1-

Revision no. 1.0

1.4.4. 0rite $ed Application !hen write a led application as; /F F myled.c F F Created on; ()#Feb#(%&? F Author; Ashutosh F/ "include 9stdio.h: "include 9stdlib.h: "include 9unistd.h: "include 9sys/ioctl.h: "include 3openGboard.h3 int mainHI J int fdK fdLopenGgpioH3/de$/openGboardGgpio3, )))IK /F....... !his function will configure the user led as output.......F/ gpioGconfHfd, gpioGconfHfd, gpioGconfHfd, gpioGconfHfd, A-D&,7I-?%,=.!IK A-D&,7I-?&,=.!IK A-D&,7I-*,=.!IK A-D&,7I-',=.!IK

/F....... !here we will toggled the user led .......F/ whileH&I J setGgpioHfd, A-D&,7I-',5+!IK setGgpioHfd, A-D&,7I-*,5+!IK setGgpioHfd, A-D&,7I-?%,5+!IK setGgpioHfd, A-D&,7I-?&,5+!IK sleepH&IK setGgpioHfd, A-D&,7I-',CM+A<IK setGgpioHfd, A-D&,7I-*,CM+A<IK setGgpioHfd, A-D&,7I-?%,CM+A<IK setGgpioHfd, A-D&,7I-?&,CM+A<IK sleepH&IK N /F....... !his function will free the user led.......F/ gpioGfreeHfd, gpioGfreeHfd, gpioGfreeHfd, gpioGfreeHfd, A-D&,7I-?%IK A-D&,7I-?&IK A-D&,7I-*IK A-D&,7I-'IK

/F....... !his function will close the node.......F/ closeGgpioHfdIK

www.phytec.in

60

Revision no. 1.0

return %K N

1.4.5. 0rite 1pen "oard Header 5elect File 6 -ew 6 8eader file from the menu bar In 8eader file write openGboard.h and click on finish !hen write the 8eader file as. /F F openGboard.h F F Created on; ()#Feb#(%&? F Author; Ashutosh F/ "ifndef =7+-G =A<2G8G "define =7+-G =A<2G8G "define =.! % "define I- & "define 5+! & "define CM+A< % "define A-D% % "define A-D& & "define A-D( (

www.phytec.in

61

Revision no. 1.0

"define A-D? ? "define 7I-% % "define 7I-& & "define 7I-( ( "define 7I-? ? "define 7I-C C "define 7I-@ @ "define 7I-) ) "define 7I-B B "define 7I-* * "define 7I-' ' "define 7I-&% &% "define 7I-&& && "define 7I-&( &( "define 7I-&? &? "define 7I-&C &C "define 7I-&@ &@ "define 7I-&) &) "define 7I-&B &B "define 7I-&* &* "define 7I-&' &' "define 7I-(% (% "define 7I-(& (& "define 7I-(( (( "define 7I-(? (? "define 7I-(C (C "define 7I-(@ (@ "define 7I-() () "define 7I-(B (B "define 7I-(* (* "define 7I-(' (' "define 7I-?% ?% "define 7I-?& ?& int openGgpioHchar Fnode, int perIK int gpioGconfHint fd, int bank, int pin, int dirIK int gpioGintrGconfHint fd, int bank, int pin, int dirIK int gpioGfreeHint fd, int bank, int pinIK int gpioGintrGfreeHint fd, int bank, int pinIK int setGgpioHint fd, int bank, int pin, int $alueIK int closeGgpioHint fdIK unsigned int readGinteruptHint fd, int bank, int pinIK "endif /F =7+-G =A<2G8G F/

www.phytec.in

66

Revision no. 1.0

1.4.6. 'odi% t#e $i,rar Pat# !hese abo$e functions are in the shared library so we are going to add our shared library to this project. you can download led and user button library from 7hytec F!7 using this link ftp;//ftp.phytec.de/pub/7roducts/India/=pen oard# A>??@x/Minux/latest/src/apps/apps.tar.gO untar it and go to the led app directory where you find the library file, this is your library path. <ight#click the led project and chose 7roperties !he 7roperties dialog appears. 5elect C/C00 uild ####: 5etting #######: tools setting ###########: Cross ,CC Minker ###############: Mibraries !here add new Mibraries H#lI as openGboard and Mibrary search path H#MI as 9location of your library :

www.phytec.in

61

Revision no. 1.0

1.4.8. 'odi% Post ,uild steps

5elect the uild 5teps tab

+nter the following command in the 7ost#build steps Command input field;

www.phytec.in

60

Revision no. 1.0

+cp -4myled root7&'/-&83-&-&&$4home4- 9++h root7&'/-&83-&-&& -4myled Click Apply and then Click =D efore building your application we need the dri$ers for led which is already in the =pen oard root file in home directory; 4home4led4driver-:o we ha$e to insert this dri$er before using the application so for this you ha$e a remote access of the open board. 1.4.9. &emote S stem Access using Eclipse For Windows : You have to set the address manually connect ethernet cable goto network connections right click on "Local area connection" -->properties -->under general tab double click on "Internet Protocol(T P!IP"" change the parameters For Linux : You have to set the address manually connect ethernet cable !o see all the interfaces present on the open board " ifconfig #a After this we got the particular interface then we ha$e to configure it. " ifconfig eth% &'(.&)*.&.&( up where eth% is the interface name. Again check whether it is configured or not " ifconfig #a !hen we ha$e to set the gateway " route add default gw &'(.&)*.&.&

www.phytec.in

6.

Revision no. 1.0

!o see the change in the gateway. " route Meft#click the Window tab. 5how $iew ####: others.. #######: <emote 5ystems and ok

-ow you are able to see the remote system page.

www.phytec.in

6:

Revision no. 1.0

1.4.1:. Create )e/ Connection %or &emote S stem login <ight Click on Mocal select new connection select linux

www.phytec.in

62

Revision no. 1.0

1.4.11. Set t#e Host )ame and IP !hen write 8ost name as &'(.&)*.&.&& and connection name as =pen oard.

5elect ssh.files

www.phytec.in

6*

Revision no. 1.0

select processes.shell.linux and next

select ssh.shells and next

www.phytec.in

6-

Revision no. 1.0

select ssh.terminals and finish -ow we successfully create the connection. Click on the open board >y 8ome

!hen a secure 5torage tab is opened just cancelled it.

www.phytec.in

10

Revision no. 1.0

!ype .ser I2 as root lea$e password as blank. !hen press =D. 1.4.12. $aunc# t#e &emote -erminal

-ow we can see all the contents of open board. If you want to open the =pen oard terminal just <ight click on 5sh !erminal and click on the Maunch !erminal.

www.phytec.in

11

Revision no. 1.0

1.4.1.. Insert t#e driver using t#e &emote -erminal ,o to the led directory and insert the dri$er into the kernel space. " cd led " ls " insmod dri$er.ko

www.phytec.in

16

Revision no. 1.0

5ince the dri$er is inserted in the kernel space now we can run our application 1.4.1.. Finall "uild t#e pro2ect

5elect 7roject 6 uild project from the menu bar !he project will be built. 5elect the Console tab. if no errors occur while building the project, you will see the following output; It will ask for a confirmation the type ye+ to allow.

All C ledPs starts blinking.

www.phytec.in

11

Revision no. 1.0

&-8- De)"00in0 an example pro2ect


&n this chapter you will learn using the =NA debugger =7, on the host for remote debugging in con;unction with the =7, server on the target. =7, is the symbolic debugger of the =NA pro;ect and is arguably the most important debugging tool for any %inux system. >irst you will start the =7, server on the target. "hen you will configure the #clipse platform and start the =NA debugger out of #clipse using the 7ebug view. "he $7" extends the standard #clipse 7ebug view with functions for debugging $5$// code. "he 7ebug view allows you to manage the debugging and running of a program in the wor+bench. Asing the 7ebug view you will be able to set brea+points5watchpoints in the code and trace variables and registers. "he 7ebug view displays the stac+ frame for the threads of each target you are debugging. #ach thread in your program appears as a node in the tree, and the 7ebug view displays the process for each target you are running. "he =7, client is running on the host and is used to control the =7, server on the target, which in turn controls the application running on the target. =7, client and =7, server can communicate over a "$P5&P networ+ connection as well as via a serial interface. &n this Muic+start we will only describe debugging via "$P5&P.

1.5.1. Starting t#e (D" server on t#e target &n this passage you will learn how to start the =7, server on the target. "he =7, server will be used to start and control the my ello<orld program. "o debug a program with =7,, the program needs extended debugging symbols. "his has already been added while building the program. 8pen 9inicom J minicom -7 5dev5ttyKK "ype root and press #nter

www.phytec.in

10

Revision no. 1.0

3tart the =7, server( J gdbserver 1-6.1:*.1.11(10000 myled !ou have started the =7, server on the target. "he =7, server is now waiting for connections on "$P port 10000. 1.5.2. Con%iguring and starting t#e de,ugger in Eclipse &n this passage you will learn how to configure your pro;ect settings to use #clipse with the =NA debugger. 'fter the configuration of your pro;ect settings, the =NA debugger will start and connect to the =7, server on the target. N 3tart #clipse if the application is not started yet N Right-clic+ on the my ello<orld pro;ect in the Navigator window N 3elect 7ebug 's O 7ebug $onfigurations ' dialog to create, manage and run applications appears. N 3elect my ello<orld under $5$// 'pplication

www.phytec.in

1.

Revision no. 1.0

3elect the 7ebugger tab

3elect gdbserver 7ebugger from the 7ebugger drop-down box $lic+ the ,rowse button right beside the =7, debugger input field. ' new dialog opens to choose the =7, executable. $lic+ on >ile 3ystem Navigate to the directory PPath of the "oolchainQ5bin 3elect the file arm-cortexa*-linux-gnueabi-gdb $lic+ 8)

www.phytec.in

1:

Revision no. 1.0

)eep the =7, command file field empty 3elect the $onnection tab and select "$P in the drop-down box #nter 1-6.1:*.1.11 Hthe targetBs &P addressI in the ost name input field. "he hostBs =7, will connect to this &P address to communicate with the targetBs =7, server

www.phytec.in

12

Revision no. 1.0

$lic+ 'pply $lic+ 7ebug ' new dialog appears.

3elect !es to switch to the 7ebug perspective

www.phytec.in

1*

Revision no. 1.0

"he debug perspective opens and the debugger stops automatically at the first line. "he hostBs =7, is now connected to the =7, server on the target.

!ou have configured your pro;ect for remote debugging. !ou have started the =NA debugger in #clipse and connected the hostBs =7, with the targetBs =7, server. !ou can now start to debug the pro;ect.

www.phytec.in

1-

Revision no. 1.0

1.5... Setting a "rea;point Now you will set a brea+point in your program. "he brea+point will be set on the last line of the function mainHI. &f you resume the application, the debugger will stop on this line.

3elect the last line in mainHI Right-clic+ into the small grey border on the left-hand side and select "oggle ,rea+point to set a new brea+point

www.phytec.in

00

Revision no. 1.0

1.5.3. Stepping and 0atc#ing <aria,le Contents &n this part you will step through the example pro;ect with the debugger. !ou will also learn how to chec+ the content of a variable. #xpand buf in the @ariables window

$lic+ the 3tep 8ver button in the 7ebug window to step to the next line

!ou will see the content of the buf variable in the @ariables window.

www.phytec.in

01

Revision no. 1.0

$lic+ on the variable buf "hen clic+ the button 3tep into to enter the function writeGttyHI

"he debugger stops in writeGttyHI. !ou will see the following variable window(

www.phytec.in

06

Revision no. 1.0

$lic+ on the variable buffer !ou will probably see a different address on the buffer pointer. Remember what address is shown in your caseR you will need this address later.

1.5.4. Stepping and 0atc#ing <aria,le Contents

&n this section you will change the value of a variable. 't the end of this part you will see the effect of this change. 3elect the count variable in the @ariables window Right-clic+ on count and select $hange @alue

www.phytec.in

01

Revision no. 1.0

$hange the value of count to 2 and clic+ 8) 8pen 9inicom if the application is not already opened =o bac+ to #clipse $lic+ the 3tep 8verbutton two times

$hange to 9inicom

!ou will see the output <elcome in the 9icrocom window. "his shows when changing the counter variableBs value to 2 only the first seven characters of the buffer are output, instead of the whole sentence.

1.5.5. *sing t#e 'emor 'onitor &n the last section of this chapter you will use the memory monitor to control the content at a memory address. 3elect the 9emory tab $lic+ 'dd 9emory 9onitor

#nter the address of buffer and clic+ 8). Remember that the variableBs address might differ from your system.

www.phytec.in

00

Revision no. 1.0

$hange the window siFe

$lic+ 'dd Rendering

3elect '3$&& and clic+ 8)

www.phytec.in

0.

Revision no. 1.0

!ou can see the contents of the variable buffer at the address 0xbee11ca2 Hor whatever address is used on your systemI. Now clic+ the Resume button from the menu bar

"he debugger stops at the brea+point in the last line of mainHI. $lic+ the Resume button to end the application

www.phytec.in

0:

Revision no. 1.0

2. Application development using Console -erminal


!ou can download the demo application from the phytec ftp using below lin+. 'fter downloading ;ust extract the file. J tar -xvf apps.tar.gF J cd final ,efore doing any thing please read the R'#79#.txt <e have to resolve some dependence as given below( ftp;//ftp.phytec.de/pub/7roducts/India/=pen oard# A>??@x/Minux/latest/src/apps/apps.tar.gO 83" 3&7#( 3tep-1( set the toolchain path edit the .bashrc file J vi S5.bashrc 3tep-6( 'dd the path of your toolchain at the last of this file and close the terminal J export P'" ETP'" (Pthe path of toolchain binQ Heg. go to toolchain5bin and type pwdI 3tep-1( #xport the path of your +ernel source location Heg. go to +ernel source and type pwdI J export )G3R$EPpath of your +ernel sourceQ 3tep-0( Run the 9a+efile J ma+e >inally you got all binary in related bin directory.

www.phytec.in

02

Revision no. 1.0

/-&- <+er ,ED=


"he 8pen ,oard-'911.x includes 0 %#7s listed as %#71, %#76, %#71, %#70 on the board. 2.1.1. Pre=&e>uists Aser %ed driver should be enabled in )ernel below is configuarion details. &t is already enable in our linux u&mage. &f you want to do it manually then. "ype ma+e menuconfig in linux +ernel source 3ystem "ype ---Q "& 89'P65150 3pecific >eatures ---Q UVW '911.K based phy$8R# '911.K andle '911.- 8penboard 9uxing ---Q UVW%ed driver 2.1.2.Compiling *ser $ed Application /-&-/-&- 5o+t ide First go to the application directory and then to the led directory. " cd final/led +xport the kernel source directory path, architecture, cross compiler " export DG5<CL/home/phytec/work//linux#?.( H!his is the path of your kernel sourceI " export A<C8Larm " export C<=55GC=>7IM+Larm#cortexa*#linux#gnueabi# After exporting these things just simply type make " make It will create a bin directory where dri$er.ko Hdri$er to be insertedI and ledGshared, ledGstatic Happlication to be executedI is created. /-&-/-/- (ar0et ide Copy the contents of the bin directory into the target using 52#CA<2, 558, !F!7, .5 . 5 scp dri$er.ko ledGshared rootQ&'(.&)*.&.&&;/home Insert the dri$er.ko into the kernel space using insmod " insmod dri$er.ko !hen run the Application " ./ledGshared It will blink the C leds @ times.

www.phytec.in

0*

Revision no. 1.0

/-/- <+er B<((O#=


!he =pen the board. oard#A>??@x includes C .!!=-P5 listed as !-&, !-(, !-?, !-C on

2.2.1. Pre=&e>uists .ser utton dri$er should be enabled in Dernel below is configuarion details. It is already enable in our linux uImage. If you want to do it manually then. ,o to the kernel directory and type make menuconfig " make menuconfig 5ystem !ype ###: !I =>A7(/?/C 5pecific Features ###: RFS A>??@A based phyC=<+ A>??@A 8andle A>??@' =penboard >uxing ###: RFS .ser uttons dri$er 2.2.2. Compiling *ser S/itc# Application 2.2.2.1. Host Side First go to the application directory and then to the button directory. " cd final/button +xport the kernel source directory path, architecture, cross compiler " export DG5<CL/home/phytec/work//linux#?.( H!his is the path of your kernel sourceI " export A<C8Larm " export C<=55GC=>7IM+Larm#cortexa*#linux#gnueabi# After exporting these things just simply type make " make It will create a bin directory where dri$er.ko Hdri$er to be insertedI and buttonGshared, buttonGstatic Happlication to be executedI is created. /-/-/-/- (ar0et ide Copy the contents of the bin directory into the target using 52#CA<2, !F!7, .5 , etc. Insert the dri$er.ko into the kernel space using insmod " insmod dri$er.ko !hen run the Application " ./buttonGshared It will blink the leds depends on the buttons pressed.

www.phytec.in

0-

Revision no. 1.0

/-3- ADC
"he 8pen ,oard-'911.x provided additional '7$ expansion for '7$ $annels there we have * channel. !ou find it out in the board at connector number K-.0. 2...1. Pre=&e>uists >or testing the '7$ you can use an P8" which loo+s li+e

'

()')

$% -I&

P#T *&% +e can connect ' ()') to ,-./0 *&% to ,-./11 and $% -I& to $I&.-$I&2
&n the above figure we are using a 10 + Potentiometer 2...2. Compiling *ser ADC Application /-3-/-&- 5o+t ide First go to the application directory and then to the adc directory. " cd final/adc +xport the kernel source directory path, architecture, cross compiler " export DG5<CL/home/phytec/work//linux#?.( H!his is the path of your kernel sourceI " export A<C8Larm " export C<=55GC=>7IM+Larm#cortexa*#linux#gnueabi# After exporting these things just simply type make

www.phytec.in

.0

Revision no. 1.0

" make It will create a bin directory where adcGam??@'.ko Hdri$er to be insertedI and adc Happlication to be executedI is created. /-3-/-/- (ar0et ide Copy the contents of the bin directory into the target using 52#CA<2, !F!7, .5 , etc. 5tep#&; Insert the dri$er file adcGam??@'.ko " insmod adcGam??@'.ko 5tep#(; <un the adc user app to print the adc $alue 5yntax; adc 9channelGnum: " ./adc & 5tep#?; Change the $alue of 7=! and obser$er the $alues printed on the screen. // channelGnum % to B

www.phytec.in

.1

Revision no. 1.0

2et t!e di lo' 'oin' """ """ nd st 3 in touc!


.ndia 781!+C +mbedded Mtd. "'/& &st Floor, ?rd >ain *th lock, =pp. 7olice 5tation Dormangala, angalore#@)%%'@ !el.; 0'&#*%C&?%B@*' www.phytec.in >ermany 781!+C >esstechnik ,mb8 <obert#Doch#5traTe ?' 2#@@&(' >ainO !el.; 0C' )&?& '((&#?( Fax; 0C' )&?& '((&#?? www.phytec.de www.phytec.eu America 781!+C America MMC (%? 7arfitt Way 5W, 5uite ,&%% ainbridge Island, WA '*&&% !el.; 0& (%) B*%#'%CB Fax; 0& (%) B*%#'&?@ www.phytec.com ?rance 781!+C France 5A<M &B, place 5t. +tienne F#B(&C% 5illU le ,uillaume !el.; 0?? ( C? (' (( ?? Fax; 0?? ( C? (' (( ?C www.phytec.fr

..................................We are looking forward to hearing from youV..................................

www.phytec.in

.6

Revision no. 1.0

S-ar putea să vă placă și