0% found this document useful (0 votes)
6 views27 pages

ilovepdf_merged (6)

The document covers embedded system design concepts, focusing on aspects like portability, time to market, cost analysis, and application-specific systems such as washing machines. It discusses state machine models, sequential program models, and the role of operating systems, including kernel functions and types of operating systems like General Purpose and Real-Time Operating Systems. Additionally, it highlights the importance of firmware development languages and the integration of high-level and low-level programming languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views27 pages

ilovepdf_merged (6)

The document covers embedded system design concepts, focusing on aspects like portability, time to market, cost analysis, and application-specific systems such as washing machines. It discusses state machine models, sequential program models, and the role of operating systems, including kernel functions and types of operating systems like General Purpose and Real-Time Operating Systems. Additionally, it highlights the importance of firmware development languages and the integration of high-level and low-level programming languages.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Embedded System Design Concepts MODULE-2(BEC601)

 An embedded product can be called portable if it is capable of performing its operation as


it is intended to do in various environments irrespective of different processor and or
controller and embedded operating systems.

d) Time to prototype and market


 Time to Market is the time elapsed between the conceptualization of a product and time
at which the product is ready for selling or use
 Product prototyping help in reducing time to market.
 Prototyping is an informal kind of rapid product development in which important feature
of the under consider are develop.
 In order to shorten the time to prototype, make use of all possible option like use of reuse,
off the self component etc.

e) Per unit and total cost


 Cost is an important factor which needs to be carefully monitored. Proper market study
and cost benefit analysis should be carried out before taking decision on the per unit cost
of the embedded product.
 When the product is introduced in the market, for the initial period the sales and revenue
will be low
 There won’t be much competition when the product sales and revenue increase.
 During the maturing phase, the growth will be steady and revenue reaches highest point
and at retirement time there will be a drop in sales volume.

6
Embedded System Design Concepts MODULE-2(BEC601)

*EMBEDDED SYSTEMS - APPLICATION AND DOMAIN

SPECIFIC

Application specific systems: Washing Machine


Let us see the important parts of the washing machine; this will also help us understand the working
of the washing machine:
1) Water inlet control valve: Near the water inlet point of the washing there is water inlet
control valve. When you load the clothes in washing machine, this valve gets opened
automatically and it closes automatically depending on the total quantity of the water required.
The water control valve is actually the solenoid valve.

2) Water pump: The water pump circulates water through the washing machine. It works in two
directions, re-circulating the water during wash cycle and draining the water during the spin
cycle

7
Embedded System Design Concepts MODULE-2(BEC601)

3) Tub: There are two types of tubs in the washing machine: inner and outer. The clothes are
loaded in the inner tub, where the clothes are washed, rinsed and dried. The inner tub has small

holes for draining the water. The external tub covers the inner tub and supports it during various
cycles of clothes washing.

8
Embedded System Design Concepts MODULE-2(BEC601)

 State Machine Model

 Based on ‘States’ and ‘State Transition’

 Describes the system behavior with ‘States’, ‘Events’, ‘Actions’ and ‘Transitions’

 State is a representation of a current situation.

 An event is an input to the state. The event acts as stimuli for state transition.

 Transition is the movement from one state to another.

 Action is an activity to be performed by the state machine.

 A Finite State Machine (FSM) Model is one in which the number of states are
finite. In other words the system is described using a finite number of possible
states

 Most of the time State Machine model translates the requirements into sequence
driven program

 The Hierarchical/Concurrent Finite State Machine Model (HCFSM) is an extension


of the FSM for supporting concurrency and hierarchy

 HCFSM extends the conventional state diagrams by the AND, OR decomposition


of States together with inter level transitions and a broadcast mechanism for
communicating between concurrent processes

 HCFSM uses state charts for capturing the states, transitions, events and actions.
The Harel State chart, UML State diagram etc are examples for popular state charts
used for the HCFSM modeling of embedded systems.

16
Embedded System Design Concepts MODULE-2(BEC601)

E.g. Automatic ‘Seat Belt Warning’ in an automotive

Requirement:

 When the vehicle ignition is turned on and the seat belt is not fastened within 10
