You are on page 1of 125

Open Source Development Tools

for ARM Architectures


AMF-SDS-T0012
Robert McGowan | Chief Architect

March 2015

TM

External Use
Session Introduction

• The development tools ecosystem for ARM is probably the most


comprehensive in the embedded world
• A wide variety of open source and commercial tools are available to
a software developer.
− Open source Linux tools
− Eclipse based open source tools
− Freescale’s CodeWarrior Development Suite and a Linux SDK.
− Third party commercial tools from ARM Holdings and others

• This session will highlight open source tools available on


Freescale’s network devices
− Where do open source and commercial tools play a role?
− What tools are available?
− Where can I go for more information?
TM

External Use 2
Freescale’s ARM Devices Span from Low-End to High-End

• Different solutions apply to different design spaces


− Kinetis Devices
 Kinetis Design Studio
 Commercial third party tools
− i.MX Devices
 Linux & tools
 Commercial third party tools
− QorIQ Digital Networking Devices
 Linux & tools
 CodeWarrior Development Suite
 Commercial third party tools

• Warning: This presentation contains information that isn’t always


applicable to each space.
TM

External Use 3
Agenda
• Open-source resources for ARM
• Target Software Building Blocks
• Tools for Build and Debug
• Eclipse Linux Tools
−Dynamic analysis tools
• Beyond open-source with Freescale

TM

External Use 4
Agenda
• Open-source vs Commercial
• Target Software Building Blocks
• Tools for Build and Debug
• Eclipse Linux Tools
−Dynamic analysis tools
• Beyond open-source with Freescale

TM

External Use 5
Open Source vs Commercial

• Open source and commercial tools are not in competition.


− Both can be effectively used in a project

− There are areas in which open source tooling excels

− And areas that are only covered with commercial tools

− Make effective use of both to expedite project delivery

TM

External Use 6
Open Source & Commercial
Open Source Commercial
Distribution Creation Yocto
Revision Management GIT, Mercurial, CVS, etc Accurev, ClearCase, etc
Building bitbake, make, etc
CW compiler (for AIOP),
Compilation GCC (for ARM) GHS
Scripting Python, etc
Device Configuration CW QCVS tools
Configuration Validation CW QCVS tools
SW Testing Valgrind Purify, Klocwork
JTAG bare-metal debug CW, ARM DS5, etc
CW Debugger, ARM DS5,
Linux Application debug GDB etc
Performance Analysis - Core Perf CW Scenario Tool
Performance Analysis - SOC CW Scenario Tool

Network Traffic Analysis Wireshark CW Packet Analysis Tool


TM

External Use 7
Agenda
• Open-source resources for ARM
• Target Software Building Blocks
• Tools for Build and Debug
• Eclipse Linux Tools
−Dynamic analysis tools
• Beyond open-source with Freescale

TM

External Use 8
Get the Target Software

• Kinetis MCU
− Processor Expert: Build applications with software drivers and have it deal
with the low-level microcontroller initialization.
 http://www.freescale.com/webapp/sps/site/prod_summary.jsp?
code=PE_DRIVER_SUITE&tid=PEH
− McuOnEclipse Processor Expert Components: an extensive set of added
Processor Expert components.
 https://github.com/ErichStyger/mcuoneclipse/tree/master/PEupd
− Kinetis SDK

• i.MX and QorIQ Devices


− U-boot boot loader http://www.denx.de/wiki/U-Boot
− Linux Kernel https://www.kernel.org/
− Linaro: Open-source software for ARM SoCs: http://www.linaro.org/
− Freescale SDK - search for Linux SDK on http://freescale.com
− Yocto, Bitbake
TM

External Use 9
Processor Expert + KSDK

TM

External Use 10
Learn more at: www.freescale.com/KSDK

Kinetis Software Development Kit (SDK)

A complete software framework for Product Features


SDK developing applications across all • Open source Hardware Abstraction Layer
Kinetis MCUs (HAL) provides APIs for all Kinetis hardware
resources
• BSD-licensed set of peripheral drivers with
HAL, peripheral drivers, libraries,
middleware, utilities, and usage easy-to-use C-language APIs
examples; delivered in C source • Comprehensive HAL and driver usage
examples and sample applications for RTOS
and bare-metal.
Customer Application • CMSIS-CORE compatible startup and drivers
plus CMSIS-DSP library and examples
Evaluation & Dev Tools
Software and Hardware

Middleware

Application

• RTOS Abstraction Layer (OSA) with support


(TCP/IP, USB)

Specific
Stacks

for Freescale MQX, FreeRTOS, Micrium


uC/OS, bare-metal and more
• Integrates USB and TCP/IP stacks, touch
sensing software, encryption and math/DSP
Libraries Operating
(DSP, Math, libraries, and more
Encryption) System
• Support for multiple toolchains including
BSP, Drivers &
Bootloader
HAL GNU GCC, IAR, Keil, and Kinetis Design
MCU Hardware Studio
• Integrated with Processor Expert

TM

External Use 11 The OSI logo trademark is the trademark of Open Source Initiative.
Kinetis SDK and Processor Expert
• Processor Expert is a complimentary PC-hosted
software configuration tool (Eclipse plugin)
• Processor Expert (PEx) provides a time-saving
option for software configuration through a
graphical user interface (GUI)
• Board configuration and driver tuning tasks
include:
− Optional generation of low-level device initialization
code for post-reset configuration
− Pin Muxing tools to generate pin muxing functions
− Components based on Kinetis SDK drivers
 Users configure the SoC and Peripherals in a GUI
 PEx creates the configuration data structures for driver
config and init

TM

External Use 12
Yocto + Linux

TM

External Use 14
What is the Yocto Project?
www.yoctoproject.org
• “An open source collaboration project that provides templates, tools
and methods to help you create custom Linux based systems for
embedded products regardless of the hardware architecture.”

• Many individuals and companies, including Freescale, Intel, TI,


Wind River, Mentor Graphics are contributing to the Yocto project

TM

