ES Mod IV
ES Mod IV
MODULE IV
SOFTWARE IMPLEMENTATION
1
Embedded Systems Module IV: Programming concepts of Embedded programming
2
Embedded Systems Module IV: Programming concepts of Embedded programming
If you are using a commercial version of assembler suit for your development, the
vendor of utility may provide you pre-written library files for performing
multiplication, floating point arithmetic, etc. as an add-on utility.
3
Embedded Systems Module IV: Programming concepts of Embedded programming
The program written in any of the high level language is saved with the corresponding
language extension
Any text editor provided by IDE tool supporting the high level language in use can be
used for writing the program
4
Embedded Systems Module IV: Programming concepts of Embedded programming
Most of the high level language support modular programming approach and hence
you can have multiple source files called modules written in corresponding high
level language
The source file corresponding to each module is represented by a file with
corresponding language extension
Translation of high level source code to executable object code is done by a cross
compiler
The cross compiler for different high level language for same target processor are
different
Without cross-compiler support a high level language cannot be used for embedded
firmware development
5
Embedded Systems Module IV: Programming concepts of Embedded programming
Portability
– Target applications written in high level languages are converted to target
processor understandable format by a cross compiler
– An application written in high level language for a target processor can be easily
converted to another target processor with little effort by simply recompiling the
code modification followed by the recompiling the application for the required
processor
– This makes the high level language applications are highly portable
6
Embedded Systems Module IV: Programming concepts of Embedded programming
When accessing certain low level hardware, the timing specification may be very
critical and a cross compiler generated binary may not be able to offer the required
time specifications accurately
Writing the hardware access routine in processor specific assembly language and
invoking it from C is the most advised method to handle such situations
7
Embedded Systems Module IV: Programming concepts of Embedded programming
Testing is an organized process to verify the behavior, performance, and reliability of a device or
system against designed specifications. It ensures a device or system to be as defect-free as
possible.
Why Test?
Types of Testing
Unit Testing.
Individual developers test at the module level. The unit module is either an isolated function or a
class. This is done by the development team, typically the developer and is done usually in the
peer review mode. The developers test with some average values, some high or low values, and
some out-of-range values
Regression Testing.
It isn’t enough to pass a test once. Every time the program is modified, it should be retested to
assure that the changes didn’t unintentionally create some unrelated behavior.
Regression tests are usually automated through a test script. For example, if you design a set of
100 input/output tests, the regression test script would automatically execute the 100 tests and
compare the output against a “gold standard” output suite. Every time a change is made to any part
of the program code, the full regression suite runs on the modified code to ensure that something
else wasn’t broken in the process.
Functional testing is often called black-box testing because the test cases for functional tests are
devised without reference to the actual code—that is, without looking “inside the box.”
An embedded system has inputs and outputs and implements some algorithm between them.
Black-box tests are based on what is known about which inputs should be acceptable and how they
should relate to the outputs. Black-box tests know nothing about how the algorithm in between is
implemented. Example black-box tests include:
8
Embedded Systems Module IV: Programming concepts of Embedded programming
• Stress tests: Tests that intentionally overload input channels, memory buffers, disk controllers,
memory management systems, and so on.
• Boundary value tests: Inputs that represent “boundaries” within a range and input values that
should cause the output to transition across a similar boundary in the output range.
• Exception tests: Tests that should trigger a failure mode or exception mode.
• Error guessing: Tests based on prior experience with testing software or from testing similar
programs.
• Random tests: Generally, the least productive form of testing but still widely used to evaluate
the robustness of user-interface code.
• Performance tests: Because performance expectations are part of the product requirement,
performance analysis falls within the sphere of functional testing.
The weakness of functional testing is that it rarely exercises all the code. Coverage tests attempt
to avoid this weakness by (ideally) ensuring that each code statement, decision point, or decision
path is exercised at least once.
Also known as white-box tests, coverage tests are devised with full knowledge of how the software
is implemented.” White-box tests are designed with the source code handy.Because white-box
tests depend on specific implementation decisions, they can’t be designed until after the code is
written.
From an embedded systems point of view, coverage testing is the most important type of testing
because the degree to which you can show how much of your code has been exercised is an
excellent predictor of the risk of undetected bugs you’ll be facing later. Example white-box tests
include:
• Statement coverage: Test cases selected because they execute every Statement in the program at
least once.
• Decision or branch coverage: Test cases chosen because they cause every branch (both the true
and false path) to be executed at least once.
• Condition coverage: Test cases chosen to force each condition (term) in a decision to take on all
possible logic values.
Gray-Box Testing
9
Embedded Systems Module IV: Programming concepts of Embedded programming
Because white-box tests can be intimately connected to the internals of the code, they can be more
expensive to maintain than black-box tests. Whereas black-box tests remain valid as long as the
requirements and the I/O relationships remain stable, white-box tests might need to be re-
engineered every time the code is changed. Thus, the most cost-effective white-box tests generally
are those that exploit knowledge of the implementation without being intimately tied to the coding
details.
Tests that only know a little about the internals are sometimes called gray-box tests. Gray-box
tests can be very effective when coupled with “error guessing.” If you know, or at least suspect,
where the weak points are in the code, you can design tests that stress those weak points.
These tests are gray box because they cover specific portions of the code; they are error guessing
because they are chosen based on a guess about what errors are likely.
This testing strategy is useful when you’re integrating new functionality with a stable base of
legacy code. Because the code base is already well tested, it makes sense to focus your test efforts
in the area where the new code and the old code come together.
10
Embedded Systems Module IV: Programming concepts of Embedded programming
SoC acronym for system on chip is an integrated circuit which integrates all the components of a
computer into a single chip. It may contain analog, digital, mixed signal and other radio frequency
functions all lying on a single chip substrate. Today, SoCs are very common in electronics industry
due to its low power consumption. Also, embedded system applications make great use of SoCs.
Control Unit: In SoCs, the major control units are microprocessors, microcontrollers, digital
signal processors etc.
Memory Blocks: ROM, RAM. Flash memory and EEPROM are the basic memory units
inside a SoC chip.
Timing Units: Oscillators and PLLs are the timing units of the System on chip.
Other peripherals of the SoCs are counter timers, real-time timers and power on reset
generators.
Analog interfaces, external interfaces, voltage regulators and power management units form
the basic interfaces of the SoCs.
On-chip interconnection (busses, network, etc.)
Accelerators or application specific hardware modules
Software – OS, Application, etc.
This Single Chip contains both hardware and software components.
11
Embedded Systems Module IV: Programming concepts of Embedded programming
Advantages of SoC
Low power.
Low cost.
High reliability.
Small form factor.
High integration levels.
Fast operation.
Greater design.
Small size.
Disadvantages of SoC
Fabrication cost.
Increased complexity.
Time to market demands.
More verification.
Example:
12
Embedded Systems Module IV: Programming concepts of Embedded programming
IDE consists of a software package which bundles a ‘Text editor’ (source code editor), ‘Cross
compiler (for cross platform development and compiler for same platform development), ‘Linker’
and a ‘Debugger’.
IDE’s can be command line based or GUI based. GUI based IDEs provide a Visual Development
Environment with user interactions through touch/mouse click interface. Such IDEs are generally
known as Visual IDEs. Eg: Microsoft Visual Studio for developing Visual C++ and Visual Basic
programs.
CROSS COMPILERS
Cross compilation is the process of converting a source code written in high level language to a
target processor understandable machine code. The conversion of code is done by software running
on a processor which is different from the target processor. The software performing this operation
is referred as the cross compiler.
Cross assembler converts assembly code to machine code.
DISASSEMBLER/DECOMPILER
Disassembler is a utility program which converts machine codes into target processor specific
Assembly codes/instructions. The process of converting machine codes into Assembly code is
known as 'Disassembling'. In operation, disassembling is complementary to assembling/cross-
assembling.
Decompiler is the utility program for translating machine codes into corresponding high-level
language instructions. Decompiler performs the reverse Operation of compiler/cross-compiler.
The disassemblers/ decompilers for different family of processors/controllers are different.
Disassemblers/Decompilers are deployed in reverse engineering.
SIMULATORS
Simulator is a software tool used for simulating the various conditions for checking the
functionality of the application firmware. The Integrated Development Environment (IDE) itself
will be providing simulator support and they help in debugging the firmware for checking its
required functionality. In certain scenarios, simulator refers to a soft model (GUI model) of the
embedded product. For example, if the product under development is a handheld device, to test
the functionalities of the various menu and user interfaces, a soft form model of the product with
all Ul as given in the end product can be developed in software. Soft phone is an example for such
a simulator.
13
Embedded Systems Module IV: Programming concepts of Embedded programming
Simulators simulate the target hardware and the firmware execution can be inspected using
simulators. The features of simulator-based debugging are listed below.
14
Embedded Systems Module IV: Programming concepts of Embedded programming
Obviously, it is a time-consuming process. But it is a onetime process and once you test the
firmware in an incremental model you can go for mass production. In incremental firmware
burning technique we are not doing any debugging but observing the status of firmware execution
as a debug method. The very common mistake committed by firmware developers in developing
non-operating system-based embedded application is burning the entire code altogether and fed up
with debugging the code. Incremental firmware burning technique is widely adopted in small,
simple system developments and in product development where time is not a big constraint.
The entire code handling the command reception and corresponding action implementation is
known as monitor program. The interface used between target board and debug application is RS-
232/USB Serial interface. After the successful completion of the 'monitor program' development,
it is compiled and burned into the FLASH memory or ROM of the target board. The code memory
containing the monitor program is known as the `Monitor ROM '.
15
Embedded Systems Module IV: Programming concepts of Embedded programming
16