Phytec phyCORE-AM335x Programming manual

A product of a PHYTEC Technology Holding company
phyCORE®-AM335x
QuickStart Instructions
Document No.: L-779e_6
Release Nos.: SO-498v6
PD15.2.1
Ubuntu 14.04
Edition: April 2016

phyCORE®-AM335x [PCM-051-xxx]
©PHYTEC Messtechnik GmbH 2016 L-779e_6
Copyrighted products are not explicitly indicated in this manual. The absence of the trademark (™, or ®)
and copyright (©) symbols does not imply that a product is not protected. Additionally, registered patents
and trademarks are similarly not expressly indicated in this manual.
The information in this document has been carefully checked and is considered to be entirely reliable.
However, PHYTEC Messtechnik GmbH assumes no responsibility for any inaccuracies. PHYTEC Messtechnik
GmbH neither gives any guarantee nor accepts any liability whatsoever for consequential damages
resulting from the use of this manual or its associated product. PHYTEC Messtechnik GmbH reserves the
right to alter the information contained herein without prior notification and accepts no responsibility for
any damages that might result.
Additionally, PHYTEC Messtechnik GmbH offers no guarantee nor accepts any liability for damages arising
from the improper usage or improper installation of the hardware or software. PHYTEC Messtechnik GmbH
further reserves the right to alter the layout and/or design of the hardware without prior notification and
accepts no liability for doing so.
©Copyright 2016 PHYTEC Messtechnik GmbH, D-55129 Mainz.
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 occur
without the express written consent from PHYTEC Messtechnik GmbH.
EUROPE NORTH AMERICA FRANCE
Address: PHYTEC Messtechnik GmbH
Robert-Koch-Str. 39
D-55129 Mainz
GERMANY
PHYTEC America LLC
203 Parfitt Way SW
Bainbridge Island, WA 98110
USA
PHYTEC France
17, place Saint-Etienne
F-72140 Sillé-le-Guillaume
FRANCE
Sales: +49 6131 9221-32
+1 800 278-9913
+33 2 43 29 22 33
Technical
Support:
+49 6131 9221-31
+1 206 780-9047
Fax: +49 6131 9221-33 +1 206 780-9135 +33 2 43 29 22 34
Web Site: http://www.phytec.de
http://www.phytec.eu
http://www.phytec.com http://www.phytec.fr
INDIA CHINA
Address: PHYTEC Embedded Pvt. Ltd.
#16/9C, 3rd Main, 3rd Floor, 8th Block,
Opp. Police Station Koramangala,
Bangalore-560095
INDIA
PHYTEC Information Technology (Shenzhen) Co. Ltd.
Suite 2611, Floor 26, Anlian Plaza,
4018 Jin Tian Road
Futian District, Shenzhen
CHINA 518026
Sales: +91-80-4086 7046/48
+86-755-3395-5875
Technical
Support:
+91-80-4086 7047
Fax: +86-755-3395-5999
Web Site: http://www.phytec.in http://www.phytec.cn
6th Edition April 2016

Contents
©PHYTEC Messtechnik GmbH 2016 L-779e_6 i
Conventions, Abbreviations and Acronyms ....................................................................iii
1Introduction ...................................................................................................... 1
1.1 Rapid Development Kit Documentation ............................................................. 1
1.2 Professional Support Packages Available ........................................................... 1
1.3 Overview of these QuickStart Instructions .......................................................... 2
1.4 System Requirements .................................................................................... 2
1.5 Software used in the Virtual Machine Hard Disk Image.......................................... 2
1.5.1 Ubuntu............................................................................................ 2
1.5.2 Eclipse............................................................................................. 3
1.5.3 Qt Creator ........................................................................................ 3
1.5.4 Yocto Project .................................................................................... 3
2Getting Started................................................................................................... 5
2.1 Preparing and Starting the virtual machine ........................................................ 5
2.2 Starting the Hardware ................................................................................... 7
3Working with Eclipse ......................................................................................... 13
3.1 Programming in the C/C++ Perspective.............................................................13
3.1.1 Work with the Demo Project ................................................................13
3.1.2 Creating a New Project .......................................................................18
3.1.3 Modifying the Demo Application ..........................................................25
3.1.4 Starting a Program out of Eclipse on the Target.......................................27
3.2 Debugging an Example Project .......................................................................29
3.2.1 Starting the GDB Server on the Target ...................................................30
3.2.2 Configuring and Starting the Debugger in Eclipse....................................30
3.2.3 Setting a Breakpoint .........................................................................35
3.2.4 Stepping through and Watching Variable Contents ..................................36
3.2.5 Stepping through and Changing Variable Contents ..................................38
3.2.6 Using the Memory Monitor..................................................................39
4Working with Qt Creator..................................................................................... 43
4.1 Stop the Running Qt Demo on the Target ..........................................................43
4.2 Importing the Demo Application .....................................................................44
4.3 Work with the Demo Application .....................................................................46
4.4 Compile and Run the Demo Application on the Target..........................................49
4.5 Compile and Run the Demo Application on the Host............................................51
4.6 Debugging the Demo Application....................................................................53
4.6.1 Using QDebug for simple Debugging Messages........................................53
4.6.2 Using the integrated Qt Creator Debugger .............................................55
5Getting Started with the BSP .............................................................................. 59
5.1 Add new Packages to the Root Filesystem with Yocto...........................................59
5.2 Writing the Root Filesystem into the Target’s Flash .............................................63

