POST AND TELECOMMUICATIONS INSTITUTE OF TECHNOLOGY
CHAPTER 3
Software components of
embedded systems and 8051
microprocessors
Faculty: Computer science - IT1
MAIN CONTENT
3.1. Device drivers
3.2. Real-time operating system
3.3. Middleware and application software
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 2
OVERVIEW OF EMBEDDED SYSTEM SOFTWARE
v Software Overview of Embedded Systems
v Operating System: System software
v Application: Application software
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 3
Chapter 3: Software components
Introduction to embedded software
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 4
Introduction to embedded software
v Two approaches to building
embedded software: Software
design is based on
conventional procedures.
§ Design based on Embedded
Operating System.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 5
Introduction to embedded software
v Software design is based on conventional procedures.
§ Use hyperloops for applications that do not depend on system
response time.
§ Each procedure is executed sequentially :
• 1. Configure shared parameters and perform initialization of hardware
components such as memory and registers.
• 2. Start with the first task and execute it.
• 3. Execute the second task.
• 4. Execute the next task.
• 5. ….
• 6. ….
• 7. Execute the last task.
• 8. Jump to the first task and execute in a thread
• similar.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 6
Introduction to embedded software
v Software design is based on conventional
procedures.
§ Advantage :
• No operating system required
• Simple design
• Low price
§ Disadvantage:
• Easily affected by the entire system, if any
an error task
• Lack of processing time
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 7
Introduction to embedded software
v Software design is based on conventional
procedures.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 8
Introduction to embedded software
v Software design based on Embedded Operating
System:
v An operating system contains the operating system.
v Create and run applications on the operating system.
v Can be a generic operating system or a real-time
operating system (RTOS)
§ General operating system:
• unifies the embedded system with the general computing system of the
operating system
• support programming interfaces can be used
§ Real-time operating system :
• embedded products require response time
• contains a software responsible for preventing multitasking, planning
execution schedules, multi-threading, a real-time operating system that
allows flexible scheduling of system resources such as CPU and memory
and output several ways to communicate between tasks
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 9
Introduction to embedded software
v Software design based on Embedded Operating
System.
§ Advantage :
• No operating system required
• Simple design
• Low price
§ Disadvantage:
• Easily affected by the entire system, if any
an error task
• Lack of processing time
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 10
3.1 Device drivers
What is Driver?
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 11
I. DEVICE DRIVER DEFINITIONS (Device driver)
• Device driver: connection between OS and I/O devices.
• Function: translate and convert requests from the OS into
commands that the peripheral controller can understand.
• Is part of the OS kernel (drivers are software modules that
are built separately and installed into the OS when
needed).
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 12
DEVICE DRIVER DEFINITIONS (Device driver)
• Examples: printer driver, Bluetooth driver...
• A complete system has many drivers installed on
the operating system.
• Device drivers operate in privileged mode: need to
be well designed and secured to avoid malicious
code.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 13
DEVICE DRIVER DEFINITIONS (Device driver)
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 14
Advantages of Device drivers
1. Simplify OS operations
2. Without a device driver, the OS is responsible for
communicating directly with the hardware
overloading the OS.
3. If a new device is installed, the OS must be changed.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 15
Key design issues
1. OS / Driver Communication
§ Information exchange(command, data)
§ Support functions that the kernel provides
2. Driver / Hardware Communication
§ Information exchange(command, data)
§ Software communicates with Hardware
§ Hardware communicates with Software
3. Driver Internal Operations
§ Translate command received from OS
§ Arrange the order of requirements
§ Manage data transmission between interfaces(OS và hardware)
§ Accept and process interrupts
§ Maintain consistency of data structures between driver and kernel.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 16
Types of Device Drivers
v Block Driver
v Character Driver
v Terminal Driver
v Stream Driver
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 17
Block Drivers
§ Communicates with the OS through a set of fixed-sized
buffers (block of data).
§ The OS manages the cache of caches and responds to
user requests for data by accessing the cache.
§ The driver is only called when the requested data is not in
the cache or when the cache changes.
§ The driver works with requests from the OS to fill or clear
buffers of a fixed size.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 18
Block Drivers
v Ví dụ: disks are applied as block devices.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 19
Character Drivers
v Requests with packet sizes of any length of I/O.
v Used for devices that communicate bytes at a time or
with data blocks larger or smaller than the block drivers'
data buffer.
VD: printer
v I/O requests are passed directly to the driver, and the
driver transfers data to VXL memory.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 20
Character Drivers
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 21
Block driver vs Character Drivers
Block Driver Character Driver
Transfer data to the kernel buffer Pass data directly to the user process
cache
Not suitable for devices Suitable for devices that communicate
communicating with variable size in packets of variable size
packets
Can be used to support UNIX-based UNIX-based devices are not
devices supported
Suitable for supporting drives and hard Suitable to support serial port, parallel
drives port, network card, keyboard...
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 22
Characteristics of a device driver
v Driver is a set of entry points called by the OS.
v One driver includes:
§ Separate data structure for each device.
§ Separate protocol for each driver
v Most drivers are written in one source file.
v The first part of the driver is called the prologue
declaration.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 23
Characteristics of a device driver
v Prologue includes: :
§ #include
§ #define
§ Declare variables and their characteristics
v The rest of the driver :
§ Entry points (C functions are referenced by the OS)
§ Routines (C functions interact with the driver)
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 24
3.2 . Real Time Operating System (RTOS)
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 25
II. Real Time Operating System (RTOS)
• Definition: is a multi-tasking operating system for
applications with real-time constraints.
• Real-time constraints: require a certain delay for
an event and system response.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 26
Benefits of Real Time Operating System (RTOS)
• Divide the project into smaller parts to "treat".
• Easily divide work in group work.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 27
Basic functions
• Kernel
• Process management
• Resource management
• Equipment management
• Manage I/O peripheral device systems
• Manage network devices
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 28
Process management
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 29
Hierarchy of priority processes
• Hierarchy of user priorities, called static priority
hierarchy, or real-time priority hierarchy.
• Real-time priority hierarchy is higher than static
priority hierarchy and idle priority hierarchy.
• Idle priority tasks run when there are no high
priority tasks running.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 30
Managing progress through intervention
• The RTOS interrupts a low-priority process when
a message or event is waiting for the high-
priority process.
• The RTOS has intervention points at the end of
critical code, and thus the RTOS can be
intervened at these points by real-time high
priority tasks.
• A small portion of RTOS functions are non-
interferable.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 31
Process management by inheriting priority levels
(priority inheritance)
• Priority inheritance allows sharing resources
with low priority tasks.
• A medium priority task will not be able to
interfere with a low priority task while it is locked
to run with the high priority task.
• Helps improve system performance.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 32
Design of RTOS
• An embedded system with a single CPU can run
only one process at a time.
• A process at any given time can be run by an
ISR, a kernel function, or a task.
• Run threads in the kernel to increase processing
speed.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 33
RTOS design
• Provides efficient handling of ISRs, drivers,
ISTs, streams...
• Turn interrupts on and off
• Allocate and deallocate memory at fixed times
and memory blocks.
• Provides efficient scheduling, running, and
stopping of tasks in case of multiple tasks.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 34
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 35
RTOS design
• Managing I/O (devices, files, mailboxes...)
becomes easy with RTOS
• Effectively manage multiple states of CPUs,
devices such as internal and external hard
drives, virtual devices...
• An embedded system running an OS makes
working with multiple inputs simpler (through
drivers) and processing data easier.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 36
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 37
RTOS design
• Managing I/O (devices, files, mailboxes...)
becomes easy with RTOS
• Effectively manage multiple states of CPUs,
devices such as internal and external hard
drives, and virtual devices.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 38
Options for RTOS
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 39
Complex multitasking embedded system design
requirements
• IDE
• C/C++ multitasking functions
• Real-time clock – timers
• Schedule(scheduler)
• Device drivers, device manager
• Communication functions between processes,
multi-threaded processing functions...
• Other functions : TCP/IP, USB port, network
• Testing and debugging software for RTOS
testing
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 40
Basic functions in RTOS
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 41
Classification of RTOSes
• In-house Developed RTOSes
1. Codes are written for specific application or
product requirements.
2. Requirements can be refined.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 42
Classification of RTOSes
• Commercial RTOSes
1. Provide testing and debugging tools.
2. Supports many VXL architectures (ARM, x86...)
3. Support GUIs
4. Supports communication with many devices and many
different connection protocols.
5. Optimized software and device support.
6. Simplify the developer's coding process.
7. Speed up product development.
8. Save time and maintenance costs.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 43
Classification of RTOSes
• Commercial RTOSes
1. Provide testing and debugging tools.
2. Supports many VXL architectures (ARM, x86...)
3. Support GUIs
4. Supports communication with many devices and many
different connection protocols.
5. Optimized software and device support.
6. Simplify the developer's coding process.
7. Speed up product development.
8. Save time and maintenance costs.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 44
Classification of RTOSes
• General purposes OS with RTOS
1. Linux, Windows OS.
2. Has a strong GUI configuration, many multimedia
interfaces, and low price.
3. Supports GUIs
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 45
III. Middleware, Application
1. Middleware: located in many places, separate from the
app, OS, and drivers.
2. Application: The software sits at the top layer,
communicating with the user.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 46
Middleware
1. Middleware: considered middleware, ensuring
flexibility, security and helping to link software at
adjacent layers.
2. Contains service functions, which are called repeatedly
by other software.
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 47
Middleware (ví dụ)
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 48
What does embedded software development require?
1. Compilation software
2. Development board
3. Loader/Debugger
4. Libraries (for ARM core, peripheral drivers...)
5. Documents (datasheet)
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 49
Steps to compile software in IDE
(translation software)
1. Create project
2. Configure the compiler software (choose chip type,
select loader circuit type)
3. Write programs and compile
4. Load into the flash memory of the development board
5. Run the program and check for errors
[Link] BỘ MÔN: KHOA HỌC MÁY TÍNH – KHOA CNTT1 Trang 50