External Use 15
Yocto Project Introduction: Terms

• Poky - A reference system which is a collection of Yocto Project tools and


metadata that serves as a set of working examples. Poky is the platform-
independent, cross-compiling integration layer that utilizes OpenEmbedded
Core.

• OpenEmbedded Core - A metadata repository for core metadata and build


information to build baseline embedded systems.

• Metadata – Tasks Definitions


− Recipes – (.bb/.bbappend) files are the build spec of the logical units of
components
− Class - (.bbclass) Contain common functions share by the multiple recipes.
− Configuration - (.conf) files define various configuration variables which govern
what Poky does.

• Layers - Sets of common recipes


TM

External Use 16
Yocto Project Introduction: Layers of Recipes

• The OpenEmbedded build system supports organizing


Metadata into multiple layers.
• Layers allow you to isolate different types of customizations from
each other.
• Source: http://www.yoctoproject.org/docs/1.4/dev-manual/dev-manual.html#understanding-and-creating-layers

Source: https://www.yoctoproject.org/tools-resources/projects/openembedded-core

Let’s check out: http://layers.openembedded.org/layerindex/


TM

External Use 17
Yocto Project Tools
www.yoctoproject.org

• Bitbake: Parses metadata, generating a list of tasks from it and


then executes them.
− Atthe core of Poky is the bitbake task executor together with various
types of configuration files.

• Hob: GUI tool to select packages to build and easily create custom
image

• GCC: Open source build tools (compiler, linker) for the ARM cores
in a Freescale device

• GIT: Revision management

TM

External Use 19
Yocto and BitBake Documentation

Yocto Project website:


www.yoctoproject.org

BitBake User Manual:


docs.openembedded.org/bitbake/html

The SDK documentation bundle:


[sdk_documentation/pdf/yocto]
├── adt-manual.pdf
├── bsp-guide.pdf
├── dev-manual.pdf
├── kernel-dev.pdf
├── kernel-manual.pdf
├── poky-ref-manual.pdf
└── profile-manual.pdf

TM

External Use 21
Yocto Basics for QorIQ SDK

TM

External Use 22
Something New For LS1021

• Distribution
− Previous Freescale SDK was a Distribution.
− Full Linux and Tools release
− Twice a year releases
− All platforms, All packages
• BSP
− Leverages Yocto Poky Distribution
− Provides only changes over distro
− NPI support separately qualified
− Released with NPIs

• Sign of Things to Come


• For now, Both SDK and BSP are available.

TM

External Use 23
Freescale QorIQ SDK and the Yocto Project
• SDK 1.4 is based off the Yocto 1.4 "dylan“ release
• SDK 1.5 is based off the Yocto 1.5 “dora” release
• SDK 1.6 is based off the Yocto 1.6 “daisy” release
• SDK 1.7 is based off the Yocto 1.7 “dizzy” release
• Alignment of release numbering just coincidence
• Freescale is an active part of the upstream community and is a full Yocto
Project Member and a member of the Advisory Board
• Freescale has created QorIQ specific layers, that can be "plugged" into the
Yocto build system, allowing users to build for Freescale target machines

TM

External Use 24
Start with the Yocto Distribution

Note Git Clone URL for Dizzy 1.7 release


25
TM

External Use 25
Add the LS1 BSP

Note Git clone URL for ls1021atwr BSP


26
TM

External Use 26
Pointers to More Information

TM

External Use 27
Recent QorIQ SDK Release
www.freescale.com/webapp/sps/site/prod_summary.jsp?code=SDKLINUX

• Log into freescale.com to download SDK releases and updates

TM

External Use 28
Recent QorIQ SDK Release (continued)
Freescale Public git Server
• Public source code for the SDK can be also pulled from:
git.freescale.com/git/cgit.cgi/arm/sdk

TM

External Use 29
Recent QorIQ SDK Documentation
On-line : http://www.freescale.com/infocenter

TM

External Use 30
Recent QorIQ SDK Documentation (continued)
InfoCenter Lite : <SOURCE ISO>/documents/START_HERE.htm

PDF version : <SOURCE ISO>/Documentation/sdk_documentation/pdf/QorIQ_SDK_Infocenter.pdf

TM

External Use 31
QorIQ Yocto Layers

TM

External Use 32
SDK Layers

• The SDK configuration includes the example Yocto distribution


based on the poky baseline, plus Freescale specific layers:
− meta-oe (public) ... generic community packages
− meta-skeleton (public)
− meta-yocto (public)
− meta-fsl-arm (public) ... pushed upstream
− meta-fsl-arm-toolchain (public)... not upstreamed
− meta-fsl-networking (public) ... not upstreamed

• Public variants live here:


− git.freescale.com ... aligned with SDK releases
− git.yoctoproject.org ... aligned with Yocto releases

TM

External Use 33
SDK Layers (continued)
meta-fsl-arm vs. meta-fsl-networking
• meta-fsl-arm:
− Adds basic support for all supported Freescale boards
− Recipes for all public Freescale projects : kernel, u-boot, ...
− Only defines images fsl-toolchain, fsl-image-minimal (not even
those in the future)
− Hosted on git.freescale.com

• meta-fsl-networking:
− Adds definitions for images like fsl-image-flash and fsl-image-
full
− Focuses on networking, QorIQ-specific technology
− More and more recipes are moved into meta-fsl-arm
− Hosted on git.freescale.com

TM

External Use 34
i.MX + Yocto

TM

External Use 35
Yocto Project Freescale i.MX 6 Releases: History
Release Description

L3.10.17-1.0.0_ga on Dora Kernel 3.10.17 GA release with p13 Vivante


graphics and manufacturing image

L3.10.17-1.0.0_beta on Dora Kernel 3.10.17 with p13 Vivante graphics and


manufacturing image with crypto support

L3.10.9-1.0.0_alpha on Dora Kernel 3.10.9 with p12 Vivante graphics and


weston/wayland support

L3.5.7-1.0.0_alpha2 on Dylan Kernel 3.5.7 alpha release with hardware floating