phyCORE®-AM335x [PCM-051-xxx]
ii ©PHYTEC Messtechnik GmbH 2016 L-779e_6
6Setup your own Linux Host PC ............................................................................. 67
6.1 Essential Settings ....................................................................................... 67
6.1.1 Installing Ubuntu ............................................................................ 67
6.1.2 Installation of Software Packages........................................................ 69
6.1.3 Set the Git Configuration................................................................... 70
6.1.4 Build the Board Support Package and Install the SDK .............................. 70
6.1.5 Set up Eclipse and Integrate Plug-ins................................................... 72
6.1.6 Install and Setup Qt Creator................................................................ 74
6.1.7 Setting up a TFTP server..................................................................... 81
6.1.8 Optional Settings............................................................................. 82
7Revision History................................................................................................ 83

Conventions, Abbreviations and Acronyms
Conventions, Abbreviations and Acronyms
The following is a list of the typographical conventions used in this book:
Conventions
The conventions used in this manual are as follows:
Signals that are preceded by an "n", "/", or “#”character (e.g.: nRD, /RD, or #RD), or
that have a dash on top of the signal name (e.g.: RD) are designated as active low
signals. That is, their active state is when they are driven low, or are driving low.
A "0" indicates a logic zero or low-level signal, while a "1" represents a logic one or
high-level signal.
The hex-numbers given for addresses of I2C devices always represent the 7 MSB of the
address byte. The correct value of the LSB which depends on the desired command
(read (1), or write (0)) must be added to get the complete address byte. E.g. given
address in this manual 0x41 => complete address byte = 0x83 to read from the device
and 0x82 to write to the device.
Tables which describe jumper settings show the default position in bold, blue text.
Text in blue italic indicates a hyperlink within, or external to the document. Click these
links to quickly jump to the applicable URL, part, chapter, table, or figure.
Text in bold italic indicates an interaction by the user, which is defined on the screen.
Text in Consolasindicates an input by the user, without a premade text or button to
click on.
Text in italic indicates proper names of development tools and corresponding controls
(windows, tabs, commands etc.) used within the development tool, no interaction
takes place.
White Text on black background shows the result of any user interaction (command,
program execution, etc.)
©PHYTEC Messtechnik GmbH 2016 L-779e_6 iii

phyCORE®-AM335x [PCM-051-xxx]
At this icon you might leave the path of this Application Guide.
This is a warning. It helps you to avoid annoying problems.
You can find useful supplementary information about the topic.
At the beginning of each chapter you can find information about the time
required to read the following chapter.
You have successfully completed an important part of this Application
Guide.
You can find information to solve problems.
iv ©PHYTEC Messtechnik GmbH 2016 L-779e_6

