Sei sulla pagina 1di 20

Compiling, Linking, and

Locating

The first program

BUILD PROCESS IN EMBEDDED


SYSTEM
The process which converts source code to
executable code is called as the build process.
The build process for embedded systems is
different. This is because the code to be run on
an embedded system is written one platform
i.e. general purpose computer and executed on
another platform i.e. the target hardware.
The build process involves three steps:
Compiling
Linking
Locating

Compiler
The compiler takes input as source
code files and gives output as multiple
object files.
Ex. Turbo C++ is a native compiler. The
compiler in case of embedded systems
development is a cross compiler (while
compiling the programmer has to select
the target processor for which the code
has to be generated)

Compiler
A compiler which produces the
executable code to be run on a
different platform is called a crosscompiler; else it is called a native
compiler.

Linking
The output of compiler is multiple object files. These files are
incomplete in the sense that they may contain reference to
variables and functions across multiple object files which need
to be resolved.
The job of the linker is to combine these multiple object files
and resolve the unresolved symbols.
The linker takes input as multiple object files and gives output
as a single object file which is also called as the relocatable
code.
The Linker does this by merging the various sections like text,
data, and bss of the individual object files.
The output of the linker will be a single file which contains all
of the machine language code from all of the input object
files.

Locating
The process of relocating is carried out by the relocater.
The relocater takes input as the relocatable code produced
by the linker and gives output as the final executable code.
This output is a binary executable file which is called HexCode.
The locator needs to be given information about the
memory available on the target processor.
The locator will use this information to assign physical
memory addresses to each of the code and data sections
within the relocatable program code.
Finally it produces an output file that contains a binary
memory image that can be loaded into the target
processors ROM.

Tool Chain

DOWNLOADING THE EMBEDDED


CODE
The code to be run on the target embedded
system is always developed on the host
computer. This code is called the binary
executable image or simply hex code.
The process of putting this code in the
memory chip of the target embedded
system is called Downloading
There are two ways of downloading the
binary image on the embedded system :
DP, ISP

Device Programmer
A device programmer is a piece of hardware that works in
two steps.
Step 1
Once the binary image is ready on the computer, the device
programmer is connected to the computer and the binary image is
transferred to the device programmer.
Step 2
The microcontroller/microprocessor or memory chip, usually the ROM
which is supposed to contain the binary image is placed on the proper
socket on the device programmer. The device programmer contains a
software interface through which the user selects the target
microprocessor for which the binary image has to be downloaded.
The Device programmer then transfers the binary image bit by bit to
the chip.

In System Programmer(ISP)
Hardware interface to both the
computer as well the chip where the code is
to be downloaded.
The user through the ISPs software interface
sends the binary image to the target board.
This avoids the requirement of frequently
removing the microprocessor /
microcontroller or ROM for downloading the
code if a device programmer had to be used.

DEBUGGING THE EMBEDDED


SOFTWARE
Debugging is the process of eliminating the bugs/errors
in software.
The software written to run on embedded systems may
contain errors and hence needs debugging.
However, the difficulty in case of embedded systems is
to find out the bug/ error itself. This is because the
binary image you downloaded on the target board was
free of syntax errors but still if the embedded system
does not function the way it was supposed to be then it
can be either because of a hardware problem or a
software problem. Assuming that the hardware is
perfect all that remains to check is the software.

The difficult part here is that once the embedded


system starts functioning there is no way for the
user or programmer to know the internal state of
the components on the target board.
The most primitive method of debugging is using
LEDs. This is similar to using a printf or a cout
statement in c/c++ programs to test if the control
enters the loop or not. Similarly an LED blink or a
pattern of LED blinks can be used to check if the
control enters a particular piece of code.

There are other advanced debugging


tools like;
Remote debugger
Emulator
Simulator

Emulator
A Remote debugger is helpful for monitoring and controlling
the state of embedded software prior to downloading it only.
An Emulator allows you to examine the state of the processor
on which that program is actually running. It is itself an
embedded system, with its own copy of the target processor,
RAM, ROM, and its own embedded software
An Emulator takes the place of-or emulates-the processor on
the target board.
Emulator uses a remote debugger for its human interface.
In-circuit emulation (ICE) is the use of a hardware device or
in-circuit emulator used to debug the software of an
embedded system. It operates by using a processor with the
additional ability to support debugging operations, as well as
to carry out the main function of the system.

simulator
A simulator is a completely host-based program
that simulates the functionality and instructions
set of the target processor.
Advantage: A Simulator can be quite valuable
in the earlier stage of a project when there has
not yet been any actual hardware
implementation for the programmers to
experiment with.
Disadvantage: One of the disadvantages of
simulator is that it only simulates the
processors.

Other Tools
Logic Analyzers
To convert the captured data into timing
diagrams, protocol decodes, state machine
traces, assembly language, or may correlate
assembly with source-level software
Oscilloscopes
Electronic test instrument that allows
observation of constantly varying signal
voltages, usually as a two-dimensional plot
of one or more signals as a function of time.

Potrebbero piacerti anche