seconds of ignition ON, the system generates an alarm signal for 5 seconds. The
Alarm is turned off when the alarm time (5 seconds) expires or if the
driver/passenger fastens the belt or if the ignition switch is turned off, which ever
happens first.

Here the states are


• 'Alarm Off’
• 'Waiting’
• 'Alarm On’
The events are
• 'Ignition Key ON’
• 'Ignition Key OFF’
• 'Timer Expire’
• 'Alarm Time Expire’
• 'Seat Belt ON’
 Sequential Program Model

 The functions or processing requirements are executed in sequence

 The program instructions are iterated and executed conditionally and the data gets
transformed through a series of operations

 FSMs are good choice for sequential Program modeling.

 Flow Charts is another important tool used for modeling sequential program

 The FSM approach represents the states, events, transitions and actions, whereas the
Flow Chart models the execution flow
17
Embedded System Design Concepts MODULE-2(BEC601)

E.g. Automatic ‘Seat Belt Warning’ in an automotive

Requirement:

 When the vehicle ignition is turned on and the seat belt is not fastened within 10
seconds of ignition ON, the system generates an alarm signal for 5 seconds.

 The Alarm is turned off when the alarm time (5 seconds) expires or if the
driver/passenger fastens the belt or if the ignition switch is turned off, whichever
happens first.

E.g. Automatic ‘Seat Belt Warning’ in an automotive

18
Embedded System Design Concepts MODULE-2(BEC601)

generated code needs to be placed (a re-locatable code) on the program


memory.
 The software program called linker/locater is responsible for assigning
absolute address to object files during the linking process.
 The Absolute object file created from the object files corresponding to
different source code modules contain information about the address where
each instruction needs to be placed in code memory.
 A software utility called ‘Object to Hex file converter’ translates the
absolute object file to corresponding hex file (binary file)

Advantages:
Reduced Development time: Developer requires less or little
Knowledge on internal hardware details and architecture of the target processor/Controller.
Developer independency: The syntax used by most of the high level languages
are universal and a program written high level can easily understand by a second
person knowing the syntax of the language
Portability: An Application written in high level language for particular target
processor /controller can be easily be converted to another target
processor/controller specific application with little or less effort
Drawbacks:
• The cross compilers may not be efficient in generating the optimized target
processor specific instructions.
• Target images created by such compilers may be messy and non- optimized in
terms of performance as well as code size.
• The investment required for high level language based development tools (IDE) is
high compared to Assembly Language based firmware development tools.

3. Embedded firmware Development Languages/Options – Mixing of Assembly Language


with High Level Language:
 Embedded firmware development may require the mixing of Assembly Language with high
level language or vice versa.
 Interrupt handling, Source code is already available in high level language\Assembly
Language etc are examples.
 High Level language and low level language can be mixed in three different ways
 Mixing Assembly Language with High level language like ‘C’
 Mixing High level language like ‘C’ with Assembly Language
 In line Assembly
The passing of parameters and return values between the high level and low level
language is cross-compiler specific

25
Embedded System Design Concepts MODULE-2(BEC601)

High Level Language –


1) ‘C’ V/s ‘Embedded C’
 ‘C’ is a well structured, well defined and standardized general purpose programming language with
extensive bit manipulation support
 ‘C’ offers a combination of the features of high level language and assembly and helps in hardware
access programming (system level programming) as well as business package developments
(Application developments like pay roll systems, banking applications etc)
 The conventional ‘C’ language follows ANSI standard and it incorporates various library files for
different operating systems
 A platform (Operating System) specific application, known as, compiler is used for the conversion
of programs written in ‘C’ to the target processor (on which the OS is running) specific binary files
 Embedded C can be considered as a subset of conventional ‘C’ language
 Embedded C supports all ‘C’ instructions and incorporates a few target processor specific
functions/instructions.
 The standard ANSI ‘C’ library implementation is always tailored to the target processor/controller
library files in Embedded C.
 The implementation of target processor/controller specific functions/instructions depends upon the
processor/controller as well as the supported cross-compiler for the particular Embedded C
language.
 A software program called ‘Cross-compiler’ is used for the conversion of programs written in
Embedded C to target processor/controller specific instructions.

26
Operating System Basics
• The operating system acts as a bridge between the user applications/tasks and the
underlying system resources
• The OS acts as a resource manager
• The primary functions of an operating system are:
• Make the system convenient to use
• Resource Management