Introduction
©PHYTEC Messtechnik GmbH 2016 L-779e_6 1
1Introduction
In this QuickStart Instructions Manual you will find general information about the Phytec
phyCORE-AM335x Kit and instructions how to start up with the phyCORE-AM335x. You will
learn how to...
… use the prepared virtual machine hard disk image.
... connect to the target.
... handle with the Yocto Project and our Board Support Package to build your own images.
... work with Eclipse and Qt Creator .
... setup your own Linux host system.
This first section gives a short introduction on the Phytec phyCORE-AM335x Kit and its
QuickStart. Also, you will find general requirements and information to successfully pass the
QuickStart.
1.1 Rapid Development Kit Documentation
This
Rapid Development Kit
(RDK) includes the following electronic documentation on the
virtual machine's hard disk under /opt/PHYTEC_Tools/Documentation.
The Phytec phyCORE-AM335x Hardware Manual
Hardware schematics
The
Yocto
Reference Manual
The BSP Manual
These QuickStart Instructions
1.2 Professional Support Packages Available
If you have any questions concerning installation and setup, you are welcome to contact
our support department.
For more in-depth questions, we offer a variety of custom-tailored packages with different
support options (e-mail, phone, direct contact to the developer) and different reaction
times.
Please contact our sales team to discuss the appropriate support option if professional
support beyond installation and setup is important for you. For more information please
refer to the following sources:
http://www.phytec.de/support/support-pakete/
http://www.phytec.eu/europe/support/support-packages.html
More contact information can be found on page 2.

phyCORE®-AM335x [PCM-051-xxx]
2©PHYTEC Messtechnik GmbH 2016 L-779e_6
1.3 Overview of these QuickStart Instructions
This QuickStart gives you an overview of the phyCORE-AM335x. Its content ranges from the
first startup, to building your own kernel and file system, to the point of building your own
program with
Eclipse
and
Qt Creator
. This QuickStart is structured as follows:
The Getting Started section describes the basics such as configuring your host platform
and starting the phyCORE-AM335x platform.
The Working with Eclipse explains how to modify an example application, create, build,
debug a new project, and copy programs to the phyCORE-AM335x using Eclipse with the
C/C++ CDT plugin.
The Working with Qt Creator section explains how to modify an example application,
create, build, debug a new project, and copy programs to the phyCORE-AM335x using
Qt
Creator
.
The
Working with Yocto
section explains how to add new packages to our Board Support
Package, build a new root filesystem and copy the root filesystem into the target’s Flash.
The Setup your own Linux-Host-PC section explains how to setup your own Linux host PC if
you do not want to use our virtual machine hard disk image.
1.4 System Requirements
The following items will be needed to complete this QuickStart successfully:
The Phytec phyCORE-AM335x
The Phytec Development Board with the included DB-9 serial cable, Ethernet crossover
cable and AC adapter supplying 5 VDC (min. 2 A)
The Phytec virtual machine hard disk image (
SO-498v6
) available on the enclosed USB
flash drive
An IBM-compatible host-PC (586 or higher) with 512 MB RAM (or more)
1.5 Software used in the Virtual Machine Hard Disk Image
1.5.1 Ubuntu
Ubuntu - which is used as operating system for our virtual machine - is a free and open
source operating system based on Debian Linux. Basically it is designed for desktop use.
Web statistics suggest that Ubuntu is one of the most popular operating systems in the
Linux desktop environment.
The Ubuntu release which we deliver is 14.04.4 and was released on 18. February 2016.
Ubuntu 14.04 code name "Trusty Tahr" is designated as a Long Term Support (LTS) release
and the first stable release was on 17. April 2014. LTS means that it will be supported and
updated for five years.

Introduction
©PHYTEC Messtechnik GmbH 2016 L-779e_6 3
Our Ubuntu version comes with Unity as desktop environment, dpkg as package
management system, the update method is based on APT (Advanced Packaging Tool) and
the user space uses GNU.
1.5.2 Eclipse
The Eclipse platform provides support for C/C++. Because the Eclipse platform is only a
framework for developer tools, it does not support C/C++ directly, instead it uses external
plug-ins. This QuickStart shows you how to make use of the CDT plug-in.
The CDT is an open source project (licensed under the Common Public License)
implemented purely in Java as a set of plug-ins for the Eclipse SDK platform. These plug-ins
add a C/C++ perspective to the Eclipse Workbench that can now support C/C++ development
with a number of views and wizards, along with advanced editing and debugging support.
1.5.3 Qt Creator
Qt Creator is a cross-platform development environment for the Qt framework. Included are
a code editor and a Qt Designer to build graphical user interfaces (GUI). It uses the GNU
C/C++ compiler.
1.5.4 Yocto Project
The Yocto Project is an open source collaboration to create custom Linux-based systems for
embedded products regardless of the hardware architecture. We use the Yocto Project to
create the Board Support Package (BSP) for our hardware.

