Development/Test Tool Compilers,
Assemblers, linkers, loaders, and
Programming issues
for Embedded Systems
P.GOWTHAM.,M.E
LECTURER/ECE
P.GOWTHAM.M.E., 1 Apr 12, 2020
is programming for an
embedded system different?
• Speed
• Size
• Correctness
• Portability
• Real-Time or not
• Other Hardware Considerations
P.GOWTHAM.M.E., 2 Apr 12, 2020
How does one actually program
an embedded system?
• Has this changed over the years? Has there been
significant progress?
• How does Ford program their Fuel Injection System
computer?
• How does GE program their Microwave Ovens (and was
this different 30 years ago?)
• How does Nikon program their digital cameras?
• How does Apple/RIM/Microsoft program their
iPhone/Blackberry/SmartPhone?
• How does NASA program (and reprogram) the Mars
Rover?
P.GOWTHAM.M.E., 3 Apr 12, 2020
Development Environment
• Development processor
• The processor on which we write and debug our programs
• Usually a PC
• Target processor
• The processor that the program will run on in our embedded
system
• Often different from the development processor
Programming Languages
Machine Fixed Rom,
Code Ram,
Firmware
Assembly
Code
Higher Level
Languages
Compiled Interpreted
C, nesC, C+ (?) Markup
+, Ada, Forth, Perl, Python, HTML, XML
etc. Javascript
All Eventually End
up as Machine
Java Code
P.GOWTHAM.M.E., 5 Apr 12, 2020
So you’ve chosen C.
Let’s Go!
(Not so
fast.)
What does a programmer need to know about programming for an
embedded system?
• We should better know about the hardware.
• Purpose
• How data flows (to include getting the program onto the
system, I/O), how to interface with sensors, actuators, etc.
• Whether there is an operating system, and how it runs
programs.
• Limitations: memory, speed, upgradability (firmware?)
• How are hardware errors handled?
• Plan on debugging hardware issues…
P.GOWTHAM.M.E., 7 Apr 12, 2020
So you’ve chosen C.
Let’s Go!
(Not so
fast.)
What does a programmer need to know about programming for an
embedded system?
• We should better know about the software tools related to programming
for the specific hardware.
• Is there a compiler/linker/assembler?
• How is the memory addressed, what bit-level knowledge of the
hardware is necessary, how does one access pins, etc.?
• What licensing needs to be organized.
• Does the software need to be portable? (using C is probably going to
help you—see the second point above).
P.GOWTHAM.M.E., 8 Apr 12, 2020
The Embedded Software
Development Process
P.GOWTHAM.M.E., 9 Apr 12, 2020
CROSS PLATFORM DEVELOPMENT
TOOLS
• Cross Compiler.
• Cross Assembler.
• Cross Debugger.
• Cross Linker.
• Cross Complier libraries.
• OS dependent libraries & header for target
processor.
P.GOWTHAM.M.E., 10 Apr 12, 2020
The Tools
• Compiler: Translates human readable code into assembly
language or opcodes for a particular processor (or possibly into
machine-independent opcodes a la Java). Produces an object file.
• Cross compiler: CC is a compiler which run on the host system
and produce object codes for target system.
• Assembler: Translates assembly language into opcodes (it is
really a compiler, too). Also produces an object file.
• Linker: Organizes the object files, necessary libraries, and other
data and produces a relocatable file.
• Locator: Takes the relocatable file and information about the
memory of the system and produces an executable.
P.GOWTHAM.M.E., 11 Apr 12, 2020
The Tools: Embedded
System Specifics
All of the tools run on the host computer, not the embedded computer.
• Compiler: Has to know about the specific hardware (except in very
trivial cases). Should be able to optimize for size.
• Assembler: Produces “startup code”; not inserted automatically as in
general purpose computers (i.e., the programmer needs to compile it
independently).
• Linker: Needs the correct libraries (open source c libraries, such as
newlib, are available).
• Locator: Needs programmer input for information about memory.
Bottom Line: There can be a lot of extra work for the
programmer, although certain systems (e.g. Pic programming)
tools can automate most of it. 12
P.GOWTHAM.M.E., Apr 12, 2020
Moving the program onto the
embedded system
• Remember, the program is written (and possibly run in an
emulator) on a host computer, but it still needs to get onto the
embedded system.
• Methods:
• Build/burn the program into the hardware (firmware or other
flash memory)
• Bootloader: a bootloader resides on the embedded system and
facilitates loading programs onto the system.
• Debug Monitor: The debug monitor is a more robust program
on an embedded system that helps with debugging and other
chores, and can include a bootloader as well.
P.GOWTHAM.M.E., 13 Apr 12, 2020
Debugging
• Debugging embedded systems can be facilitated with
a Debug Monitor, or through a remote debugger on
the host computer. A serial link is normally set up, and
the debugger acts more or less like a general purpose
debugger.
• Emulators can be used to test the system without
utilizing the actual hardware (but this has many
caveats, and nothing beats testing on the real
system).
• Software Simulators allow the programmer to debug
completely on the host system, which can be quicker
and can allow faster code turnaround.
• When it comes down to it, an oscilloscope and a
multimeter can be your best friend for debugging.
P.GOWTHAM.M.E., 14 Apr 12, 2020
Final Thoughts
• Programming for embedded systems has come a long way
since the days of toggle switches, but it still involves greater
programmer involvement in the hardware aspect of the system.
• There are many software tools built for embedded systems, and
many embedded system hardware designers include debugging
tools with the hardware.
• You had probably learn C (and a fair amount of assembly) to
program embedded systems.
P.GOWTHAM.M.E., 15 Apr 12, 2020
Development/Testing tools
• Hard ware Development/Test tools
• Digital multimeter,Oscilloscope,Logic Analyzer,
Spectrum Analyzer.etc.,
• Soft ware Development/Test tools
• OS Development suit.
• API,ICE,IDE,Emulator,Debugger.
P.GOWTHAM.M.E., 16 Apr 12, 2020
Final Thoughts
• Is this a necessary topic for an Embedded
Systems class?
• Yes
• You’ve got to get your program onto the system
some how, and flipping toggle switches doesn’t
put food on the table any more.
• Hardware only does what you tell it to, via
software.
• Discussion of the tradeoffs necessary to program
an embedded system versus a GP system is a
necessity.
P.GOWTHAM.M.E., 17 Apr 12, 2020
6 Questions
1) Discuss the steps needed to get a program from source code
to executable in an embedded system, and the differences
between similar steps on a general purpose system.
2) What trade-offs are necessary when thinking about how you
are going to program for an embedded system?
3) Why is C generally considered a better language to program
in for embedded systems than, say, Java or Perl?
P.GOWTHAM.M.E., 18 Apr 12, 2020
6 Questions
4) Name three different ways you might debug the code for your
embedded system.
5) Why is it imperative that an embedded system programmer
know the details of the hardware that she is programming
for? Compare this to someone writing a Java applet for a
web site.
6) Talk about the role firmware plays in developing software for
an embedded system.
P.GOWTHAM.M.E., 19 Apr 12, 2020
Bibliography
• Barr, M. & Massa, A. Oram, A. (ed.)
Programming Embedded Systems in C and C++,
2nd Edition. O'Reilly & Associates, Inc., 2006
• Wolfe, M. How compilers and tools differ for
embedded systems. 2005.
http://www.pgroup.com/lit/pgi_article_cases.pdf
• Gay, D.; Levis, P.; von Behren, R.; Welsh, M.;
Brewer, E. & Culler, D. The nesC language: A
holistic approach to networked embedded systems
SIGPLAN Not., ACM, 2003, 38, 1-11
• Williams, B.; Ingham, M.; Chung, S. & Elliott, P.
Model-based programming of intelligent embedded
systems and robotic space explorers
Proceedings of the IEEE, 2003, 91, 212-237
P.GOWTHAM.M.E., 20 Apr 12, 2020