Post on 24-Dec-2015
transcript
B U I L D I N G & P O R T I N G O P E R A T I N G S Y S T E M S
CROSS DEVELOPMENT
WHAT IS A TOOL CHAIN?
A set of software utilities used to perform an operation.
GNU Toolchain - a blanket term for a collection of programming tools produced by the GNU Project. Used for OS and application development.
FOR EMBEDDED SYSTEMS
Usual development tools available on a GNU/Linux workstation is a native toolchain
Embedded systems typically run on one platform while building applications for another.
Therefore, cross-compiling toolchains are generally used. They run on your workstation but generate code for your target.
EMBEDDED SYSTEMS
x86
ARMx86
Compilationmachine
Execution machine
Source code
Native toolchainCross-compiling
toolchain
x86 binary ARM binary
build host target
Native buildused to build the normal gcc
of a workstation
build host target
Cross buildused to build a toolchain that runs on your workstation but generates
binaries for the target
build host target
Cross-native buildused to build a toolchain that
runs on your target and generates binaries for the
target
build host target
Canadian buildused to build on architecture
A a toolchain that runs on architecture B and generates
binaries for architecture C
The most common solution in embedded
WHAT IS IT COMPOSED OF?
Binutils Kernel headers
C/C++ libraries GCC compiler
GDB debugger(optional)
Source: free-electrons.com
Binutils set of tools to generate and manipulate binaries for a given CPU architecture. The main ones are:
ld - the linker. as - the assembler.Ar, ranlib - A utility for creating, modifying and
extracting from archives. c++filt - Filter to demangle encoded C++
symbols. addr2line - Converts addresses into filenames
and line numbers. Others: Gprof, Nlmconv, nm, objcopy, objdump,
ranlib, Readelf, Size, Strings, strip, windres
BINUTILS
Interface between the applications and the kernel
Provides the well-known standard C API to ease application development
Several C libraries are available:glibc, uClibc, eglibc, dietlibc, newlib, etc.
The choice of the C library must be made at the time of the cross-compiling toolchain generation, as the GCC compiler is compiled against a specific C library.
C LIBRARY
Kernel
C Library
Applications
KERNEL HEADERS
The C library and compiled programs needs to interact with the kernel
Available system calls and their numbers
Constant definitions Data structures, etc. Therefore, compiling the C library
requires kernel headers, and many applications also require them.
Kernel
Kernel headers
C Library
Applications
Available in <linux/...> and <asm/...> and a few other directories corresponding to the ones visible in include/ in the kernel sources
GCC: GNU C Compiler, the famous free software compiler
Can compile C, C++, Ada, Fortran, Java, Objective-C, Objective-C++, and generate code for a large number of CPU architectures, including ARM, AVR, Blackfin, CRIS, FRV, M32, MIPS, MN10300, PowerPC, SH, v850, i386, x86_64, IA64, Xtensa, etc.
Available under the GPL license, libraries under the LGPL.
GCC COMPILER
• The debugger on GNU/Linux,available for most embedded architectures.
• Console interface or GUI available, also gdbserver• Can be used to control the execution of a
program, set breakpoints or change internal variables. Can also see memory images, useful if system crashes.
• Use of terminal emulators – Ensure you can access the serial port (/dev/ttys0) (chmod to change rights of files)– Minicom most commonly used, usually installed in distribution, Others include UUCP cu and C-Kermit
GDB DEBUGGER
USING ‘MAKE’
make – used after every tool if built from scratch Brings all of the tools together, and makes use
of them to build the project Processes a makefile that dictates the build
procedure Generated files depend on source files, if a
source file is updated so is the generated file! Likewise, if a source is not updated, and the
generated file already exists... It isn’t re-built Pseudo targets, allow for install and clean etc..Tip: Use SVN/Configuration facility
Video: Compiling
ARM
WHERE DOES IT FIT IN?
Basic example of a typical self-build GNU toolchainSource: eejournal.com
CROSS DEVELOPMENT ENVIRONMENT
• In today’s embedded development or development as a whole, is rare that developers develop & write code on the devices themselves.
• Because of this, it means there is a need for cross development environments which differ dependent on the target hardware.
• Mobile Applications – Android, iOS, Windows, all have different cross development environments – which enable programmers to develop for there chosen platform.
DEVICE DEVELOPMENT
• When developing system software for embedded devices, one of the important facts is figuring out how to the code on the board, and proceeding with the code execution.
• The deployment of code on devices can be achieved in many
ways which depends on the target product device that the build was built for and its on board features.
• With most of ‘OUR’ late embedded development experiences, it was achieved by populating an micro SD card with kernel/boot loader images along with file systems which are recognized by the boards CPU’s and booted accordingly.
• Difficulties – Errors downloading from git repositories• Bad or corrupt repos
DATA TRANSFERS
• Ethernet Cables • Year 2, Configuring Puppeteer boards
• COM Ports• Virtual USB COM port• RS-232
• Micro SD Cards & Reader • Loading Kernel Images, boot loaders & File systems
BUILDROOT
• Build root is a set of Makefiles and patches which make it easy to generate a complete embedded Linux system.
• It is very useful for people working with embedded systems using various CPU architectures: ARM, x86, MIPS, PowerPC and more.
• Automating the build process for your chosen embedded system & easing the cross compilation generation.
MAJOR BUILD ROOT FEATURES
THE “MAKE” COMMAND
• The ‘Make’ Utilities purpose is to determine automatically which pieces of a large program need to be recompiled & then issue certain commands to recompile them.
• Using make requires Makefiles to be written, which describes relationships amongst files in your program – stating commands for updating each file.
• Once a Makefile exists, each time source files are changed the simple shell command make performs all necessary recompilations, executing commands in the Makefile to update one or more target names.
• Few Make Options: ( -b, -C dir, -d, -e, -f file, -j jobs, -k and many more)
• The GNU implantation of the make command was written by Richard Stallman and Roland McGrath.
DEBUGGING
• Embedded systems development relies on debuggers talking to chips to perform operating like single stepping & break pointing. Debugging stages may be performed at different levels, depending on facilities that are available to the debugger.
• It can be achieved in two ways , internally or externally.
• Internal Debugging by Running pieces of software through tools viewing the code running on the processor. Allowing the starting or stopping operations , which can be done using emulators.
DEBUGGING EXTERNAL
• Using serial ports (RS232/USB COM PORT) and JTAG(Joint Test Action Group) hardware interfaces.
• JTAG adapters uses JTAG as the transport mechanism to access on-chip debug modules inside the CPU. These modules let developers debug the software directly at machine instruction level.
• Most Digital electronic products today's such as mobile phones or a wireless access point generally have no other debug or test interfaces.
SOFTWARE DEVELOPMENT KIT (SDK)
• Set of software development tools that allows for the creation of applications for a certain software package, software framework, hardware platform, computer system, video game console, operating system or similar platform
• A software engineer typically receives the SDK from the target system developer
• Providers of SDKs for specific systems or subsystems may sometimes substitute a more specific term instead of software. For instance, both Microsoft and Apple provide driver development kits (DDK) for developing device drivers
WINDOWS SDK
• Microsoft Windows SDK, Platform SDK and .NET Framework SDK
• Platform SDK specializes in developing applications for Windows 2000, XP and Windows Server 2003. .NET Framework SDK is dedicated to developing applications for .NET Framework 1.1 and .NET Framework 2.0. Windows SDK is the successor of the two and supports developing applications for Windows XP, Windows Vista, Windows 7, Windows Server 2008, .NET Framework 3.0, .NET Framework 3.5, and .NET Framework 4.0.
THE WINDOWS SDK CONTAINS THE FOLLOWING
• For Win32 development:o 1,915 Headerso 348 Librarieso 100 Tools
• For .NET (managed code) development:o 14 Reference Assemblies supporting .NET, Tablet PC, Windows
PowerShell, MMC, etc.o 33 Intellisense Fileso 70 .NET 2.0 Tools + 10 .NET 3.0 Tools + 35 .NET 4.0 Tools
• For Visual Studio 2005/2008/2010 integrationo Utilities to enable Visual Studio 2005/2008 to easily use
Windows SDK headers and librarieso Visual Studio 2005/2008 Wizards for creating Windows Media
Player applications
• Latest version of JDK ( Java Development Kit)
• Eclipse IDE
• SDK Starter Package (it includes only the core SDK Tools)
• ADT Plugin for Eclipse
• Android SDK and AVD Manager (a tool included in the SDK starter package) to download essential SDK components into your development environment.
ANDROID SDK AND ECLIPSE
ANDROID SDK TOOLS
• Android EmulatorA QEMU-based device-emulation tool that you can use to design, debug, and test your applications in an actual Android run-time environment. Hierarchy Viewer (hierarchyviewer)Lets you debug and optimize an Android application's user interface.layoutoptLets you quickly analyse your application's layouts in order to optimize them for efficiency.MksdcardHelps you create a disk image that you can use with the emulator, to simulate the presence of an external storage card (such as an SD card).MonkeyRuns on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events. You can use the Monkey to stress-test applications that you are developing, in a random yet repeatable manner.
ANDROID SDK TOOLS
• Monkey runnerProvides an API for writing programs that control an Android device or emulator from outside of Android code.ProGuardShrinks, optimizes, and obfuscates your code by removing unused code and renaming classes, fields, and methods with semantically obscure names.sqlite3Lets you access the SQL Lite data files created and used by Android applications.traceviewProvides a graphical viewer for execution logs saved by your application.zipalignOptimizes .apk files by ensuring that all uncompressed data starts with a particular alignment relative to the start of the file. This should always be used to align .apk files after they have been signed.
QUESTIONS?