phyCORE®-AM335x [PCM-051-xxx]
4©PHYTEC Messtechnik GmbH 2016 L-779e_6

Getting Started
2Getting Started
2.1 Preparing and Starting the virtual machine
©PHYTEC Messtechnik GmbH 2016 L-779e_6 5
To follow this QuickStart you need our phyCORE-AM335x virtual machine hard disk image.
The hard disk image includes all software installations and configurations (e.g. pre-built
Yocto BSP, Eclipse, Qt Creator) necessary for a successful start-up of the phyCORE-AM335x.
The compressed image (SO-498v6.zip) on the enclosed USB flash drive includes the virtual
machine disk file (.vmdk). It is suitable for most virtualization software, and can be
mounted to an appropriate virtual machine (tested with VMware Player and VirtualBox).
The SO-498v6.vmdk included in the compressed image is not a complete
virtual machine, it is solely a hard disk image.
Perform the following steps to mount the virtual machine disk file (.vmdk):
1. Plug in the USB flash drive.
2. Unpack the compressed VM hard disk image from the USB flash drive to your hard
disk.
3. Follow the instructions of your virtualization software to create a new virtual
machine. However, pay regard to the following settings required to obtain a
correctly working virtual machine:
-choose Linux-Ubuntu 64-bit version as operating system
-use the file SO-498v6.vmdk as hard disk (in Virtualbox you will choose the hard
disk image while creating a new virtual machine. In VMware you can mount the
hard disk image only after you created the new virtual machine by removing the
hard disk created automatically and adding SO-498v6.vmdk instead)
-a network adapter (NAT), as well as a serial interface, or the USB controller must
be available to connect to the phyCORE-AM335x
In order to avoid any conflicts we recommend to have only the Ethernet
adapter in the virtual machine which will be used for the peer to-peer
connection between your PC and the phyCORE-AM335x.
To ensure successful introduction to the development with the
phyCORE-AM335x we strongly recommend continuing with the prepared
virtual machine hard disk image.
Nonetheless, if you want to use your already existing environment we
explain how to modify your system to get the same experience as with our
virtual machine in section 6. Please be advised that use of your already
existing environment is on your own risk. We can not guarantee to
successfully support you with your own environment.

phyCORE®-AM335x [PCM-051-xxx]
4. Start the virtual machine with our hard disk image.
You will see the modified Ubuntu desktop :
For further use of the virtual machine the pre-created login data is:
username: „phyvm“ — password: „phytec“.
Now you are ready to connect your PC with the phyCORE-AM335x.
6©PHYTEC Messtechnik GmbH 2016 L-779e_6

Getting Started
2.2 Starting the Hardware
In this section you will learn how to connect your host PC to the target. The connection will
be done using a cross-over Ethernet cable and a serial one-to-one cable. You will start
Linux from the Flash memory on the target and you will be able to log in with the serial
communication program Microcom as well as via a SSH session using a peer-to-peer
network connection.
By default every input and output is transmitted over the serial
connection with a baud rate of 115200.
Connect the serial cable to the to RS-232 connector X18 (UART0) on the target and the
first serial interface on your host.
Be sure to use the one-to-one serial cable included in this Rapid
Development Kit.
Connect the cross-over Ethernet cable to the Ethernet connector X12 (ETH1) on the
target and to the appropriate network card of your host, which is passed on the virtual
machine.
Click the Microcom_ttyS0 icon on your desktop, if you have connected the target to your
serial interface on your host. If you have connected the serial cable with an USB dongle
to your PC click the Microcom_ttyUSB0 icon on your desktop.
Connect the AC adapter to the power supply connector (+5 V DC) on your board.
After connecting the board to the power supply, the target starts booting and the outputs
will be shown in the
Microcom
terminal while booting. When the target has finished
loading the system, you should see a screen similar to the following:
©PHYTEC Messtechnik GmbH 2016 L-779e_6 7

phyCORE®-AM335x [PCM-051-xxx]
Enter root as the login name and press
Enter
.
As a good example (and helpful for understanding the next step) enter ifconfig .
8©PHYTEC Messtechnik GmbH 2016 L-779e_6

Getting Started
You will get information about the configuration of the Ethernet interface on the
phyCORE-AM335x.
©PHYTEC Messtechnik GmbH 2016 L-779e_6 9