point using p12 Vivante graphics fixes from
3.0.35-4.1.0 final ltib release
L3.5.7-1.0.0_alpha on Dylan Kernel 3.5.7 alpha release with hardware floating
point using p12 Vivante graphics and 2013.04
uboot

TM

External Use 36
Yocto Project Freescale i.MX 6 Releases: Distribution

meta-fsl-bsp-release layer
• Distributes changes on top of community layers
− meta-fsl-arm
− meta-fsl-demos
− poky
• After each release the changes are upstreamed into the layers for
the next Yocto release to provide

Freescale i.MX Yocto Project mirror


• Stores Freescale packages
• Git.freescale.com
• Kernel and u-boot-imx releases
• Moderated download for packages with license restrictions

TM

External Use 37
Yocto Project Freescale i.MX 6 Releases: Contents
Contents Description

recipes-kernel Kernel and crypto recipes

recipes-bsp U-boot, imx-test, imx-lib, imx-vpu, imx-


kobs, imx-uuc, firmware,

recipes-graphics gpu-viv-bin-mx6q, gpu-viv-g2d, xorg-


driver
recipes-multimedia libfslcodec, libfslparser, libfslvpuwrap,
gstreamer, alsa

recipes-core busybox, eglibc, udev

recipes-devtools gcc, mtd

recipes-connectivity linuxptp, obexftp, openobex, openssl

TM

External Use 38
Yocto Project Build:
Configure the build environment
• What are the supported boards?
i.MX Reference Boards

i.MX 6Q imx6qsabresd imx6qsabreauto


i.MX 6DualLite imx6dlsabresd imx6dlsabreauto
i.MX 6Solo imx6solosabresd imx6solosabreauto
i.MX 6SoloLite imx6slevk
i.MX 6SX imx6sxsabresd
i.MX53 imx53qsb
i.MX28 Imx28evk

$ MACHINE=imx6qsabresd source fsl-setup-release.sh -b build

This is your build environment, you can set


a different name to reflect the configuration

TM

External Use 41
Using BitBake

TM

External Use 42
Running BitBake

• Bitbake: Parses metadata, generating a list of tasks from it and then


executes them.
− When bitbake (a Python script) runs:
 It parses recipes and tasks
 Determines task queue dependencies
 Prepares and executes a run queue of tasks, which perform the steps needed to
obtain the desired result, e.g. image generation

• Any required earlier tasks will be run first


(e.g. source will be installed before compilation)
• BitBake must always be executed from within the <project>
directory
• To speed up subsequent builds, the generated <pkg>.rpm's are saved
to the binary cache folders in:
<project>/tmp/deploy/rpm
TM

External Use 43
Running Specific BitBake Tasks

• Invoke bitbake to run a specific task specified in the recipe of a


package or an image, e.g.
− Generate one of the image types defined in the SDK
− Build an individual package
− Build the cross compiler toolchain
− Optionally with -c <CMD> indicate a specific task to perform

$ bitbake [-c <CMD>] [options] <recipe>

• An initial image built may take a significant amount of time, if many


packages are not available in the binary cache

TM

External Use 45
Agenda
• Open-source resources for ARM
• Target Software Building Blocks
• Tools for Build and Debug
• Eclipse Linux Tools
−Dynamic analysis tools
• Beyond open-source with Freescale

TM

External Use 47
Components of a Tools Suite

• GDB: debugger
• Debug Interface: Connection from the host to the target for debug
− MCU: third party probes like Segger.
− Linux: UART or socket
− Layerscape bare-metal: CW-TAP
• Eclipse for C/C++: the IDE and framework to edit, build and debug
projects.
• GNU ARM Eclipse plugins: integration of the GNU gcc for ARM
into Eclipse, provides panels and build tool integration including a
wizard to create new projects.
• GCC ARM Embedded: compiler, linker, build tools and gdb,
needed to compile source code.
• Cross Build Tools: some tools like ‘echo’ or ‘rm’ are not present by
default on Windows, this package closes that gap.
TM

External Use 48
GDB – Gnu Debugger

• GDB is one of the most popular and used debuggers.


• GDB is free software provided by Free Software Foundation
• http://www.gnu.org/software/gdb/