The Kernel
 The kernel is the core of the operating system and is responsible for managing the
system resources and the communication among the hardware and other system
services.
 Kernel acts as the abstraction layer between system resources and user applications.
 Kernel contains a set of system libraries and services.
For a general purpose OS, the kernel contains different services for handling the following:
• Process Management
• Primary Memory Management
• File System Management
• I/O System (Device) Management
• Secondary Storage Management
• Protection Systems
• Interrupt Handler
Process Management:
• Process management deals with managing the processes/tasks.
• Process management includes
• Setting up the memory space for the process
• Loading the process's code into the memory space
• Allocating system resources
• Scheduling and managing the execution of the process
• Setting up and managing the Process Control Block (PCB)
• Inter Process Communication and synchronisation
• Process termination/deletion, etc.

Primary Memory Management


• The term primary memory refers to the volatile memory (RAM) where processes are
loaded and variables and shared data associated with each process are stored.
• The Memory Management Unit (MMU) of the kernel is responsible for
• Keeping track of which part of the memory area is currently used by which
process
• Allocating and De-allocating memory space on a need basis (Dynamic
memory allocation)

File System Management


• File is a collection of related information.
• A file could be a program (source code or executable), text files, image files,
word documents, audio/video files, etc.
• The file system management service of Kernel is responsible for
• The creation, deletion and alteration of files
• Creation, deletion and alteration of directories
• Saving of files in the secondary storage memory (e.g. Hard disk storage)
• Providing automatic allocation of file space based on the amount of free space
available
• Providing a flexible naming convention for the files
I/O System (Device) Management
• Kernel is responsible for routing the I/O requests coming from different user
applications to the appropriate I/O devices of the system.
• In a well-structured OS, the direct accessing of I/O devices are not allowed and the
access to them are provided through a set of Application Programming Interfaces
(APIs) exposed by the kernel.
• The kernel maintains a list of all the I/O devices of the system. May be available in
advance or updated dynamically as and when a new device is installed.
• The service Device Manager of the kernel is responsible for handling all I/O device
related operations.
• The kernel talks to the I/O device through a set of low-level systems calls, which are
implemented in a service called device drivers.
Secondary Storage Management
• The secondary storage management deals with managing the secondary storage
memory devices, if any, connected to the system.
• Secondary memory is used as backup medium for programs and data since the main
memory is volatile.
• In most of the systems, the secondary storage is kept in disks (Hard Disk).
• The secondary storage management service of kernel deals with
• Disk storage allocation
• Disk scheduling (Time interval at which the disk is activated to backup data)
• Free Disk space management
Protection Systems
• Most of the modern operating systems are designed in such a way to support multiple
users with different levels of access permissions.
E.g. ‘Administrator’, ‘Standard’, ‘Restricted’ permissions in Windows XP.
• Protection deals with implementing the security policies to restrict the access to both
user and system resources by different applications or processes or users.
• ln multiuser supported operating systems, one user may not be allowed to view or
modify the whole or portions of another user's data or profile details.
Kernel Space and User Space
• The applications/services are classified into two categories:
• User applications
• Kernel applications
• Kernel Space is the memory space at which the kernel code is located
• Kernel applications/services are kept in this contiguous area of primary
(working) memory.
• It is protected from the unauthorised access by user programs/applications.
• User Space is the memory area where user applications are loaded and executed.
• The partitioning of memory into kernel and user space is purely OS dependent.
• In an operating system with virtual memory support, the user applications are loaded
into its corresponding virtual memory space with demand paging technique.
• The entire code for the user application need not be loaded to the main
(primary) memory at once.
• The user application code is split into different pages and these pages are
loaded into and out of the main memory area on a need basis.
• The act of loading the code into and out of the main memory is termed as
'Swapping’.
• Swapping happens between the main (primary) memory and secondary
storage memory.
• Microkernel based design approach offers the following benefits:
• Robustness
• If a problem is encountered in any of the services, which runs as 'Server'
application, the same can be reconfigured and re-started without the
need for re- starting the entire OS.
• This approach is highly useful for systems, which demands high
'availability’.
• Since the services which run as 'Servers' are running on a different
memory space, the chances of corruption of kernel services are ideally
zero.
• Configurability
• Any service which runs as 'Server' application can be changed without
the need to restart the whole system.
• This makes the system dynamically configurable.
Types of Operating Systems
Depending on the type of kernel and kernel services, purpose and type of computing systems
where the OS is deployed and the responsiveness to applications, Operating Systems are
classified into different types.
• General Purpose Operating System (GPOS)
• Real-Time Operating System (RTOS)
General Purpose Operating System (GPOS)
The operating systems which are deployed in general computing systems are referred as
General Purpose Operating Systems (GPOS).
• The kernel of such a GPOS is more generalised and it contains all kinds of services
required for executing generic applications.
• General purpose operating systems are often quite non-deterministic in behaviour.
• GPOS are usually deployed in computing systems where deterministic behaviour is not
an important criterion.
• Personal Computer/Desktop system is a typical example for a system where GPOSs are
deployed.
• Windows (11,10, 7) XP/MS-DOS etc. are examples for General Purpose Operating
Systems.
Real-Time Operating System (RTOS)
Real-Time' refers to deterministic timing behavior, meaning OS services take a known, fixed
time regardless of the number of tasks.
An RTOS (Real-Time Operating System) enforces policies and rules for time-critical resource
allocation. It determines task execution order and time allocation, ensuring predictable
performance.
A well-designed RTOS maintains consistency through policies that shape its structure and rules
that enforce them while resolving conflicts.
Examples of RTOS include Windows CE, QNX, VxWorks, and MicroC/OS-II.
The Real-Time Kernel
• The kernel of a Real-Time Operating System is referred as Real-Time kernel.
• The Real-Time kernel is highly specialised and it contains only the minimal set of
services required for running the user applications/tasks.
• The basic functions of a Real-Time kernel are:
• Task/Process Management
• Task/Process Scheduling
• Task/Process Synchronisation
• Error/Exception Handling
• Memory Management
• Interrupt Handling
• Time Management
Task/Process Management
Deals with
 Setting up the memory space for the tasks
 Loading the task's code into the memory space allocating system resources
 Setting up a Task Control Block (TCB) for the task task/process termination/deletion
 A Task Control Block (TCB) is used for holding the information corresponding to a