phyCORE®-AM335x [PCM-051-xxx]
When the target is connected to the power supply, the bootloader
barebox is first loaded from the Flash memory. Next the bootloader is
uncompressing and booting the
Linux
kernel from the Flash. Then the
kernel will install the root filesystem, which is also located in the target's
Flash.
If you do not see any output in the Microcom window, check the serial
connection between the target and your host. If you have more than one
serial port try the others. By default Microcom uses /dev/ttyS0. If you
want to use another port you can click on the Microcom Icon at your
desktop with your right mouse button and select Properties. A window
opens in which you can change the properties of the Microcom icon. Click
in the Command field and search for "-p /dev/ttyS0". Change it for
example to /dev/ttyS1 and so on if you have more than one serial port.
If you are connecting the board via RS-232 to USB converter change it to
/dev/ttyUSB0. The -p parameter defines the port which Microcom will use.
If the Microcom window does not open, one reason could be a lock-file
which was created when
Microcom
was not correctly terminated. Delete
this file by opening a terminal and type: sudo rm /var/lock/LCK..*
In our next step we want to connect to the target via Ethernet, but first we must configure
the Ethernet adapter in our virtual machine.
In the Unity-panel (left side of your desktop) click the Dash Home icon.
Enter System Settings in the search field (you will see the corresponding icon showing
up while typing the search string).
10 ©PHYTEC Messtechnik GmbH 2016 L-779e_6

Getting Started
Open System Settings and click the Network icon.
Select the physical interface to which you have connected the Ethernet cable and click
Options.
Select the IPv4 Settings tab and choose Manual in the Method drop down box.
Click Add and enter the IP address 192.168.3.10 , 255.255.255.0 as subnet mask and
192.168.3.10 as gateway.
Finally click Save to save these connection settings and close the windows.
You are now ready to test the Ethernet network connection.
Click the SSH for Target icon on your desktop.
©PHYTEC Messtechnik GmbH 2016 L-779e_6 11

phyCORE®-AM335x [PCM-051-xxx]
A console window will open and you will see following output in the SSH terminal if the
connection is established successfully:
If you do not see the user login, check the Ethernet connection between
the target and the host. If you have installed more than one network card
on your host, be sure to connect the cable to the network card which you
have configured with the IP address 192.168.3.10.
Be sure that you have configured the network adapter in the virtual
machine configuration as
NAT
.
If you do not see the login, you may not have set up the right IP address
for your host. Open the
System Settings
, click the
Network
icon and
check the settings for the physical interface to which you have connected
the Ethernet cable.
You have successfully set up all configurations to access your
phyCORE-AM335x from your host.
12 ©PHYTEC Messtechnik GmbH 2016 L-779e_6

Working with Eclipse
3Working with Eclipse
Now we start developing our own applications with the help of Eclipse.
3.1 Programming in the C/C++ Perspective
We are starting with the C/C++ workbench. Therefore you will import an existing Eclipse
project into your workspace. The imported example project will be compiled with the cross
compiler. After that, you will copy and execute the newly created program on the target.
3.1.1 Work with the Demo Project
Click the Eclipse icon to start the application. You can find this icon on your desktop.
Change the workspace directory to /opt/prj_workspace/Eclipse if necessary and confirm
with OK.
©PHYTEC Messtechnik GmbH 2016 L-779e_6 13

phyCORE®-AM335x [PCM-051-xxx]
Now you can see the Eclipse workbench.
First we will import an existing project.
Select File ►Import from the menu bar.
Expand General, select Existing Projects into Workspace and click Next.
14 ©PHYTEC Messtechnik GmbH 2016 L-779e_6
Other manuals for phyCORE-AM335x
2
Table of contents
Other Phytec Microcontroller manuals

Phytec
Phytec phyCORE-LPC3250 Programming manual

Phytec
Phytec nanoModul-164 Programming manual

Phytec
Phytec phyCORE-MPC5200B tiny User manual

Phytec
Phytec i.MX6UR User manual

Phytec
Phytec SYS TEC ELECTRONIC CANopen Chip164 Programming manual

Phytec
Phytec IoT-Enablement-Kit 1 User manual

Phytec
Phytec phyCORE-SC520 User manual

Phytec
Phytec phyCORE-167CS User manual

Phytec
Phytec phyCORE-i.MX31 User manual

Phytec
Phytec phyCORE-XScale/PXA255 Installation and operating instructions