• GDB can be used to find what is going on `inside' another program


while it executes – or what another program was doing at the
moment it crashed
− Current execution point context
− Program’s source code
− Registers
− Stack frames
− Program memory
− Variables
− Change program execution
TM

External Use 49
Two ways to run GDB
Target (self-hosted) Native (Host)
• GDB runs on the target (DUT) • GDB runs on the development
− E.g. Target OS: Linux host
− Host
OS and Target OS are not
• Debugs an application running on
the same system necessarily the same
• Interface with the target system • Remotely debugs an application
using other applications running on the target
− telnet − Socket connection or UART
into the target system to
run GDB from the Linux connection over the OS’s drivers
command prompt and interface carries GDB
commands and responses
− HostGDB communicates with
target GDB server

TM

External Use 50
GDB Self-Hosted Target Debugging ARM Target
QorIQ

Host Target GDB

Telnet, Terminal, GDB


etc

Remote terminal connection


/home> gdb

Host Embedded Target

Target $ gdb myProgram


telnet 192.168.1.101

TM

External Use 51
GDB Host Remote Debugging ARM Target
QorIQ

Host cross
Target GDB
GDB

GDB gdbserver
(+ ddd, Eclipse) GDB remote protocol
- Requests
- Notifications
- Data Exchange

Host Embedded Target

Target $ gdbserver :1234 myProgram


(gdb)target remote 192.168.0.1:1234

TM

External Use 52
GDB – ARM Support

• Support for:
− ARMv7 (32-bit)
− ARMv8 (64-bit)
 from GDB 7.6 add ARM AArch64 debug architecture (native and target
configuration)

• Configure and build GDB for ARM:


− Target GDB
./configure --target=aarch64-linux-gnu // or arm-linux-gnu for ARMv7
--host=aarch64-linux-gnu

− Host (native) GDB (


./configure –-target=aarch64-linux-gnu // or arm-linux-gnu for ARMv7
[--host=x86_64-linux]

TM

External Use 53
GDB – ARM Support (continued) QorIQ

• Using Yocto: How to configure and build GDB for ARM


− Configure Yocto target
$ source ./fsl-setup-poky –m <ARM target>
or
$ source poky/oe-init-build-env
edit conf/local.conf to define the ARM target details
 Target GDB
$ bitbake gdb

Native (host) GDB


$ bitbake gdb-cross

TM

External Use 54
GDB – Debugging ARM Target

• Compiling the application


$ arm-linux-gcc hello.c –o hello –g
• Debugging the application

Host$ gdb ./hello


Target$ gdbserver :1234 ./hello
GNU gdb (GDB) 7.6
Process ./hello created;

Listening on port 1234
This GDB was configured as
"--host=x86_64-linux-gnu
--target=arm-linux
Remote debugging from host
(gdb)target remote 192.168.0.1:1234
192.168.0.2
(gdb)break main
(gdb)continue

• GDB commands
− run/Ctrl-C(stop), next, step, nexti, stepi, breakpoint
− backtrace, frame, print, x, dump
− set, call, jump, return

TM

External Use 55
Debug Interface

• For Linux application debug, the connection to the target was a OS


supported device interface. E.g. Ethernet socket, UART

• With other OSes, bare-metal applications, boot-loaders, and kernel


debug, a target agent is not available.
− JTAG is the predominate method for connecting a debugger to a target
− Need a JTAG Probe
 Kinetis: Segger Systems
 Kinetis: CMSIS-DAP
 QorIQ: Freescale CW-TAP
 Many others as recommended by debugger vendor

TM

External Use 56
What is Eclipse?

Full ecosystem with many members, dozens of open source projects and
millions of downloads

Open source project and community—available for free download

Universal IDE platform of frameworks and exemplary tools

Multi-language development environment—


Java, C/C++, and many other languages

TM

External Use 57
What is Eclipse? (contd.)
► Anextensible open source software platform made up of core
services and interoperable plug-in components.
► Anenvironment supporting a group of flexible (extensible) integrated
and inter-operable components.
► Eclipse
facilitates integration of open source and commercial
components

Third Party CodeWarrior CodeWarrior


CDT
Service B Services Service Z

Third Party
Eclipse-based Development Platform
Service A

TM

External Use 58
Eclipse IDE

• Eclipse IDE for C/C++ Developers


− http://www.eclipse.org/downloads/

− 32bit version and 64bit versions available

− For developers using Linux on the target, using Linux on the host is
preferred

TM

External Use 59
Eclipse User Interface Example
Menu bar
Perspectives
Tool bar

Text
editor

Resource Stacked
Navigator views
view

Editor
Status
area

TM

External Use 60
CDT – C/C++ Integrated Development Environment

• C/C++ Development Tooling (CDT)


− Integrated Development Environment based on Eclipse
− http://www.eclipse.org/cdt

• Features
− Supports GNU build tools as managed build project or standard make
build
− Source navigation, code refactoring, code generation
− Visual debugging tools, including memory, registers, and disassembly
viewers, multicore visualization

• Uses native Linux command-line tools. These tools have to be


installed independently

TM

External Use 61
Eclipse CDT – Remote Application Debug QorIQ

GDB Cross-
Eclipse CDT Tools • CDT prerequisites
ARM
GDB
− GDB cross-tools for
Launch
GDB/MI
GDB gdbserver remote target
GDB CLI
Linux
− SSH connection for
downloading application
(gdb) break main.c:10
(gdb) continue
Host Continuing. Target • Debug configuration
− Update GDB debugger
to point to cross-tools
gdb
− Use “C/C++ Remote
Application” and ssh
connection to download
executable on remote
Linux machine
TM

External Use 62
Eclipse CDT – Debugging ARM Target

TM

External Use 63
GCC

• Open-source build tools for a wide variety of targets


 GNU http://www.gnu.org/
 GCC: the GNU Compiler Collection http://gcc.gnu.org/
− Compiler, Linker

− Native or Cross-build
− For ARM targets, usually want the cross build tools

• For Linux development, the best way to obtain the build tools is
through Yocto QorIQ

• For bare-metal / non-Linux, download the latest GCC ARM


Kinetis
Embedded from the Launchpad:

TM

External Use 64
QorIQ
SDK Compiler Tool Chain

• An architecture-specific cross-compiler toolchain (gcc) and


eglibc are built and installed per build project and invoked by
BitBake tasks as needed
− An external compiler tool chain can be configured for use by Yocto as
described in:
www.openembedded.org/wiki/Adding_a_secondary_toolchain
• A cross compiler tool chain for use outside of BitBake can be
generated as follows:

$ bitbake meta-toolchain

An installable tar file will be installed here:


<project>/tmp/deploy/sdk

TM

External Use 65
GCC Kinetis

• For bare-metal / non-Linux, download the latest GCC ARM


Embedded from the Launchpad:
− https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+down
load/gcc-arm-none-eabi-4_8-2013q4-20131204-win32.exe

• Run the setup. It is up to you where to install the tools, default


(depends on release) is
− C:\Program Files (x86)\GNU Tools ARM Embedded\4.8 2013q4
− Or in the Eclipse installation folder:
− C:\Freescale\Kepler\GNU Tools ARM Embedded\4.8 2013q4
− Note: ‘Add path to environment variable’ at the end of the setup.

TM

External Use 66
Extra Tools for Windows Hosts Kinetis

• There are a bunch of tools like ‘echo’ or ‘rm’ which are used by
Eclipse.
http://sourceforge.net/projects/gnuarmeclipse/files/Miscellaneous/
− Download the Cross Build Tools.zip file.
− Place in C:\Freescale\Kepler\CrossBuildTools.

• The package has cs-make.exe and cs-rm.exe included.


− Rename them to rm.exe and make.exe (or make copies and rename):

TM

External Use 67
Eclipse Compiler Support Kinetis

• Launch Eclipse, use the menu Help > Install New Software
• Use http://gnuarmeclipse.sourceforge.net/updates as update site
and install the packages.

TM

External Use 68
The Easy Way

• Kinetis users: Kinetis

− Step by step guide to creating your own tools suite:


 http://mcuoneclipse.com/2013/07/20/dyi-free-toolchain-for-kinetis-part-1-gnu-a
rm-build-tools
/
− Or use Kinetis Design Studio

• I.MX users
− Build tools are set up with Yocto

• QorIQ users
− Build tools are set up with Yocto
− Use CodeWarrior Development Suite

TM

External Use 70
Agenda
• Open-source resources for ARM
• Target Software Building Blocks
• Tools for Build and Debug
• Eclipse Linux Tools
−Dynamic analysis tools
• Beyond open-source with Freescale

TM

External Use 71
QorIQ
Eclipse Linux Tools i.MX

• Full-featured C and C++ IDE for Linux developers.


− Builds upon the source editing and debugging features of the CDT
− Integrates popular native development tools
 Gcov – code coverage
 Gprof - profiling
 Perf – profiling
 Valgrind – memory usage & heap usage analysis tool
 LTTng – Linux trace
 Oprofile - call profiling tools
 GNU Autotools - build integration
 SystemTap – editor for Linux kernel instrumentation scripting language
 Call Graph - C/C++ function and timing visualization
 RPM – package manager
 ChangeLog - automatic ChangeLog entry creation (CVS, SVN)
 Man Page – displays man pages
TM

External Use 72
Eclipse Linux Tools

• Installing Linux Tools Project


− Install into an existing Eclipse (p2 update)
 http://download.eclipse.org/linuxtools/update

− Provides only the Eclipse like interfaces


− Eclipse Linux tools use the native Linux command-line tools. These
tools have to be also installed independently

TM

External Use 73
GCOV, GPROF

TM

External Use 74
Gcov – code coverage
• Gcov is an open-source community code coverage analysis tool:
− Provides code coverage testing to C/C++ projects
− monitors an application under execution and identifies
python
 how often each line of code executes scripts
 what lines of code are actually executed
 how much computing time each section of code uses

• Uses two files


− .gcno (block info) - contains information about each branch in the code
− .gcda (block execution count) - contains all branches taken
• To enable coverage testing, the program must be compiled with the following
options:
− -fprofile-arcs
− -ftest-coverage

• Gcov main view displays an overview of coverage information for the whole
project
TM

External Use 75
Gcov – code coverage
Build Project

 Obtain .gcno file


python
Run Project scripts
 Obtain .gcda file

Display code coverage


 Source file annotated with coverage
information
 gcov view

TM

External Use 76
GPROF

• Generate flat timing profile or call graph


− Requires special hooks compiled/linked in
− -pg compile/link option
• Creates gmon.out in CWD when app executed
• To bring up Gprof view
− Double-click on gmon.out file generated after run
− Run application via Gprof profiling

TM

External Use 77
GPROF

• Uses set sampling interval – not very accurate


• Hooks are left in program
• To improve accuracy one can do multiple runs and combine
gmon.out files using -s command-line option
• Eclipse Gprof just supports flat profile for single run
• -g option needed for useful reports

TM

External Use 78
Linux Perf

TM

External Use 79
Linux perf

• Perf is a profiler tool for Linux 2.6+ based systems that abstracts
away CPU hardware differences in Linux performance
measurements and presents a simple command line interface.
• Perf is based on the perf_events interface exported by recent
versions of the Linux kernel.
• It goes by several names:
− Linux perf
− perf_events
− Just “perf” – for simplicity this is what we will use during this
presentation

TM

External Use 80
Why perf?

• Perf can help you solve a wide range of problems: It can be used
with very simple to complex
− Performance problems.
− Debugging problems
• It can cover
− Kernel itself
− Application (User Space)
• It can show you:
− Annotated source code that can be used for hotspot analysis
− CPU event counters
− Other kernel information
− State of various Kernel probes in the system.
− Much more …

TM

External Use 81
Why perf?

• Perf can answer questions like;


− Measure CPU performance counter events
− Tracing of user and kernel level program
− Why is the kernel on-CPU so much?
− What code-paths are active?
− Which code-paths are causing CPU level 2 cache misses?
− Which code-paths are allocating memory, and how much?
− What is triggering TCP retransmits?
− Why are threads leaving the CPU?
− Is a certain kernel function being called, and how often?
− Who is causing disk IO?
− And many others.

TM

External Use 82
perf invocation

TM

External Use 83
perf invocation

• In traditional Linux fashion, typing ‘perf’ without arguments will give


you a list of its commands.
• The general pattern for perf commands is perf [command][options]

TM

External Use 84
Using Linux Tools - perf
• Eclipse – one click launch
− Right click on the project->Profile As -> Profile with Perf

• Customized profiling – Profile configuration


− Perf options
− Perf event selection SW/HW: cycles, cache-misses, hw counters

• View the results


− Perf profile view

TM

External Use 85
perf – Counting events

TM

External Use 86
perf stat
• Gathers several performance statistics from a command.
• Results collected to ‘perf.data’ by default

Some useful perf stat Scenarios

# Continuously gather CPU counter statistics for the specified PID.


# Stop with Ctrl-C
perf stat -p PID

# CPU counter statistics for the entire system, for 5 seconds:


perf stat -a sleep 5

TM

External Use 87
perf – running reports

TM

External Use 88
perf – report scenarios

The perf report command is used to read the perf data (by default
collected to perf.data) and displays a ‘profile’.

#Display the perf data


perf report

# Show perf.data with a column for sample count:


perf report -n

# Show perf.data as a text report, with data coalesced and percentages:


perf report --stdio

# Disassemble and annotate instructions with percentages (requires


debuginfo):
perf annotate --stdio

TM

External Use 89
perf stat -e

• perf stat –e <COMMAND>. Runs a command and gathers


performance counter statistics.
• One of the ‘workhorse’ commands for performance measurements

TM

External Use 90
perf list

perf list – lists all of the symbolic event types. These are the events that can be selected with the
perf –e option

TM

External Use 91
perf stat Scenarios

# perf stat scenarios

# Various basic CPU statistics, system wide, for 10 seconds:


perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles -a sleep
10

# Various CPU last level cache statistics for the specified command:
perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches command

TM

External Use 92
Valgrind

TM

External Use 93
What is Valgrind?

• Valgrind is mostly a collection of tools that detect many memory


related problems and (in some architectures) allows you to analyze
your programs from the point of view of the memory subsystem.

• Keep in mind that Valgrind uses simulation, and so the program will
execute slower

TM

External Use 94
The Valgrind Tool suite

• Memcheck - detects memory management problems


• Cachegrind - a cache profiler
• Massif - a heap profiler
• Helgrind - thread debugger which finds data races in multithreaded
programs
• Others …

From the list above, the most commonly used tool is memcheck. In fact
many people think that Valgrind is basically the same thing as
memcheck

This presentation focuses only on


Valgrind’s memcheck

TM

External Use 95
Why Valgrind?

• When a program runs under Valgrind its reads and writes to


memory are monitored and calls to memory allocation routines
(such as malloc(), free()) are monitored.
• Because of this Valgrind is able to detect problems like
− Memory leaks
− Use of initialized memory
− Reading and writing from memory after it has been freed
− Reading and writing from memory past their allocated size
− Reading and writing inappropriate areas of the stack
− Passing of uninitialized and/or un-addressable memory
− Mismatched use of malloc/new vs. free/delete
• This and more on not only your problems but also system code and
libraries that have linked against your code.

TM

External Use 96
Valgrind Use Cases

• We are going to discuss some very important examples using


simple but relevant examples.
− Memory Leaks
− Reading past the end of an array
− Reading uninitialized memory
− Invalid free() (C++ Example)
− Mismatched use of functions

TM

External Use 97
Using Valgrind

Valgrind is a command line tool. It has several options (consult the


manual for all of the details) that can be used to invoke all of its tools.
If you invoke Valgrind without options, it runs memcheck – It is the
default tool

usage:
valgrind [--version] [--help] [--tool=memcheck] foo [foo’s args]

TM

External Use 98
Using Linux Tools - valgrind

• - One click launch and profile configuration


• - View the results

TM

External Use 99
Compilation notes

• For these examples the example code was compiled as follows


gcc –O0 –g foo.c –o foo
-or-
g++ -O0 –g foo.cpp –o foo

TM

External Use 100


Valgrind - Memory Leaks

#include <stdio.h>
#include <stdlib.h>
• With no options given,
Valgrind will do a quick of
int main(int argc, char** argv){
memory leaks
int i;
int *a; • If you need more detailed
information, run Valgrind with
the option –leak-check=full.
for (i=0; i < 10; i++){
a = malloc(sizeof(int) * 100);
}
free(a);
return 0;
}

TM

External Use 101


Valgrind - Memory Leaks Analysis

• If you see leaks indicated as still reachable, this may not be a problem. It simply means
that the memory was still in use at the end of the program.
• Any leaks named as “definitely lost”, “indirectly lost” or “possibly lost” (as the ones shown
in our example) should be fixed as they represent real problems.
• Note that Valgrind points out the line in your program where the leak occurred.

TM

External Use 102


LTTNG

TM

External Use 103


Linux Tools – LTTng

• LTTng
− Linux Trace Toolkit – next generation: kernel and user-space tracer with
view and analysis tools.
− LTTNG has been separated out of the Linux Trace Toolkit. Now a
separate project called Trace Compass.
 http://projects.eclipse.org/projects/tools.tracecompass

TM

External Use 104


LTTNG

• Trace Compass is a Eclipse tool for viewing and analyzing any type
of logs or traces.
− Provide views, graphs, metrics, etc. to help extract useful information
from traces, in a way that is more user-friendly and informative than
huge text dumps

• Eclipse: “LTTng” perspective


• View the results
− Events: timestamp, trace, Marker, Content
− Histogram: trace event distribution in time
− Control flow: processes list and their state in time
− Resources: CPU resources per interrupts type
− Statistics: event counters cpu time, cumulative /elapsed time
• Import or create a LTTng trace
TM

External Use 105


Using Linux Tools – LTTng

TM

External Use 106


Traces / Logs

• Trace Compass supports many trace formats:


− Common Trace Format (CTF), including but not limited to:
 Linux LTTng kernel traces
 Linux LTTng-UST userspace traces
 Linux Perf traces (using the out-of-tree patchset to convert to CTF)
− GDB traces for debugging
− The libpcap (PAcket CAPture) format, for network traces

TM

External Use 107


Linux Trace

• Static probe points strategically located inside the kernel code


• Register/unregister with tracepoints via callback mechanism
• Can be used to profile, debug and understand kernel behavior

• Trace synchronization
− Time correction
− Multi-core
− Dependency analysis, delay analyzer
− Dependencies among processes

TM

External Use 108


Agenda
• Open-source resources for ARM
• Target Software Building Blocks
• Tools for Build and Debug
• Eclipse Linux Tools
−Dynamic analysis tools
• Beyond open-source with Freescale

TM

External Use 109


MBED
• http://www.freescale.com/webapp/sps/site/overview.jsp?code=KINETIS_MBED

• Software Development Kit (SDK)


The mbed Software Development Kit is an open source C/C++ microcontroller
software platform relied upon by tens of thousands of developers to build projects fast.
• Free online development tools
The mbed Compiler is a powerful online IDE that is free for use with hardware
implementing the mbed HDK, and tightly integrated with the mbed SDK and Developer
Website.
• Hardware Development Kit (HDK)
The mbed Hardware Development Kit provides full microcontroller sub-system design
files and firmware for building development boards and custom products that benefit
from the native support of the mbed SDK and free mbed Online Compiler and mbed
Developer Platform.
• Worldwide Developer Community
The mbed platform is supported by an active and friendly community of skilled
developers that are collectively helping get prototypes made even faster. Better yet,
they are building an extensive cookbook of recipes that you can reuse to build your
products.
TM

External Use 110


Learn more at: www.freescale.com/KDS

Kinetis Design Studio

No-cost integrated Product Features


development environment • A free of charge and unlimited IDE for Kinetis
(IDE) for Kinetis MCUs MCUs
• A basic IDE that offers robust editing,
Eclipse and GCC-based IDE compiling and debugging
for C/C++ editing, compiling • Based on Eclipse, GCC, GDB and other open-
and debugging source technologies
• Includes Processor Expert with Kinetis SDK
Customer Application integration
• Host operating systems:
Evaluation & Dev Tools
Software and Hardware

Middleware

Application

• Windows 7/8
(TCP/IP, USB)

Specific
Stacks

• Linux (Ubuntu, Redhat, Centos)


• Support for SEGGER, P&E and Open
SDA/CMSIS-DAP debugger targets
Libraries Operating • Support for Eclipse plug-ins including RTOS-
(DSP, Math,
Encryption) System awareness (i.e. MQX, FreeRTOS)
BSP, Drivers &
Bootloader • CodeWarrior project importer
HAL

MCU Hardware

TM

External Use 111


Kinetis Design Studio – Block Diagram

TM

External Use 112


CodeWarrior Development Studio for QorIQ LS-series
A Complete Development Environment Under Eclipse

• Eclipse IDE • Simulation


− Leverages community offering; − Functional simulator for LS1043A,
updated on a regular basis LS2085A
− Configuration Wizards − Full simulation of ARMv8 and DPAA
− Plug-In Architecture subsystems
− 3rd party community • Debugger
− Bare-metal and Linux aware
• Build Tools − Multi-core, Cross-triggering
− Linaro GCC C/C++ Compiler for − Access to all on-chip resources
ARMv8 bundled with CW − Command-line and GUI

• Initialization Tools • Software Analysis - Trace &


− SOC platform initialization and Profile
configuration − Core and SoC trace sources
− Profiling: Core & SOC
• Run Control − Trace / Code / Performance Viewer
− CodeWarrior TAP − Offline trace visibility
TM

External Use 113


CodeWarrior Usage Scenarios

• CodeWarrior Development Suite targets Freescale’s network devices.


• Pre-silicon development
− Simulator for several Layerscape series devices including LS2085A and
LS1043A
− Bare-metal and Linux application debug
• SoC and board bring-up
− Device and Linux configuration tools
− Device configuration validation and optimization toosl
− Single core and multi-core bare-metal debugger
− Eclipse GUI and command-line interfaces
− SoC register details from the reference manual
− Bare-metal utilities: Flash Programmer, Hardware Diagnostics
− Bundled with ARM EABI toolchain (Linaro) for bare-metal application
development
TM

External Use 114


CodeWarrior Usage Scenarios

• Linux development
− GNU debugger compatible + extensions for Linux application debug
− SMP aware kernel debugging
− Linux kernel module development and debug
− Aligned with Freescale SDK: Linaro GNU toolchain, integrated target
debug agent
• Non-intrusive debug through trace
− Core and SoC trace sources: configuration, extraction, visibility
− Post-mortem debugging: offline trace
− Debug-print over STM
− Linux aware trace
• Performance Analysis
− Platform counter configuration and display
− Predefined measurement scenarios
TM

External Use 115


QorIQ Configuration and Validation Tools

Eclipse-based tools for configuring, validating and fine-tuning QorIQ


processors during board bring-up

Device Tree
Editor Pre-boot
LS Loader
Configuration

DDR Configuration Pin Muxing


and Validation Configuration

TM

External Use 116


Bare-Metal Debug
• Target interface to real hardware / simulator
• Lightweight debugger engine accessible from (gdb) break
main.c:10
Target Access
Proxy
both GUI and command line (gdb) continue
Continuing.
• Compatible with the GNU debugger front-end Linux KA
• Standard set of memory/register access
commands + monitor extensions

Command

Low Level
access
Server
Debug
• Simultaneous connectivity with multiple clients
• Single- and Multi-core support
Flash
programmer

Flash Programmer (gdb) monitor


flash AM29F002B
(gdb) erase
• Utility accessible from command-line, from done
Eclipse UI or as a set of reusable libraries
• Used by Target Access Proxy to implement flash
commands
• Extended control of flash memory device –
erase, program, blank check, protect, unprotect,
secure, unsecure, diagnose

TM

External Use 117


Linux Kernel Awareness Eclipse

• Linux Kernel Awareness features


kernel threads information
− Kernel modules list
− Stack frames for each kernel
thread
(gdb) break CW Linux KA
− Attach to active/inactive threads start_kernel scripts
(gdb) continue
− Per kernel thread registers view Continuing.

− Kernel Module Debug, module


insert/remove detection CW TAP
Hardware
Proxy

• Available from Eclipse UI and


command line in debugger Host PC FSL Target
(local/remote)
console Simulator
Proxy Simulated
Model

TM

External Use 118


Linux Application Debug Remote Linux System

Linux User Space


CodeWarrior
Debugged Application
GDB/MI
Debugger Ethernet/serial gdbserver
Eclipse App GDB CLI

Debug
Linux Kernel

(gdb) break main Simulation Arm


Arm
(gdb) continue
Continuing. Model v8
v8

- CW project: project wizard root@freescale $ uname -a


- Eclipse DSF – automatic download and Linux freescale 3.12.0+ #1 Wed Feb 26
launch application 09:45:41 IST 2014 aarch64 GNU/Linux
- Run Control: run/suspend/step root@freescale $
- Breakpoints root@freescale $
- Registers View: GPR registers root@freescale $ ./myLinuxApplication
running Linux Application
TM

External Use 119


Core and SoC Trace
Single core views Multicore views

Core #0
Core #1 Core #0 … #n

Core #n

- Single-core and multi-core views


- Non-intrusive hw trace collection
- Crash analysis
- Trace synchronization
- Foundation for profiling statistics

TM

External Use 120


Linux Kernel and User Space Trace
Initial snapshot of process
memory map (list of shared libs)

Start trace

Kernel & user app


execution
Continuous recording of
Execution new libraries loaded using STM
time
Save raw trace data
Target
Host

Import trace inCodeWarrior

TM

External Use 121


Profiling

Core #0 Core #0 Core #0

Core #1 Core #1 Core #1

Core #n Core #n
Core #n

Timeline Hierarchical Profiler Critical Code

Core #0
Statistics based on non-intrusive collected trace
- Single core and Multicore views
Core #1
- Code coverage (asm and C level)
- Optimize application using Hierarchical profiler
- Spot bottlenecks using Critical Code Core #n
- Visually identify out-of-order execution using Timeline
- Identify critical call chain using Call Tree
- Critical stack usage (simulator based)
CallTree
TM

External Use 122


Scenarios Tools

• Collect performance data from the core and SOC


• Use metrics to collect data pertinent to a problem

TM

External Use 123


Performance Analysis: Scenarios Tool
Optimized workflow for efficiently narrowing down performance issues anywhere on the system

Customer Benefits
• System Optimization for • Probe-less, field based
Cores and SoC usage.
• Complexity Abstraction • Streamlined to solve
• Delivers FSL expertise to several performance
users . issues
• Ease of Use

Key Features
• Stand alone – no • User defined
CodeWarrior Needed measurement scenarios
• Performance Analysis • Compare pairs of runs
including visualization • Graphically visualize all
• Connection auto measurements
discovery • “Live” view of events Devices supported
• “Canned” measurement and metrics
scenarios • Supports “bare metal” or • P2040, P3041, • B4860 (Rev 2, 2.1)
• 100+ scenarios covering Linux applications P5020x P5040, • LS1020A, LS1021A,
Core and SoC blocks • Python scripting support P4080 (Revs 1,2) LS1022A.
• T1040,T2080
• T4240 (Rev1, 2)

TM

External Use 124


Scenarios Tool – What Is a Scenario?

A Scenario defines what performance data will be


measured

• Aggregates Performance Monitor Events to be counted


into cohesive groups
• Defines Metrics which are mathematical operations to be
applied to the Event counts after the data is collected
• Optionally defines Python Scripts to perform additional
target setup

Stock Scenarios are canned Scenarios that are


automatically included with the tool

TM

External Use 125


Scenarios Tool – Available Scenarios

Approximately 50-100 Scenarios are available depending


on the target
Scenario Group What can I measure?
CPU – Utilization Branch Misses, Interrupt Counts, CPU Usage
Cache Misses (Data/Instruction L1, Data/Instruction Backside
CPU – Cache
L2)
CPU - MMU TLB4K Reloads, VSP Reloads, L2 MMU Misses
CPU - Core Complex Core Complex Traffic
CPU - Load Store Unit Data Line Fill Buffer (DLFB) Misses
DDR DDR Traffic, Page Misses, Collisions
CoreNet CoreNet Traffic
DPAA QMan QMan Dequeue and/or Enqueue Counts
DPAA SEC Security Engine Utilization
OCeaN DMA Performance
Combination Broad measurements over the whole system

TM

External Use 126


Packet Analysis Tool - Overview
Packet oriented system level analysis, debug complexity abstraction and ease of use

Customer Benefits
• Abstracts complexity of • Probe-less, field based
DPAA Debug resources usage.
• Delivers FSL expertise to • Streamlined to solve
users . several performance
• Ease of Use issues
• Stand alone – no
CodeWarrior Needed

Key Features
• SoC Data Plane • Packet Processing
Configuration Debug Critical Resource
• Packet Processing Monitoring
Latency Analysis • Analysis data
• Automatically identifies interpretation and
the frame processing visualization Devices and Platforms
paths (data flows) of the • User defined
system measurement scenarios Analysis over JTAG
• Provides visibility into • Graphical Visualization P2040, P3041, P4080, P5020, P5040, T1040,
T2080, T4240, B4860R2
networking tasks • Supports “bare metal” or
Analysis with software debug agent (over SSH)
offloaded to SoC Linux applications P4080, P5020, P5040, T4240, B4860R2
• Python scripting support

TM

External Use 127


Packet Analysis Tools – Use Cases

Packet Tracing Allows the users to capture trace data at


key points in the system, as they process
frames.
Lost Packet Analysis Helps the users understand why the
packets become stranded or are discarded.
Packet Latency Analysis Allows users to measure the time spent by
a frame at various points in the system
Packet Sequencing Analysis Uses the trace features in order to trace an
entire sequence of frames.
Queue Manager Analysis Allows users to trace specific flows of
frames, and inspect portal status.

TM

External Use 128


Freescale Packet Analysis Tool – Overview
• User friendly system-level analysis, performance measurements and debug
• Provides visibility into networking tasks offloaded to hardware
• Non-intrusive or low-intrusive data collection
• Packet-centric analysis data visualization
• Exemplifies the key concepts for implementing packet-focused analysis tools

TM

External Use 129


Summary

TM

External Use 130


Summary
Eclipse CodeWarrior

GCC Kinetis Design


SDK Development
CW QCVS Studio
Yocto System
Build Processor 3P IDEs
bitbake
Expert

CodeWarrior Debug
GDB
Kinetis Design Studio
LTTNG Debug
CW Packet Tools
Valgrind CW HW Trace

CW Scenarios
Perf Optimization
CW Profiling

TM

External Use 131


Summary

• To maximize productivity, your development flow should include


both open source and commercial tools

− Open source is complimentary to commercial tools


 Each have areas in which they excel.

TM

External Use 132


TM

www.Freescale.com

© 2014 Freescale Semiconductor, Inc. | External Use

You might also like