Section I
Quality Attributes
-
Operational Quality Attributes
-
Non-Operational Quality Attributes
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.
Components for Embedded Programs
State Machine
Circular Buffers
Queue
Models of Program
Data Flow Graph (Basic Block)
- 没有条件/循环语句的一个代码块
Control / Data Flow Graph
- 把Basic Block作为基本元素
Compilation Techniques
Frame
- 定义
- 当一个函数被调用时,一个新的frame会被创建并压入堆栈中,在函数执行结束后,这个frame会从堆栈中弹出并销毁。这个过程也被称为“函数调用栈”或“运行时堆栈”。
- 原理
-
Stack Pointer 指向当前帧的结尾
-
Frame Pointer 指向上一个帧的结尾
Compilation of an Arithmetic Expression & Register Allocation Optimisation
- Example
- Optimization
-
变量数超过寄存器数时,需要重复利用某些寄存器以优化代码
-
在此例中,最多只要3个寄存器
-
伪代码
|
|
Testing Techniques
黑盒测试分类
Function Testing | 测试功能可不可用 |
---|---|
Non-functional Testing | 测试怎么实现功能 |
Regression Testing | 测试更新后的软件性能是否下降了 |
白盒/黑盒比较
比较项目 | White-Box Testing | Black-Box Testing(functional testing) |
---|---|---|
测试前的数据 | 测试前对硬件和软件都了如指掌 | 测试前只知道输入和输出 |
(时间和经济)成本 | 高 | 低 |
复杂度 | 高 | 低 |
对测试者的知识储备要求 | 高 | 低 |
效果 | 高 | 相对较差 |
Debugging
Debug & Test
-
Debug: Given a symptom of software failure, locate and correct the defect.
-
Test: Executing a program to see if it performs as expected.
选择Debug工具
- ESC (Easy Use, Special Capability, Cost)
Debug 工具
- Burn and Learn
stateDiagram
写(修改)代码 --> 编译
编译 --> 测试
测试 --> 写(修改)代码
- Software Simulation
- I/O: Waveforms, Register Log, Digital Signal, Manual Input
-
Oscilloscope
-
Logic Analyzer
Pros | Cons |
---|---|
高效 | external memory bus |
贵 | |
只能监测I/O,而不是内存活动 |
- Hardware Emulation
In-Circuit Emulation (ICE) | More Powerful, more expensive |
---|---|
In-Circuit Debug (ICD) |
Section II
Embedded Firmware – Design and Development
Super Loop
- 定义
-
经典循环, 时序进行
-
任务简单,对时间没有要求
- 例子
- 优缺点
Pros | Cons |
---|---|
简单 | 错一点就会死机 |
没OS | 非实时 |
省内存 |
- 改进
- 加个中断,从而可以执行实时任务
Embedded OS based Approach
- RTOS (Real-Time OS)
-
GPOS (Customized General-Purpose OS)
-
比较
Scheduling
基本概念
- TAT (Turn Around Time)
- 从进入序列(开始排队)到运行结束
- Waiting Time
Non-preemptive
FIFO/FCFS(First-Come-First-Served))
LIFO/LCFS
SJF(Shortest Job First)
Priority-Based Scheduling
优缺点综述
SJF + PBS | |
---|---|
会出现Starvation |
Preemptive
Preemptive SJF Scheduling / Shortest Time(SRT)
- 每当有新的任务进入队列,系统会重新计算SRT,并重新调整当前执行任务
Round Robin (RR)
- Ready Queue
- Ready Queue中的程序都执行*Pre-defined Time**
Preemptive Priority-Based Scheduling
Rate Monotonic (RM) Scheduling Algorithm
-
根据时间给任务安排优先级
-
但是任务时间是很难预测的
附录
Firmware
- 装载ROM上的软件, 提供最底层的操作