background image

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

Содержание phyBOARD RANA-AM335x

Страница 1: ...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...

Страница 2: ...arising from the improper usage or improper installation of the hardware or software PHYTEC Embedded Pvt Ltd further reserves the right to alter the layout and or design of the hardware without prior...

Страница 3: ...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...

Страница 4: ...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 I...

Страница 5: ...ace 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 Pane...

Страница 6: ...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 Creat...

Страница 7: ...un 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 O...

Страница 8: ...Now you can see the Eclipse workbench PHYTEC Embedded Pvt Ltd 2014 8...

Страница 9: ...pse 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 pro...

Страница 10: ...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...

Страница 11: ...ux gnueabi and the appropriate path of the toolchain 1 3 3 Open new C source file Right click on myHelloWorld project Select File New Source file from the menu bar In Source file write myHelloWorld c...

Страница 12: ...C cross compiler Modify Post build steps Right click the myHelloWorld project and chose Properties The Properties dialog box will appear Select C C Build Setting Select the Build Steps tab Enter the f...

Страница 13: ...t 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 usi...

Страница 14: ...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 u...

Страница 15: ...td 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...

Страница 16: ...program after changing the code Select Project Build 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 L...

Страница 17: ...d 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 functio...

Страница 18: ...You have to set the address manually for this refer section 1 2 2 1 Left click the Window tab Show view other Remote Systems and ok Now you are able to see the remote system page PHYTEC Embedded Pvt L...

Страница 19: ...ection 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 Embe...

Страница 20: ...Select ssh files select processes shell linux and next PHYTEC Embedded Pvt Ltd 2014 20...

Страница 21: ...select ssh shells and next select ssh terminals and finish Now the connection has been created successfully PHYTEC Embedded Pvt Ltd 2014 21...

Страница 22: ...Click on the Rana Board Sftp Files My Home Type 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...

Страница 23: ...1 5 3 Launch the Remote Terminal Right click Ssh Terminal Launch Terminal Now we can see all the contents of phyBOARD RANA AM335x PHYTEC Embedded Pvt Ltd 2014 23...

Страница 24: ...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...

Страница 25: ...lipse if the application is not started yet Right click on the myHelloWorld project in the Navigator window Select Debug As Debug Configurations A dialog to create manage and run applications appears...

Страница 26: ...te 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...

Страница 27: ...Click Apply Click Debug A new dialog appears Select Yes to switch to the Debug perspective PHYTEC Embedded Pvt Ltd 2014 27...

Страница 28: ...ger 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 wi...

Страница 29: ...ew 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...

Страница 30: ...uf 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...

Страница 31: ...nge 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 O...

Страница 32: ...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...

Страница 33: ...able 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...

Страница 34: ...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 91...

Отзывы: