Phytec phyBOARD RANA-­AM335x User Manual

phyBOARD RANA-AM335x
Single Board Computer
Application Development User Manual
Product No : PCL-051/PBA-CD-03 SOM PCB No : 1397.0 CB PCB No : 1404.0 Edition : Mar 10, 2014
The information in this document has been carefully checked and is believed to be entirely reliable. However, PHYTEC Embedded Pvt. Ltd. assumes no responsibility for any inaccuracies. PHYTEC Embedded Pvt. Ltd neither gives any guarantee nor accepts any liability whatsoever for consequential damages resulting from the use of this manual or its associated product. PHYTEC Embedded Pvt. Ltd reserves the right to alter the information contained herein without prior notification and accepts no responsibility for any damages that might result.
© Copyright 2014 PHYTEC Embedded Pvt. Ltd, Koramangala Bangalore. 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 PHYTEC Embedded Pvt. Ltd.
India Europe North America
Address: PHYTEC Embedded Pvt.
Ltd. # 16/9C, 3rd Floor, 3rd Main, 8th Block, Opp: Police Station, Koramangala, Bangalore -560095 INDIA
PHYTEC Technologie Holding AG Robert-Koch-Str. 39 55129 Mainz GERMANY
PHYTEC America LLC 203 Parfitt Way SW, Suite G100 Bainbridge Island, WA 98110 USA
Ordering Information:
+91-80-40867046
Sales@phytec.in
+49 (800) 0749832
order@phytec.de
1 (800) 278-9913
sales@phytec.com
Web Site: http://www.phytec.in http://www.phytec.de http://www.phytec.com
PHYTEC Embedded Pvt. Ltd 2014 2
Table of Contents
Introduction..........................................................................................................................................4
1. Application development using Eclipse IDE...............................................................................4
1.1. Eclipse IDE Installation.......................................................................................................4
1.2. Eclipse IDE Configuration for phyBOARD-RANA-AM335x............................................5
1.2.1. Host Setup....................................................................................................................5
For Linux:.....................................................................................................................5
For Windows:................................................................................................................5
1.2.2. Target Setup..................................................................................................................6
1.3. Creating a New Project in Eclipse.......................................................................................6
1.3.1. How to open eclipse.....................................................................................................7
For Linux:-.........................................................................................................................7
For windows:-....................................................................................................................7
1.3.2 Creating a New Project..................................................................................................9
1.3.3. Open new C source file..............................................................................................11
1.3.4. Write simple Hello Application..................................................................................12
1.3.5. Build the project.........................................................................................................14
1.4. Changing the Demo Application........................................................................................15
1.4.1. Open Target Board using Minicom............................................................................17
1.5. Remote System Access using Eclipse................................................................................17
For Windows :..................................................................................................................17
For Linux :.......................................................................................................................18
1.5.1. Create New Connection for Remote System login....................................................19
1.5.2. Set the Host Name and IP...........................................................................................19
1.5.3. Launch the Remote Terminal.....................................................................................23
1.6. Debugging an example project...........................................................................................24
1.6.1. Starting the GDB server on the target........................................................................24
1.6.2. Configuring and starting the debugger in Eclipse......................................................25
1.6.3. Setting a Breakpoint...................................................................................................28
1.6.4. Stepping and Watching Variable Contents.................................................................29
1.6.5. Stepping and Watching Variable Contents.................................................................31
1.6.6. Using the Memory Monitor........................................................................................32
PHYTEC Embedded Pvt. Ltd 2014 3
Introduction
This Reference Manual describes the phyBOARD-RANA-AM335x for application development. First chapter describes the installation of eclipse and how to develop an application on phyBOARD-RANA-AM335x using Eclipse IDE. Second chapter describes about how to write an application using console terminal. After completing this manual you will come to know how to use the Eclipse.
1. Application development using Eclipse IDE
During this chapter you will learn how to build your own C/C++ applications for the target with the help of Eclipse. We will start developing our own applications with the help of Eclipse. First we will take a look on the C programming language. At the end of this chapter we will explain how to execute your written programs automatically when booting the target.
1.1. Eclipse IDE Installation
Download the Eclipse IDE from the below link(Note: According to your system configuration) and install.
For Linux:
Install java using below command:
$ sudo apt-get install openjdk-7-jdk openjdk-7-jre
Download eclipse from below link
http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/junosr2
For windows:
Download and install the java for windows using below link:
http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-
1880261.html
Download eclipse from below link
http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/junosr2
PHYTEC Embedded Pvt. Ltd 2014 4
1.2. Eclipse IDE Configuration for phyBOARD-RANA-AM335x
1.2.1. Host Setup
Toolchain: For Compiling the Application we need the toolchain which you can easily download from the below link.
For Linux:
ftp://ftp.phytec.de/pub/Products/India/phyBOARD-RANA­AM335x/Linux/PD13.0.0/tools/toolchain/arm-cortexa8-linux-gnueabihf.tar.bz2
Set ip Address
$ ifconfig eth0 192.168.1.12 up
Ths will be used as server IP address
Note : Where eth0 is the LAN Interface.
Set the gateway
# route add default gw 192.168.1.1
For Windows:
http://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-
2012.09-64-arm-none-linux-gnueabi.exe
Click Start ► Control Panel ► open Network and Sharing CenterFrom the Tasks menu on the left, choose Manage Network Connections Find and Right click on the active Local Area Connection and choose
Properties
Double-click on Internet Protocol Version 4 (TCP/IPv4) Click on Use the following IP address Enter a IP like 192.168.1.12 Press Tab and the Subnet Mask section will populate with default
numbers
Enter gateway 192.168.1.1 Hit Ok .
PHYTEC Embedded Pvt. Ltd 2014 5
1.2.2. Target Setup
Connect the power adaptor, serial cable, ethernet cable to the Rana AM335x Board & Boot the Board.
To see all the Communication interfaces present on the Rana AM335x Board
# ifconfig -a
Configure eth0.
# ifconfig eth0 192.168.1.15 up
where eth0 is the LAN interface.
Check whether eth0 is configured or not by using the below command.
# ifconfig -a
Note
192.168.1.15 is not mandatory you can use any IP but it should be
different from the server IP.
Set the gateway
# route add default gw 192.168.1.1
To see the change in the gateway.
# route
1.3. Creating a New Project in Eclipse
In this section you will learn how to create a new project with Eclipse and how to configure the project for use with the GNU C/C++ cross development toolchain. Click the Eclipse icon to start the application. You can find this icon where you have extracted the Eclipse IDE for C/C++ Developers .
PHYTEC Embedded Pvt. Ltd 2014 6
1.3.1. How to open eclipse
For Linux:-
Go to the Location where you have downloaded eclipse, Extract it and run
binary file ./eclipse
Confirm the workspace directory with OK
For windows:-
Click the Eclipse icon to start the application. You can find this icon on
your desktop.
Confirm the workspace directory with OK
Close the "Welcome to Eclipse" screen by clicking on the "workbench"
button
PHYTEC Embedded Pvt. Ltd 2014 7
Now you can see the Eclipse workbench.
PHYTEC Embedded Pvt. Ltd 2014 8
1.3.2 Creating a New Project
In this section we will learn how to create a new project with Eclipse and how to configure the project for use with the GNU C/C++ cross development toolchain.
Select File ► New ► Project from the menu bar. A new dialog will open.
Select C Project and click Next
Enter the project name myHelloWorld and Toolchain as Cross GCC then
click Next
PHYTEC Embedded Pvt. Ltd 2014 9
Click Next
Set Toolchain Prefix & Path and Click Finish
Select the Cross Compiler Prefix as arm-cortexa8-linux-gnueabihf- and Cross Compiler Path as <path of toolchain bin>
PHYTEC Embedded Pvt. Ltd 2014 10
Note
For windows you have to select the arm-none-linux-gnueabi- and the appropriate path
of the toolchain.
1.3.3. Open new C source file
Right-click on myHelloWorld project
Select FileNewSource file from the menu bar
In Source file write myHelloWorld.c and click on Finish.
`
PHYTEC Embedded Pvt. Ltd 2014 11
1.3.4. Write simple Hello Application
Write a simple Hello Application in C.
` To compile your project for the phyBOARD-RANA-AM335x instead, you will have to use the GNU C/C++ cross compiler.
Modify Post build steps:
Right-click the myHelloWorld project and chose Properties
The Properties dialog box will appear.
Select C/C++ BuildSetting ► Select the Build Steps tab
Enter the following command in the Post-build steps Command input field:
scp ./myHelloWorld root@192.168.1.15:/home ;ssh
root@192.168.1.1 5 ./myHelloWorld
PHYTEC Embedded Pvt. Ltd 2014 12
Note
First login manually using ssh as shown in snapshot below. Otherwise we will not be able to login in target because it requires secure connection
Note
If you are using windows so you have to use Winscp or directly copy the binary into target board using pen drive or sd card.
PHYTEC Embedded Pvt. Ltd 2014 13
Click Apply
Click OK
1.3.5. Build the project
Select ProjectBuild project from the menu bar
The project will be built.
Select the Console tab.
if no errors occur while building the project, you will see the following output:
Note
If you are using Window machine then you need the make utils using the
below link.
ftp://ftp.equation.com/make/32/make.exe
PHYTEC Embedded Pvt. Ltd 2014 14
1.4. Changing the Demo Application
Now we will extend the myHelloWorld application. The extended myHelloWorld application will write an output to the first serial interface as well as to the standard output.
Open Eclipse if it is not opened yet
Double-click myHelloWorld.c in the myHelloWorld project
First include the following two additional header files:
#include <unistd.h> #include <fcntl.h>
Then add the function write_tty(), which writes n bytes to the first serial interface (which, on the phyBOARD-RANA-AM335x, is connected to the system console /dev/console):
void write_tty (char *buffer, int count)
{
int out;
out = open ("/dev/console", 666);
write(out, buffer, count); close(out);
}
Enter the following two lines in the main() function to declare the buffer and call the write_tty() function.
char buf [] = { "Welcome to the World of the Rana-AM335x! (serial)\n" };
write_tty(buf, sizeof (buf) - 1);
In the next screenshot you can see the complete program.
PHYTEC Embedded Pvt. Ltd 2014 15
Save your program after changing the code.
Select ProjectBuild project from the menu bar
The project will be build...
The application will be compiled, built, copied to the target and executed.
PHYTEC Embedded Pvt. Ltd 2014 16
1.4.1. Open Target Board using Minicom
Open the terminal using minicom-
# sudo minicom -D /dev/ttyXX
Note
where XX is the Node Number.In case of USB-to-Serial converter it will be USB*.
Enter user name root and press Enter then type ls to see all the file.
# ls
Run ./myHelloWorld to start the application
# ./myHelloWorld
Hello World
Welcome to the World of the Rana-AM335x! (serial)
close minicom.
In this section we had changed an existing application. We had also learned how to access the serial interface. First we called the function open() on the device /dev/console. The return value of this function was a file descriptor. With the file descriptor you called the function write() to send n bytes to the device /dev/console. After that, the file descriptor was closed with the function close().
1.5. Remote System Access using Eclipse
For Windows :
You have to set the address manually
connect ethernet cable
Go to network connections
right click on "Local area connection" ► properties ► under general tab
double click on "Internet Protocol(TCP/IP)"
change the parameters
For above settings, refer section 1.2.1
PHYTEC Embedded Pvt. Ltd 2014 17
For Linux :
You have to set the address manually ,for this refer section 1.2.2.1
Left-click the Window tab
Show viewotherRemote Systems and ok
Now you are able to see the remote system page.
PHYTEC Embedded Pvt. Ltd 2014 18
1.5.1. Create New Connection for Remote System login
Right Click on Local select new connection
select linux
1.5.2. Set the Host Name and IP
Then write Host name as 192.168.1.15 and connection name as Rana Board.
PHYTEC Embedded Pvt. Ltd 2014 19
Select ssh.files
select processes.shell.linux and next
PHYTEC Embedded Pvt. Ltd 2014 20
select ssh.shells and next
select ssh.terminals and finish
Now the connection has been created successfully
PHYTEC Embedded Pvt. Ltd 2014 21
Click on the Rana BoardSftp FilesMy HomeType User ID as root leave password blank. Then press OK.
Then a secure Storage tab is opened just cancel it.
PHYTEC Embedded Pvt. Ltd 2014 22
1.5.3. Launch the Remote Terminal
Right click Ssh TerminalLaunch Terminal
Now we can see all the contents of phyBOARD-RANA-AM335x.
PHYTEC Embedded Pvt. Ltd 2014 23
1.6. Debugging an example project
In this section, we will learn how to use the GNU debugger i.e., GDB on
the host for remote debugging in conjunction with the GDB server on the target.
 First, start the GDB server on the target. Then configure the Eclipse platform
