Module 4
Module 4
AJIET, Mangalore
What is Firmware?
• Firmware refers to a small piece of code that resides in non-
volatile memory.
• In hardware peripherals that are commonly found in offices
these days (e.g. printers, VoIP(voice over Internet protocol)
phones, etc.)
• Firmware's are usually responsible for loading (e.g. OS code
signature verification) and managing (e.g. flashing OS in
recovery mode) the operating systems that is installed on the
machine.
• It's the operating system's job to carry out the actual task (e.g.
printing)
Firmware design approaches:
• Two basic approaches are used in embedded systems.
Ex:
Label opcode operand comment
mov a , #30 ;data transfer operation
• Opcode tells the processor what to do, in the previous example it
is mov a .
28
C vs Embedded C
• C is well structured, well defined and standardised general
purpose programming.
• ANSI(American national Standard Institute) and have various
library files
• Compiler used for conversion
30
Compiler Vs Cross-Compiler
• Compiler converts a source code written in high level language on
top of particular OS running on a specific target processor.
32
@ McGraw-Hill Education
33
@ McGraw-Hill Education
34
@ McGraw-Hill Education
Object File
• Cross-compiling/assembling each source module (written in
C/Assembly) converts the various Embedded C/ Assembly
instructions and other directives present in the module to an
object (.OBJ) file.
• OMF51 or OMF2 are the two objects file formats supported by
C51 cross compiler.
• The object file is a specially formatted file with data records for
symbolic information, object code, debugging information,
library references, etc.
35
@ McGraw-Hill Education
36
@ McGraw-Hill Education
37
@ McGraw-Hill Education
• Page Header
• Command Line
• CPU Details
• Input Modules
• Memory Map
• Symbol Table
• Inter Module Cross Reference
• Program Size
• Warnings and Errors
38
@ McGraw-Hill Education
39
@ McGraw-Hill Education
Intel HEX file is used for transferring the program and data to a ROM or
EPROM which is used as code memory storage.
• Each record is made up of five fields arranged in the following
format:
• :llaaaattdd...cc
40
@ McGraw-Hill Education
41
@ McGraw-Hill Education
Intel hex fi le generated for “Hello World” application example is given below
42
@ McGraw-Hill Education
• Motorola HEX file is also an ASCII text file where the HEX data
is represented in ASCII format in lines.
• The lines in Motorola HEX file represent a HEX Record. Each
record is made up of hexadecimal numbers that represent
machine-language code and/or constant data.
• The general form of Motorola Hex record is given below.
43
@ McGraw-Hill Education
44
@ McGraw-Hill Education
45
@ McGraw-Hill Education
DISASSEMBLER/DECOMPILER
• The process of converting machine codes into Assembly code is
known as ‘Disassembling’.
• In operation, disassembling is complementary to
assembling/crossassembling.
• 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.
46
@ McGraw-Hill Education
47
@ McGraw-Hill Education
48
@ McGraw-Hill Education
49
@ McGraw-Hill Education
VCET, Puttur
50
@ McGraw-Hill Education
51
@ McGraw-Hill Education
52
@ McGraw-Hill Education
54
@ McGraw-Hill Education
55
@ McGraw-Hill Education
56
@ McGraw-Hill Education
57
@ McGraw-Hill Education
58
@ McGraw-Hill Education
59
@ McGraw-Hill Education
60
@ McGraw-Hill Education
61
@ McGraw-Hill Education
62
@ McGraw-Hill Education
63
@ McGraw-Hill Education
Emulation Device
• Emulation Device is a replica of the target CPU which receives
various signals from the target board through a device adaptor
connected to the target board and performs the execution of fi
rmware under the control of debug commands from the debug
application.
• The emulation device can be either a standard chip same as the
target processor (e.g. AT89C51) or a Programmable Logic
Device (PLD) configured to function as the target CPU.
• If a standard chip is used as the emulation device, the emulation
will provide real-time execution behaviour ,emulator becomes
dedicated to that particular device and cannot be re-used for the
derivatives of the same chip.
64
@ McGraw-Hill Education
65
@ McGraw-Hill Education
Emulation Memory
• It is the Random Access Memory (RAM) incorporated in the
Emulator device. It acts as a replacement to the target board’s
EEPROM
• Emulation memory also acts as a trace buffer in debugging.
• Trace buffer is a memory pool holding the instructions
executed/registers modified/related data by the processor while
debugging.
• The common features of trace buffer memory are
1)Trace buffer records each bus cycle in frames
2) Trace data can be viewed in the debugger application as
Assembly/Source code
3)Trace buffering can be done on the basis of a Trace trigger (Event)
66
@ McGraw-Hill Education
67
@ McGraw-Hill Education
The device adaptor is usually connected to the emulator POD using ribbon cables .
68
@ McGraw-Hill Education
69
@ McGraw-Hill Education
70