task.
TCB usually contains the following set of information:
 Task ID: Task Identification Number
 Task State: The current state of the task (e.g. State = 'Ready' for a task which is ready
to execute)
 Task Type: Indicates what is the type for this task. The task can be a hard real time or
soft real time or background task.
 Task Priority: Task priority (e.g. Task priority = 1 for task with priority = 1)
 Task Context Pointer: Pointer for context saving
 Task Memory Pointers: Pointers to the code memory, data memory and stack memory
for the task
 Task System Resource Pointers: Pointers to system resources (semaphores, mutex,
etc.) used by the task
 Task Pointers: Pointers to other TCBs (TCBs for preceding, next and waiting tasks)
 Other Parameters: Other relevant task parameters
The parameters and implementation of the TCB is kernel dependent.
The TCB parameters vary across different kernels, based on the task management
implementation.
Task management service utilises the TCB of a task in the following way:
 Creates a TCB for a task on creating a task
 Delete/remove the TCB of a task when the task is terminated or deleted
 Reads the TCB to get the state of a task
 Update the TCB with updated parameters on need basis (e.g. on a context switch)
 Modify the TCB to change the priority of the task dynamically

Task/Process Scheduling
 Deals with sharing the CPU among various tasks/processes.
 A kernel application called 'Scheduler' handles the task scheduling.
 Scheduler is nothing but an algorithm implementation, which performs the efficient and
optimum scheduling of tasks to provide a deterministic behaviour.
Task/Process Synchronisation
 Deals with synchronising the concurrent access of a resource, which is shared across
multiple tasks and the communication between various tasks.
Error/Exception Handling
 Deals with registering and handling the errors occurred/exceptions raised during the
execution of tasks.
 Insufficient memory, timeouts, deadlocks, deadline missing, bus error, divide by zero,
unknown instruction execution, etc. are examples of errors/exceptions.
 Errors/Exceptions can happen at the kernel level services or at task level.
 Deadlock is an example for kernel level exception, whereas timeout is an example for
