Page 20

EETE MAR 2015

DEBUGGING &PROGRAMING TOLS Tips for designers using Linux in an embedded project MBy Arnoldas Bagdonas icrocontroller manufacturers’ development boards, and the example software projects that they provide with them, can provide great assistance to engineers at the start of a new design. Equally, the software that they provide can cause problems as a design project goes beyond its early phases. Designs using a real-time operating system as the platform for application code also face the challenge of partitioning functionality into concurrent tasks, designing bullet-proof interprocess communications, and testing the whole package in hardware. More and more OEMs are finding that the best way to avoid both of the problems described above is to base new designs on an open-source, proven Operating System (OS) which is scalable and runs on various hardware platforms: Linux. Ths OS has been ported to more computer hardware platforms than any other. Its derivatives run on a very wide range of embedded systems such as network routers, mobile phones, building automation controls, televisions and video game consoles. Just because Linux is used successfully, however, does not mean that it may always be used easily. The OS consists of more than one million lines of code, and operates with a distinctive Linux philosophy that the beginner may struggle to grasp quickly. The main aim of this article, therefore, is to provide a fivestep guide to starting a new design project using the μClinux version of embedded Linux. To illustrate the guidance, the article describes the implementation of a μClinux project on an STM32F429 microcontroller from STMicroelectronics (ARM® Cortex®-M4 core running at 180MHz maximum), and using Emcraft’s STM32F429 Discovery Linux Board Support Package (BSP). Step 1: Linux tools and project layout Every embedded software design starts with the selection of the right tools. A toolchain is a set of software development tools that are linked (or chained) together, and it consists of components such as GNU Compiler Collection (GCC), binutils and glibc, as well as, in some cases, other tools such as compilers and debuggers. The toolchain used for embedded development is a crosstoolchain, more commonly known as a cross-compiler. The GNU Binutils is the first component of an embedded Linux toolchain. GNU Binutils contains two important tools: • ‘as’, the assembler, which turns assembly code (generated by gcc) into binary • ‘ld’, the linker, which links discrete object code segments into a library, or executable The compiler is the second important component of a toolchain. In embedded Linux, it is known as GCC, and supports a wide range of MCU and processor architectures. Next is the C library. This implements Linux’s traditional POSIX Application Programming Interface (API), which can be used to develop user-space applications. It interfaces with the kernel through system calls, and provides higher-level services. The engineer has several choices of C Library: • glibc is the C library available from the open-source GNU project. This library is full-featured, portable, and conforms to the Linux standard. • Embedded GLIBC (EGLIBC) is a variant optimised for embedded systems. It has a reduced footprint, supports crosscompiling and cross-testing, and maintains source and binary compatibility with GLIBC. • uClibc is another C library that may be used if Flash space is limited and/or the memory footprint must be minimised. The debugger is also usually part of the toolchain, as a cross-debugger is needed to debug applications running on the target machine. In the embedded Linux world, the usual debugger is GDB. Essential as these tools are, when used on their own it would take too long to compile Linux source code and merge it into a final image. Fortunately, the Buildroot tool automates the process of building a complete embedded system, and eases cross-compilation by generating any or all of: • a cross-compilation toolchain • a root filesystem • a kernel image • a bootloader image For embedded systems designers, it can also be convenient to use a utility aggregator tool, such as BusyBox, that combines the most commonly required utilities in one place. According to the BusyBox information page, it ‘combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.’ One last essential tool is a BSP that is made specifically for the motherboard carrying the project’s target MCU or processor. A BSP includes preconfigured tools, and a bootloader that Arnoldas Bagdonas is Field Applications Engineer at Future Electronics (Lithuania) - www.futureelectronics.com 20 Electronic Engineering Times Europe March 2015 www.electronics-eetimes.com


EETE MAR 2015
To see the actual publication please follow the link above