and start the GNU debugger of Eclipse using the Debug view.
The GDB client is running on the host and is used to control the GDB
server on the target, which in turn controls the application running on the target.
 GDB client and GDB server can communicate over a TCP/IP network
connection as well as via a serial interface. In this Quickstart we will only describe debugging via TCP/IP.
1.6.1. Starting the GDB server on the target
In this passage you will learn how to start the GDB server on the target. The GDB server will be used to start and control the myHelloWorld program.
To debug a program with GDB, the program needs extended debugging symbols.
This has already been added while building the program.
Open Minicom
#sudo minicom -D /dev/ttyXX
Note : where XX is the Node Number. In case of USB-to-Serial converter it will be USB*
Type user name “root” and press Enter
Start the GDB server:
# gdbserver 192.168.1.12:10000 myHelloWorld
You have started the GDB server on the target. The GDB server is now waiting for connections on TCP port 10000.
PHYTEC Embedded Pvt. Ltd 2014 24
1.6.2. Configuring and starting the debugger in Eclipse
In this passage we will learn how to configure our project settings to use Eclipse with the GNU debugger. After the configuration of our project settings, the GNU debugger will start and connect to the GDB server on the target.
Start Eclipse if the application is not started yet
Right-click on the myHelloWorld project in the Navigator window
Select Debug AsDebug Configurations
A dialog to create, manage and run applications appears.
Double click on C/C++ Remote Application ► select myHelloWorld Debug
Note
Make sure that on the bottom of the Debug configuration Window it says “Using GDB (DSF) Manual Remote Debugging Launcher”. If it does not, then click on the “Select Other” and select this option.
PHYTEC Embedded Pvt. Ltd 2014 25
Select the Debugger tabClick the Browse button right beside the GDB debugger input field.
Navigate to the directory <Path of the Toolchain>/bin/arm-cortexa8-linux-
gnueabihf-gdb
Click OK
Select the Connection tab and select TCP in the drop-down box
Enter 192.168.1.15 (the target's IP address) in the Host name input field.
And port numer 10000.As shown in next page.
PHYTEC Embedded Pvt. Ltd 2014 26
Click Apply
Click Debug
A new dialog appears.
Select Yes to switch to the Debug perspective
PHYTEC Embedded Pvt. Ltd 2014 27
The host's GDB is now connected to the GDB server on the target.
We have configured our project for remote debugging. We have started the GNU debugger in Eclipse and connected the host's GDB with the target's GDB server. We can now start to debug the project.
1.6.3. Setting a Breakpoint
Now we will set a breakpoint in our program. This breakpoint will be set on the last line of the function main(). If you resume the application, the debugger will stop on this line.
PHYTEC Embedded Pvt. Ltd 2014 28
Select the last line in main() .Right-click into the small grey border on the left­hand side and select Toggle Breakpoint to set a new breakpoint
1.6.4. Stepping and Watching Variable Contents
In this part we will step through the example project with the debugger. we will also learn how to check the content of a variable. Expand buf in the Variables window
Click the Step Over button in the Debug window to step to the next line
PHYTEC Embedded Pvt. Ltd 2014 29
we will see the content of the buf variable in the Variables window.
Click on the variable buf
Then click the button Step into to enter the function write_tty()
The debugger stops in write_tty().
we will see the following variable window:
PHYTEC Embedded Pvt. Ltd 2014 30
Click on the variable buffer,as pointed in above figure.
we will probably see a different address on the buffer pointer. Remember what address is shown in our case; we will need this address later.
1.6.5. Stepping and Watching Variable Contents
In this section we will change the value of a variable. At the end of this part we will see the effect of this change.
Select the count variable in the Variables window
Double click on value and Change Value to 7
Click the Step Overbutton two times
Change to Minicom
we will see the output Welcome in the Minicom window. This shows when changing the counter variable's value to 7 only the first seven characters of the buffer are output, instead of the whole sentence.
PHYTEC Embedded Pvt. Ltd 2014 31
1.6.6. Using the Memory Monitor
In the last section of this chapter you will use the memory monitor to control the content at a memory address.
Select the Memory tab
Click Add Memory Monitor
Enter the address of buffer and click OK. Remember that the variable's
address might differ from your system.
You will see following output.
Click New RenderingSelect ASCII and click Add Rendering(s).
PHYTEC Embedded Pvt. Ltd 2014 32
You will see follwing output on your screen.
You can see the contents of the variable buffer at the address 0xbeeb7c34 (or whatever address is used on your system).
Now click the Resume button from the menu bar
The debugger stops at the breakpoint in the last line of main() i.e return0.
Click the Resume button to end the application.
PHYTEC Embedded Pvt. Ltd 2014 33
Get the dialog going ...
... and stay in touch
India
PHYTEC Embedded Pvt. Ltd.
# 16/9C, 3rd Floor, 3rd Main, 8th Block, Opp: Police Station,
Koramangala,
Bangalore -560095
www.phytec.in
Germany
PHYTEC Messtechnik GmbH
Robert-Koch-Straße 39
D-55129 Mainz Tel.: +49 6131 9221-32 Fax: +49 6131 9221-33
www.phytec.de www.phytec.eu
America
PHYTEC America LLC
203 Parfitt Way SW, Suite G100
Bainbridge Island, WA 98110
Tel.: +1 206 780-9047
Fax: +1 206 780-9135
www.phytec.com
France
PHYTEC France SARL
17, place St. Etienne
F-72140 Sillé le Guillaume
Tel.: +33 2 43 29 22 33 Fax: +33 2 43 29 22 34
www.phytec.fr
..................................We are looking forward to hearing from you!..................................
PHYTEC Embedded Pvt. Ltd 2014 34
Loading...