0% found this document useful (0 votes)
233 views33 pages

Embedded Systems: Unit 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
233 views33 pages

Embedded Systems: Unit 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

EMBEDDED SYSTEMS

UNIT 3: EMBEDDED FIRMWARE DESIGN


Mr. P. Tirumala Rao
Assistant Professor
ECE Department.
INTRODUCTION:
• Controls peripherals
• Generates response according to functional requirements
• Master brain and imparts intelligence.
• Continue to serve assigned task until Hardware break down or firm ware corruption
• Adaptive ES use NVRAM and Non adaptive ES use ROM
• Firmware developer should know about Hardware and program languages
• It starts with conversion of firmware requirements to program model using UML or Flowcharts

EMBEDDED FIRMWARE DESIGN APPROACHES


Based on Complexity and speed, Firmware design approaches are classified into
1. Conventional procedural based firm ware design (Super Loop Based Approach)
2. Embedded operating system based approach
THE SUPER LOOP BASED APPROACH

•Used in Non time critical embedded systems


•Tasks in top of program code executed first and vice versa
•In a multitask based system ,each task is executed in a serial fashion
•Example is Vending machine, Card reader etc..

•The firmware execution flow for this will be


1. Configure the common parameters and perform initialisation for various hardware components
memory, registers, etc.
2. Start the first task and execute it
3. Execute the second task
4. Execute the next task
5. :
6. :
7. Execute the last defined task
8. Jump back to the first task and follow the same flow
The order of execution of tasks are fixed and hard coded in the code itself.
Tasks are executed endlessly in an infinite loop based approach.
void main ()
{
Configurations ();
Initialisations ();
while (1)
{
Task 1 ();
Task 2 ();
:
:
Task n ();
}
}
•Used in low cost Embedded systems
•No need of scheduling Tasks
•Order of tasks execution is fixed, hence no need to give priority to tasks
•Only way to come out of loop is
1. Hardware reset
2. Interrupt assertion

Disadvantages
3. Failure in execution of single task will lead to total system failure
4. While execution if program hangs, then controller will be in hanging state forever
5. Require Watchdog timer to reset during system failure
THE EMBEDDED OPERATING SYSTEM (OS) BASED APPROACH

•contains operating systems, which can be either a


•General Purpose Operating System (GPOS) or Real Time Operating System (RTOS)
•Employed in time critical embedded systems
•Used in products which demands Real time response
•Contains real time kernel which is responsible for
1. Pre-emptive multi tasking
2. Scheduling tasks
3. Multiple threads
4. Assigning priority to tasks
•‘Windows Embedded Compact’, ‘pSOS’, ‘VxWorks’, ‘ThreadX’, ‘MicroC/OS-III’, ‘Embedded Linux’,
‘Symbian’ etc are examples of RTOS employed in embedded product development
EMBEDDED FIRMWARE DEVELOPMENT LANGUAGES
• Target processor/controller specific language
• Target processor/controller independent language
• Combination of Assembly and High level Language.
• Where each of the approach is used and the relative merits and de-merits

ASSEMBLY LANGUAGE BASED DEVELOPMENT:


• Assembly language is the human readable
• ‘machine language’ is a processor understandable language
• Machine language is a binary representation and it consists of 1s and 0s
• Machine language is made readable by using specific symbols called ‘ mnemonics
• machine language can be considered as an interface between processor and programmer
• processor/controller dependent and an assembly program written for one processor/controller
family will not work with others
• Assembly language programming is the task of writing processor specific machine code in
mnemonic form, converting the mnemonics into actual processor instructions (machine language)
and associated data using an assembler.
• common type of programming adopted in the beginning of software revolution is Assembly
language
• Each line of an assembly language program is split into four fields as given below
LABEL OPCODE OPERAND COMMENTS
• The general format of an assembly language instruction is an Opcode followed by Operands. The
opcode tells the processor/controller what to do and the Operands provide the data and information
required to perform the action specified by the opcode
• example.
• MOV A, #30
• The same instruction when written in machine language will look like
• 01110100 00011110
• INC A is an example for instruction holding operand implicitly in the Opcode
• The machine language representation of the same is 00000100.
• LJMP 16bit address is an example for dual operand instruction
• The machine language for the same is
• 00000010 addr_bit15 to addr_bit 8 addr_bit7 to addr_bit 0
The sample code given below using 8051 Assembly language illustrates the structured assembly language
programming.
;####################################################################
; SUBROUTINE FOR GENERATING DELAY
; DELAY PARAMETR PASSED THROUGH REGISTER R1
; RETURN VALUE NONE
; REGISTERS USED: R0, R1
;####################################################################
DELAY: MOV R0, #255 ; Load Register R0 with 255
DJNZ R1, DELAY ; Decrement R1 and loop till R1= 0
RET ; Return to calling program
SOURCE FILE TO OBJECT FILE TRANSLATION
FUNDAMENTAL ISSUES IN HARDWARE SOFTWARE CO-DESIGN

 Selecting the model


 Selecting the Architecture
