See discussions, stats, and author profiles for this publication at: [Link]
net/publication/387504626
Embedded Software Development course notes
Presentation · December 2024
CITATIONS READS
0 82
1 author:
Youcef Benabderrezak
University of Boumerdes
169 PUBLICATIONS 23 CITATIONS
SEE PROFILE
All content following this page was uploaded by Youcef Benabderrezak on 29 December 2024.
The user has requested enhancement of the downloaded file.
Embedded Software Development
Dr Benabderrezak
Researcher in Cyber Security
Full-stack Web developer 1
Work Plan
1. Introduction to embedded systems
2. Embedded systems running Linux and C
3. Software development tools
4. Multitasking and task synchronization mechanisms
5. Smartphone programming
6. Methods of design for embedded systems
2
Introduction to Embedded Systems
3
An embedded system
Is a computer system designed to perform a specific task, a particular function,
often with real-time computing requirements
4
Embedded Systems Key Features
● Hardware + Software
● Real-Time
● Compact and Efficient
5
Embedded Systems Key Features
Hardware + Software :
- Embedded systems are built on microcontrollers or microprocessors with
associated hardware and software
6
Embedded Systems Key Features
Real-Time :
- They often need to meet strict timing constraints (real-time systems)
7
Embedded Systems Key Features
Compact and Efficient :
- Designed to be small, energy-efficient, and optimized for specific applications
8
Embedded Systems History
9
History
- 1960s : First embedded system, Apollo Guidance Computer (used in
spacecraft)
- 1970s : Emergence of microcontrollers, starting with Intel 4004 and 8051.
- 1980s-Present : Rapid evolution, with systems integrated into automotive,
industrial, consumer electronics, and more
10
Embedded Systems Applications
11
Fields of Application
- Automotive : Engine control units, ABS, airbag systems
- Consumer Electronics : Smartphones, washing machines, smart TVs.
- Medical : Pacemakers, MRI machines, diagnostic devices.
- Industrial : Robotics, PLCs (Programmable Logic Controllers).
- Aerospace : Flight navigation, satellite systems.
- Telecommunications : Routers, modems.
- IoT Devices : Smart thermostats, home automation systems
12
Characteristics and Attributes
of Embedded Systems
13
Characteristics and Attributes of Embedded Systems
- Specific Functionality : Performs dedicated tasks
- Real-Time Operation : Executes tasks with precise timing requirements
- Low Power Consumption : Optimized for energy efficiency
- Compact Size : Integrated into a small form factor
14
Characteristics and Attributes of Embedded Systems
- Reliability : Expected to work without failure over long periods
- Embedded Operating Systems : Some run on specialized OS like FreeRTOS,
others on bare-metal systems
- Interfaces and Communication : Interacts with the external environment
using sensors, actuators, and communication modules
15
Different Models of the ARM Family
16
Different Models of the ARM Family
ARM (Advanced RISC Machine) is the leading architecture for embedded systems.
Its models include :
- ARM Cortex-M Series : Designed for microcontrollers and low-power
applications.
- ARM Cortex-A Series : High-performance processors for mobile and
complex applications.
- ARM Cortex-R Series : Real-time processors for critical applications like
automotive and robotics.
17
ARM architecture and core concepts
18
ARM Architecture and Core Concepts - RISC Architecture :
ARM uses Reduced Instruction Set Computing, making it efficient for
low-power and high-performance tasks
19
ARM Architecture and Core Concepts - Pipeline :
- Instructions are divided into stages (e.g., Fetch, Decode, Execute).
- Multiple instructions are processed simultaneously, increasing speed.
20
ARM Architecture and Core Concepts - Interrupts :
Interrupts and Interrupt Vectors :
Mechanisms to handle external events like a button press or sensor signal
- Interrupt Vector Table : Stores the addresses of interrupt handling routines.
- Status Registers : Hold flags and states, such as zero flags, overflow, etc.
21
Sensors and Actuators
22
Sensors : Devices that measure physical quantities (temperature, light, pressure) and convert
them into electrical signals
Examples : Temperature sensors (LM35), motion sensors (PIR)
23
Actuators : Convert electrical signals into physical actions (movement, sound, etc.).
Examples : Motors, buzzers, LEDs.
24
Sensors & Actuators
25
Control and Transfer of Data
26
Control and Transfer of Data
- Control Logic : Governs how data is processed and communicated
- Data Flow : Managed via buses (data, address, and control buses) in
microcontrollers or microprocessors
27
Communication Interfaces
28
Communication Interfaces
- UART (Universal Asynchronous Receiver-Transmitter) : Serial
communication interface
- SPI (Serial Peripheral Interface) : High-speed serial communication.
- I2C (Inter-Integrated Circuit) : Used for short-distance communication.
29
Interfacing with GSM and GPS
GPS وGSM اﻟﺮﺑﻂ ﻣﻊ
30
Interfacing with GSM and GPS
GSM Module : Enables communication over cellular networks for sending/receiving
messages or data.
- Example : SIM800/900 modules.
31
Interfacing with GSM and GPS
GPS Module : Provides location data by communicating with satellites.
- Example : Neo-6M module
32
Data Processing and Display
Data from GSM/GPS can be processed by microcontrollers and displayed on
screens (e.g., LCD, OLED) or sent to a server/cloud for further analysis
33
Embedded Systems running
Using Linux & C
34
System Aspects - Memory Management and Allocation
Static Allocation : Memory allocated at compile time, typically for global or static
variables
Dynamic Allocation : Memory allocated during runtime (e.g., using malloc and
free in C)
35
System Aspects -Memory Management in Linux
- Managed by the kernel using paging and segmentation.
- Tools like kmalloc and vmalloc are used in kernel development.
36
System Aspects - Scheduling
- Determines how CPU resources are allocated to processes or threads
37
System Aspects - Linux Scheduling
Uses Completely Fair Scheduler (CFS) for general processes and Real-Time
Scheduler for critical tasks.
38
System Aspects - Linux Scheduling
Priority Levels : Embedded systems often rely on priority-based scheduling to
meet real-time requirements.
39
Timers
- Used for managing delays, periodic tasks, or timeouts.
Examples in C :
- sleep(), usleep() for user-space delays.
- timer_create() for precise timers.
40
Processes and Threads
- Process : An independent program with its own memory space
- Thread : A lightweight process that shares memory with other threads in the same
process
41
Multi-Threading in C/Linux
Implemented using pthread library for tasks like :
- pthread_create(&thread_id, NULL, function, arg);
- pthread_join(thread_id, NULL);
42
Semaphores
43
Semaphores
- Synchronization tools to control access to shared resources
- Binary Semaphore : Allows or denies access (like a lock)
- Counting Semaphore : Tracks the number of available resources
44
Semaphores - Example in C
sem_t semaphore;
sem_init(&semaphore, 0, 1);
sem_wait(&semaphore); // Lock
// Critical Section
sem_post(&semaphore); // Unlock
45
Embedded Software
46
Embedded Software
Is tailored ( ) ﻣﺼﻤﻤﺔfor specific hardware. It includes :
1. Device Drivers : Interface between hardware and software
2. Application Software : Implements the embedded system’s main
functionality
3. Middleware : Provides additional services (e.g., communication stacks)
47
Examples of Real-Time Applications
- Automotive Systems : Anti-lock braking systems (ABS), engine control units.
- Medical Devices : Pacemakers, ventilators
- Industrial Automation : Robotics, conveyor systems
- Consumer Electronics : Smart appliances, video streaming
48
Embedded Software - Time Constraints
- Hard Real-Time Systems : Missing a deadline leads to system failure (e.g.,
ABS)
- Soft Real-Time Systems : Missing a deadline reduces performance but
doesn’t cause failure (e.g., video streaming).
49
Different Architectures of Real-Time Embedded Systems
- Monolithic Architecture
- Layered Architecture
- Distributed Systems
50
Different Architectures of Real-Time Embedded Systems
Monolithic Architecture : Combines all system components into a single program
51
Different Architectures of Real-Time Embedded Systems
Layered Architecture : Divides the system into layers, such as hardware
abstraction, kernel, and application layers
52
Different Architectures of Real-Time Embedded Systems
Distributed Systems : Components spread across multiple nodes, communicating
via networks
53
Real Time Embedded System Core
54
Real-Time Embedded System Cores
- ARM Cortex-M Series : Designed for low-power, real-time applications
- RISC-V : Open-source architecture for embedded systems
- DSPs (Digital Signal Processors) : Specialized for signal processing tasks
55
Scheduling and Fault Tolerance
- Single-Processor Scheduling
- Multi-Processor Scheduling
- Fault Tolerance
56
Scheduling and Fault Tolerance - Single-Processor Scheduling
Techniques :
- Rate-Monotonic Scheduling (RMS) : Static priority based on task frequency
- Earliest Deadline First (EDF) : Dynamically prioritizes tasks with the nearest
deadline
57
Scheduling and Fault Tolerance - Multi-Processor Scheduling
- Global Scheduling : Tasks can run on any processor
- Partitioned Scheduling : Tasks are assigned to specific processors
58
Hardware and Software Architecture Elements
59
Hardware and Software Architecture Elements
- Kernel
- Bus and Networks
60
Hardware and Software Architecture Elements
Kernel
- The core of an embedded operating system
- Manages processes, memory, I/O, and devices
- Examples : Linux kernel, FreeRTOS
61
Hardware and Software Architecture Elements
Bus and Networks
- Bus : Transfers data between hardware components (e.g., I2C, SPI, CAN).
- Networks : Allow multiple devices to communicate (e.g., Ethernet, Zigbee).
62
Software development tools
63
Software Development Tools for Embedded Systems
Developing software for embedded systems requires specialized tools to ensure that
code is correctly designed, compiled, debugged, and deployed on the hardware.
64
Programming Environment
- C-POSIX
- C language
- Embedded C
65
Programming Environment - C-POSIX
- POSIX (Portable Operating System Interface)
- A set of standards for maintaining compatibility between operating systems.
- In embedded systems, POSIX APIs provide standardized access to system
resources, including file systems, threads, and I/O operations.
66
C Language
- Widely used for embedded systems due to its low-level hardware interaction
and efficiency
- POSIX-compliant libraries enable multi-threading (pthread), inter-process
communication, and real-time scheduling in embedded C programs.
67
Compilation Environment
68
Compilation Environment
Translates source code into machine code for the target hardware
- Cross-Compilers
- Toolchains
69
Compilation Environment
Cross-Compilers : Used to compile code for a different architecture than the
development platform (e.g., ARM GCC for ARM processors).
70
Compilation Environment
Toolchains : Include compilers, linkers, assemblers, and debuggers (e.g., GNU
Toolchain, Keil MDK).
71
Simulators & Emulators
72
Simulators and Emulators - Simulators
- Software tools that mimic the behavior of embedded hardware.
- Allow developers to test code without physical hardware.
Examples :
- QEMU : Simulates various architectures (ARM, RISC-V).
- Proteus : For testing microcontroller-based designs.
73
Simulators and Emulators - Simulators
Advantages :
- Cost-effective.
- Useful in the early development stages when hardware may not be available.
Limitations :
Does not replicate exact hardware behavior, especially for timing-critical
applications.
74
Simulators and Emulators - Emulators
- Hardware tools that replicate the functionality of the target system more
accurately than simulators.
- Provide real-time testing and debugging.
75
Simulators and Emulators - Emulators
Examples :
- ARM DS-5 Debugger with a connected hardware emulator
Advantages : Closer to real hardware behavior.
Limitations : More expensive than simulators.
76
ROM Monitor
77
ROM Monitor
A small program stored in the embedded system’s ROM/Flash that facilitates
system debugging and management
78
ROM Monitor - Functions
- Loading new programs into memory
- Providing diagnostics and error logs
- Enabling developers to test and debug applications
79
ROM Monitor - Examples
U-Boot (Universal Bootloader) : A popular bootloader and ROM monitor for
embedded Linux systems.
80
JTAG Interface
Joint Test Action Group
81
JTAG Interface
JTAG (Joint Test Action Group) is a standard for testing and debugging embedded
hardware
Functions :
- Debugging microcontrollers and processors.
- Boundary-scan testing for verifying hardware connections.
- Programming flash memory.
82
JTAG Interface Tools
- JTAG-compatible debuggers like SEGGER J-Link, ARM DAPLink.
83
JTAG Interface - Advantages
- Direct access to the CPU for step-by-step debugging
- Ideal for troubleshooting low-level hardware issues.
84
Programming and Direct Testing of
ROM/Flash
85
Programming and Direct Testing of ROM/Flash
Programming ROM/Flash :
- ROM/Flash holds the embedded software (firmware) and is non-volatile.
- Tools like Flash programmers or In-System Programmers (ISP) are used to
write code directly to ROM/Flash.
- Examples : ST-Link for STM32, AVRISP for AVR microcontrollers.
86
Programming and Direct Testing of ROM/Flash
Direct Testing :
- Involves writing test code into ROM/Flash and running it on the target
hardware.
- Debuggers can inspect the code's behavior during execution.
- Often combined with JTAG or ROM monitors for enhanced debugging.
87
Workflow Summary of developing embedded
software
88
Workflow Summary
1. Develop Code
2. Simulate or Emulate
3. Compile & link
4. Deploy
5. Debug and Test
6. Refine and Repeat
89
Workflow Summary
Develop Code : Use an IDE like Keil, Eclipse, or Visual Studio Code. & Write in
C/C++ with POSIX libraries (if applicable)
Simulate or Emulate : Test in a simulator/emulator before deploying to hardware
Compile and Link : Use a cross-compiler toolchain to produce binary files.
90
Workflow Summary
Deploy : Load code into ROM/Flash using a programmer or JTAG
Debug and Test : Use JTAG, ROM monitors, or onboard debugging tools
Refine and Repeat : Debug, refine code, and repeat the process until the desired
functionality is achieved.
91
Multitasking and task synchronization
mechanisms
92
Multitasking and Mechanisms of Task Synchronization
Multitasking is a fundamental aspect of embedded systems where multiple tasks
are executed concurrently.
This chapter explores the mechanisms, tools, and concepts essential for
implementing multitasking in real-time embedded systems.
93
Use of a Real-Time Executive
- A lightweight operating system or kernel designed for real-time embedded
applications.
- Manages tasks, time, and resources to ensure deadlines are met.
94
Use of a Real-Time Executive - Purpose :
- Facilitate task scheduling and execution.
- Provide synchronization mechanisms for multitasking.
- Manage system resources efficiently.
Examples :
- FreeRTOS : A popular open-source real-time executive.
- RTEMS : Real-Time Executive for Multiprocessor Systems.
95
Functional Breakdown of Embedded Systems
Dividing the system into smaller, manageable components or modules based on
functionality
96
Functional Breakdown of Embedded Systems - Common Functional Blocks
● Sensor Interface
● Processing Unit
● Actuator Control
● Communication Interface
● User Interface
97
Functional Breakdown of Embedded Systems - Common Functional Blocks
● Sensor Interface : Captures input from sensors.
● Processing Unit : Performs computations and decision-making.
● Actuator Control : Sends signals to actuators for physical actions.
● Communication Interface : Facilitates data exchange with external systems.
● User Interface : Provides interaction with the user.
98
Software Architecture of a Control System
Key Components
99
Software Architecture of a Control System - Key Components :
- Input Modules : Handle sensor data.
- Processing Modules : Contain algorithms and logic for control
- Output Modules : Control actuators or other output devices
- Middleware : Manages communication and data exchange
- Kernel/Executive : Handles multitasking and synchronization
100
Software Architecture of a Control System - Key Components :
Architecture Styles :
- Monolithic : Single large program handling all tasks.
- Layered : Separate layers for hardware abstraction, kernel, and application
logic.
- Component-Based : Independent modules that communicate via well-defined
interfaces.
101
Synchronous and Asynchronous
Implementation
102
Synchronous Implementation
Tasks execute in a predictable order based on a fixed schedule
Role of Executive :
- Enforces timing and sequencing of tasks
- Often used in systems with strict timing requirements (e.g., automotive
controllers)
103
Asynchronous Implementation
Tasks are triggered by events or interrupts.
Role of Executive :
- Manages event queues and interrupts.
- Suitable for systems where tasks are unpredictable (e.g., user interaction
systems)
104
General Structure
of Executive
105
General Structure of an Executive
● Task Scheduler
● Inter-Task Communication
● Resource Manager
● Time Management
● Interrupt Handling
106
General Structure of an Executive
Task Scheduler : Allocates CPU time to tasks based on priorities or deadlines.
Inter-Task Communication : Provides mechanisms like message queues,
semaphores, and shared memory.
107
General Structure of an Executive
Resource Manager :Manages access to hardware and software resources
Time Management : Includes timers, delays, and periodic task execution
Interrupt Handling : Responds to hardware or software interrupts
108
Time, Event, and Time Management
Primitives
109
Time Primitives
- Delays : Suspend a task for a specific duration (e.g., vTaskDelay() in
FreeRTOS)
- Timers : Trigger actions at specific intervals.
110
Event Primitives
- Interrupts : Immediate response to hardware or software events
- Event Flags : Synchronize tasks based on events.
111
Time Management
Tick Count : Measures time intervals based on system ticks
- The system tick is the time unit that OS timers and delays are based on.
- The system tick is a scheduling event
- i.e. it causes the scheduler to run and may cause a context switch - for example if a timer
has expired or a task delay completed.
Periodic Tasks : Executes tasks at regular intervals.
112
Smartphone / Mobile programming
113
Smartphone Programming
Programming for smartphones, especially on the Android platform, involves
understanding the specific environment, frameworks, and tools provided by
Android
114
Android Overview
- Open-source mobile operating system based on Linux.
- Supports Java/Kotlin as primary programming languages, with optional
support for C++.
115
Android Unique Features
Component-Based Architecture : Applications are built using Activities, Services,
Broadcast Receivers, and Content Providers
Resource Management : Provides XML-based resource files for layouts, strings,
styles, etc.
116
Android Unique Features
Lifecycle Awareness : Activities and other components have specific lifecycle
methods to manage transitions (e.g., onCreate(), onPause())
Fragmentation : Supports a wide range of devices with different screen sizes,
resolutions, and versions of Android.
117
Components of a Graphical Interface
- Android UI Components
- XML Layout Files
118
Components of a Graphical Interface - Android UI Components :
Activity : Represents a single screen with a user interface.
119
Components of a Graphical Interface - Android UI Components :
Fragment : A reusable component within an activity.
120
Components of a Graphical Interface - Android UI Components :
View : Basic building block for user interface elements.
Examples : TextView, Button, EditText, ImageView, RecyclerView.
121
Components of a Graphical Interface - Android UI Components
Layout : Defines the structure of the user interface.
- Examples : LinearLayout, ConstraintLayout, RelativeLayout.
122
XML Layout Files : Define the visual structure of an app using XML.
123
Event Handling
Handles user interactions such as button clicks.
124
Persistence of Data - Shared Preferences :
- Store simple key-value pairs
125
SQLite Database
- For structured data storage
126
Room Database (Modern Approach):
- Provides abstraction over SQLite.
Example :
@Entity
public class User {
@PrimaryKey(autoGenerate = true)
public int id;
public String name;
}
127
File Storage
- Store files in internal or external storage.
Example :
FileOutputStream fos = openFileOutput("[Link]", Context.MODE_PRIVATE);
[Link]("Hello, world!".getBytes());
[Link]();
128
Concurrent Programming
On Android
129
Concurrent Programming on Android - Concurrency Needs :
Android applications often perform long-running tasks (e.g., network requests, file
I/O) in the background to keep the UI responsive
130
Threads :
131
Network Communications
132
Setting Up a Network Communication - Networking Libraries :
- HttpURLConnection : Low-level library for HTTP requests
- Retrofit : High-level library for REST APIs
- Volley : Library for easier networking operations
133
Handling Permissions
- Android 6.0+ requires runtime permissions for networking.
134
135
Methods of design for embedded
systems
136
Designing embedded systems
Involves precise planning and modeling to meet the system’s functional and
non-functional requirements
This chapter discusses key methods like co-design templates, system modeling
with SysML, and advanced techniques like MARTE and specialized modeling
languages.
137
Co-Design Templates
Co-design involves the simultaneous design of hardware and software components
of embedded systems to achieve an optimized balance between performance, cost,
and power consumption.
138
Co-Design Templates - Key Concepts :
Hardware/Software Partitioning :
- Decide which functions are implemented in hardware and which in software
Iterative Design :
- Continual refinement based on simulations and testing
Templates :
- Predefined frameworks or guidelines that streamline the co-design process
139
Co-Design Templates - Examples :
- Use of FPGA alongside software microcontrollers.
- Partitioning algorithms to distribute computational tasks effectively.
140
System Modeling (SysML)
SysML (Systems Modeling Language) is a graphical modeling language designed
for systems engineering.
141
SysML - Needs Analysis and System Specification
Objective :
- Identify the functional and non-functional requirements of the system.
- Define what the system is supposed to do (inputs, outputs, constraints).
SysML Diagrams for Needs Analysis :
- Requirement Diagrams : Visualize requirements and their relationships.
- Use Case Diagrams : Capture high-level system functionality.
142
Modeling the System Architecture
Objective :
- Define the structural components of the system and their interactions.
SysML Diagrams for Architecture :
- Block Definition Diagram (BDD) : Represents the system's structural elements.
- Internal Block Diagram (IBD) : Details the internal structure of a block, including
connections and ports.
143
Modeling Behavior
Objective :
- Capture dynamic aspects of the system, such as processes and workflows.
SysML Diagrams for Behavior :
- Activity Diagrams : Represent workflows and processes
- State Machine Diagrams : Show state transitions and events
- Sequence Diagrams : Model interactions between components over time
144
Modeling Transverse Aspects
Objective : Handle system constraints, parametric equations, and traceability.
Key Techniques :
- Parametric Diagrams : Specify equations and constraints. ( Example : Thermal,
electrical, or performance constraints)
- Traceability Management : Link requirements to architecture and design elements.
- Behavior-Architecture Allocation : Map behaviors (e.g., algorithms) to physical
architecture (e.g., processors, sensors).
145
MARTE
Modeling and Analysis of Real Time and
Embedded systems
146
What is MARTE ?
- Modeling and Analysis of Real-Time Embedded Systems is an extension of
UML for real-time systems
- Provides tools for modeling time-critical properties.
147
MARTE Key Features
- Time Modeling : Define timing constraints like deadlines and execution time
- Performance Analysis : Evaluate throughput, latency, and resource usage
- Hardware/Software Allocation : Map software tasks to hardware
components.
148
MARTE Example
Model a temperature monitoring system with real-time deadlines using MARTE to
ensure the system reacts within a predefined time frame
149
System Simulation
150
Simulation of Systems by Running Models
Objective :
- Validate system behavior before hardware implementation
- Identify bottlenecks and verify timing constraints
151
Tools for Simulation
- Simulink, MATLAB, or SysML-compatible simulators.
- MARTE-based simulation frameworks.
152
Tools for Simulation
Example :
Simulating a robotic arm's movement to ensure precise motor control within
real-time constraints.
153
Advanced IDM Techniques
IDM (Integrated Development Methods) focuses on automating and enhancing
system design through specialized modeling and code generation.
154
Definition of a Specialized Modeling Language (DSML)
- A tailored modeling language designed for specific application domains
Example : A DSML for automotive systems might include elements like "ECU"
(Electronic Control Unit) or "CAN bus."
155
Definition of a Specialized Modeling Language (DSML)
Advantages :
- Simplifies communication within the domain.
- Reduces design errors by focusing on domain-specific abstractions.
156
Code Generator
157
Definition of a Code Generator - Objective :
- Automatically generate implementation code (e.g., C or VHDL) from models
- Speeds up development and ensures consistency between models and code
158
Code Generator Process
- Define transformation rules to map models to code
- Use tools like Eclipse Modeling Framework (EMF) or Xtext.
Example :
- Generate control logic code for a washing machine directly from its state
diagram.
159
160
View publication stats