a task level exception.
 The OS kernel gives the information about the error in the form of a system call (API).
 Watchdog timer is a mechanism for handling the timeouts for tasks.
Memory Management
 RTOS makes use of 'block' based memory allocation technique, instead of the usual
dynamic memory allocation techniques used by the GPOS.
 RTOS kernel uses blocks of fixed size of dynamic memory and the block is allocated
for a task on a need basis.
 The blocks are stored in a 'Free Buffer Queue’.
 To achieve predictable timing and avoid the timing overheads, most of the RTOS
kernels allow tasks to access any of the memory blocks without any memory protection.
 RTOS kernels assume that the whole design is proven correct and protection is
unnecessary.
 Some commercial RTOS kernels allow memory protection as optional.
Interrupt Handling
 Deals with the handling of various types of interrupts.
 Interrupts provide Real-Time behaviour to systems.
 Interrupts inform the processor that an external device or an associated task requires
immediate attention of the CPU.
 Interrupts can be either Synchronous or Asynchronous.
Synchronous interrupts:
 Occur in sync with the currently executing task.
 Usually the software interrupts fall under this category.
 Divide by zero, memory segmentation error, etc. are examples of synchronous
interrupts. For synchronous interrupts, the interrupt handler runs in the same context of
the interrupting task.
Memory Mapped Objects
• Memory mapped object is a shared memory technique adopted by certain Real-Time
Operating Systems for allocating a shared block of memory which can be accessed by
multiple process simultaneously.
• In this approach, a mapping object is created and physical storage for it is reserved and
committed.
• A process can map the entire committed physical area or a block of it to its virtual
address space.
• All read and write operation to this virtual address space by a process is directed to its
committed physical area.
• Any process which wants to share data with other processes can map the physical
memory area of the mapped object to its virtual memory space and use it for sharing
the data.
2. Message Passing
• Message passing is an (a)synchronous information exchange mechanism used for Inter
Process/Thread Communication.
• The major difference between shared memory and message passing technique is that,
through shared memory lots of data can be shared whereas only limited amount of
information/data is passed through message passing.
• Also, message passing is relatively fast and free from the synchronisation overheads
compared to shared memory.
• Based on the message passing operation between the processes, message passing is
classified into:
• Message Queue
• Mailbox
• Signalling
Message Queue
• 'Message queue’ is a First-In-First-Out (FIFO) queue which stores the messages
temporarily in a system defined memory object to pass it to the desired process.
• Usually the process which wants to talk to another process posts the message to a
message queue.
• Messages are sent and received through send and receive methods.
• send (Name of the process to which the message is to be sent, message)
• receive (Name of the process from which the message is to be received, message)
• The implementation of the message queue, send and receive methods are OS kernel
dependent.

Mailbox
• Mailbox is an alternate form of ‘Message queue’ and it is used in RTOS for IPC usually
for one way messaging.
• The task/thread which wants to send a message to other tasks/threads creates a mailbox
for posting the messages.
• The threads which are interested in receiving the messages posted to the mailbox by the
mailbox creator thread can subscribe to the mailbox.
• The thread which creates the mailbox is known as 'mailbox server' and the threads
which subscribe to the mailbox are known as 'mailbox clients’.
• The mailbox server posts messages to the mailbox and notifies it to the clients which
are subscribed to the mailbox.
• The clients read the message from the mailbox on receiving the notification.

Signalling
• Signalling is a primitive way of communication between processes/threads.
• Signals are used for asynchronous notifications where one process/thread fires a
signal, indicating the occurrence of a scenario which the other process(es)/thread(s) is
waiting.
• Signals are not queued and they do not carry any data.
• E.g. Communication mechanisms used in RTX51 Tiny OS, inter process
communication in VxWorks OS Kernel are examples for signalling.
3. Remote Procedure Call (RPC) and Sockets
• Remote Procedure Call (RPC) is the Inter Process Communication (IPC) mechanism
used by a process to call a procedure of another process running on the same CPU or
on a different CPU which is interconnected in a network.
• In the object oriented language terminology, RPC is also known as Remote Invocation
or Remote Method Invocation (RMI).
• RPC is mainly used for distributed applications like client-server applications.
• With RPC it is possible to communicate over a heterogeneous network (i.e.
Network where Client and server applications are running on different operating
systems). The CPU/process containing the procedure which needs to be invoked
remotely is known as server.
• The CPU/process which initiates an RPC request is known as client.
EMBEDDED SYSTEM HARDWARE:
Embedded systems can control many different devices, from small sensors found on a production
line, to the real-time control systems used on a NASA space probe. All these devices use a
combination of software and hardware components.
The following Figure shows a typical embedded device based on an ARM core. Each box
represents a feature or function. The lines connecting the boxes are the buses carrying data.