1. Controller Architecture(FSM model- state registers, two
combinational circuits)
2. Data path Architecture
3. Finite State Machine Data path
4. Complex Instruction Set Computing
5. Very Long Instruction Word
6. Parallel processing architecture
 Selecting the language
 Partitioning System Requirements into hardware and software
Embedded Firmware

Introduction:
Embedded Firmware
The control algorithm (Program instructions) and or the configuration settings that an embedded
system developer dumps into the code (Program) memory of the embedded system
It is an un-avoidable part of an embedded system.
The embedded firmware can be developed in various methods like
o Write the program in high level languages like Embedded C/C++ using an Integrated Development
Environment (The IDE will contain an editor, compiler, linker, debugger, simulator etc. IDEs are
different for different family of processors/controllers.
o Write the program in Assembly Language using the Instructions Supported by your application’s
target processor/controller
Embedded Firmware Design & Development:
The embedded firmware is responsible for controlling the various peripherals of the embedded
hardware and generating response in accordance with the functional requirements of the product.
The embedded firmware is the master brain of the embedded system. The embedded firmware imparts
intelligence to an Embedded system. It is a onetime process and it can happen at any stage.
The product starts functioning properly once the intelligence imparted to the product by embedding
the firmware in the hardware.
The product will continue serving the assigned task till hardware breakdown occurs or a corruption in
embedded firmware.
In case of hardware breakdown , the damaged component may need to be replaced and for firmware
corruptions the firmware should be re-loaded, to bring back the embedded product to the normal
functioning.
The embedded firmware is usually stored in a permanent memory (ROM) and it is non alterable by end
users.
Designing Embedded firmware requires understanding of the particular embedded product hardware,
like various component interfacing, memory map details, I/O port details, configuration and register
details of various hardware chips used and some programming language (either low level Assembly
Language or High level language like C/C++ or a combination of the two)
The embedded firmware development process starts with the conversion of the firmware requirements
into a program model using various modeling tools.
The firmware design approaches for embedded product is purely dependent on the complexity of the
functions to be performed and speed of operation required.
There exist two basic approaches for the design and implementation of embedded firmware,
namely;
 The Super loop based approach
 The Embedded Operating System based approach

The decision on which approach needs to be adopted for firmware development is purely
dependent on the complexity and system requirements
Embedded firmware Design Approaches – The Super loop:

The Super loop based firmware development approach is Suitable for applications that are not time
critical and where the response time is not so important (Embedded systems where missing
deadlines are acceptable).
It is very similar to a conventional procedural programming where the code is executed task by task
The tasks are executed in a never ending loop.
The task listed on top on the program code is executed first and the tasks just below the top are
executed after completing the first task
A typical super loop implementation will look like:
1. Configure the common parameters and perform
initialization for various hardware components memory,
registers etc.
2. Start the first task and execute it
3. Execute the second task
4. Execute the next task 5. :

6. :
7. Execute the last defined task
8. Jump back to the first task and follow the same flow.
The ‘C’ program code for the super loop is given below void
main ()
{
Configurations (); Initializations ();
while (1)
{
Task 1 ();
Task 2 ();
:
:
Task n ();
}
}
Pros:
Cons:
Doesn’t require an Operating System for task scheduling and monitoring and free from OS related
overheads
Simple and straight forward design Reduced memory footprint
Non Real time in execution behavior (As the number of tasks increases the frequency at which a
task gets CPU time for execution also increases)
Any issues in any task execution may affect the functioning of the product (This can be effectively
tackled by using Watch Dog Timers for task execution monitoring)
Enhancements:
 Combine Super loop based technique with interrupts
 Execute the tasks (like keyboard handling) which require Real time attention as Interrupt Service
routines.
2. Embedded firmware Design Approaches – Embedded OS based Approach:
The embedded device contains an Embedded Operating System which can be one of:
 A Real Time Operating System (RTOS)
 A Customized General Purpose Operating System (GPOS)

The Embedded OS is responsible for scheduling the execution of user tasks and the allocation of system
resources among multiple tasks
It Involves lot of OS related overheads apart from managing and executing user defined tasks
Microsoft® Windows XP Embedded is an example of GPOS for embedded devices
Point of Sale (PoS) terminals, Gaming Stations, Tablet PCs etc are examples of embedded devices running
on embedded GPOSs
‘Windows CE’, ‘Windows Mobile’,‘QNX’, ‘VxWorks’, ‘ThreadX’, ‘MicroC/OS-II’, ‘Embedded Linux’, ‘Symbian’
etc are examples of RTOSs employed in Embedded Product development
Mobile Phones, PDAs, Flight Control Systems etc are examples of embedded devices that runs on RTOSs
Embedded firmware Development Languages/Options
Assembly Language High Level Language
o Subset of C (Embedded C)
o Subset of C++ (Embedded C++)
o Any other high level language with supported Cross-compiler

Mix of Assembly & High level Language


o Mixing High Level Language (Like C) with Assembly Code
o Mixing Assembly code with High Level Language (Like C)
o Inline Assembly

You might also like