Figure: An ARM-based Embedded Device, a Microcontroller

We can separate the device into four main hardware components:


1. The ARM processor controls the embedded device. Different versions of the ARM
processor are available to suit the desired operating characteristics. An ARM processor
comprises a core (the execution engine that processes instructions and manipulates data)
plus the surrounding components (memory and cache) that interface it with a bus.
2. Controllers coordinate important functional blocks of the system. Two commonly found
controllers are interrupt and memory controllers.
3. The peripherals provide all the input-output capability external to the chip and are
responsible forthe uniqueness of the embedded device.

4. A bus is used to communicate between different parts of the device.

page: 7
Figure: ARM Core dataflow Model
The arrows represent the flow of data, the lines represent the buses, and the boxes represent
either an operation unit or a storage area.

o load instructions copy data from memory to registers in the core


o store instructions copy data from registers to memory
 There are no data processing instructions that directly manipulate data in memory. Thus,
data processing is carried out in registers.
 Data items are placed in the register file—a storage bank made up of 32-bit registers.
o Since the ARM core is a 32-bit processor, most instructions treat the registers as
holding signed or unsigned 32-bit values. The sign extend hardware converts
signed 8-bit and 16-bit numbers to 32-bit values as they are read from memory
and placed in a register.
 ARM instructions typically have two source registers, Rn and Rm, and a single result or
destination register, Rd. Source operands are read from the register file using the
internal buses A and B, respectively.
 The ALU (arithmetic logic unit) or MAC (multiply-accumulate unit) takes the register
values Rn and Rm from the A and B buses and computes a result. Data processing
instructions write the result in Rd directly to the register file.
 Load and store instructions use the ALU to generate an address to be held in the address
register and broadcast on the Address bus.
o One important feature of the ARM is that register Rm alternatively can be
preprocessed in the barrel shifter before it enters the ALU. Together the barrel
shifter and ALU can calculate a wide range of expressions and addresses.
 After passing through the functional units, the result in Rd is written back to the register
file usingthe Result bus.
 For load and store instructions the Incrementer updates the address register before the
core reads or writes the next register value from or to the next sequential memory
location.
 The processor continues executing instructions until an exception or
interrupt changes the normal execution flow.

page: 16
REGISTERS:
General-purpose registers hold either data or an address. They are identified
with the letter r prefixed to the register number. For example, register 4 is
given the label r4. The Figure shows the active registers available in user
mode. (A protected mode is normally used when executing applications).
 The processor can operate in seven different modes.
 All the registers shown are 32 bits in size.
 There are up to 18 active registers:
o 16 data registers and 2 processor status registers.
o The data registers visible to the programmer are r0 to r15.
 The ARM processor has three registers assigned to a particular task or special function:
r13, r14,and r15. They are given with different labels to differentiate them from the
other registers.
o Register r13 is traditionally used as the stack pointer (sp) and stores the head of
the stack in the current processor mode.
o Register r14 is called the link register (lr) and is where the core puts the return
addresswhenever it calls a subroutine.
o Register r15 is the program counter (pc) and contains the address of the next
instructionto be fetched by the processor.
 In ARM state the registers r0 to r13 are orthogonal—any instruction that you can apply
to r0 youcan equally well apply to any of the other registers.
 In addition to the 16 data registers, there are two program status registers: cpsr (current
programstatus register) and spsr (saved program status register)
CURRENT PROGRAM STATUS REGISTER:
The ARM core uses the cpsr to monitor and control internal operations. The cpsr is a dedicated 32-bit
register and resides in the register file. The following Figure shows the basic layout of a generic program
status register. Note that the shaded parts are reserved for future expansion.

page: 17

You might also like