Interesting Lecture - Embedded Systems
-
Upload
vivek-kumar -
Category
Documents
-
view
27 -
download
3
Transcript of Interesting Lecture - Embedded Systems
![Page 1: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/1.jpg)
Today
Advanced embedded systems The point of the course Hardware stuff Software stuff
![Page 2: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/2.jpg)
![Page 3: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/3.jpg)
Ariane 5 Details
What happened? Need to look into the flight software…
“Horizontal bias” converted from 64-bit float to a 16-bit integer Software reused from Ariane 4 – a slower vehicle
The 16-bit int overflowed, throwing an exception Uncaught exception shut down the guidance
computer …and the backup computer
Rocket became unguided Started to disintegrate due to aerodynamic forces Then destructed
![Page 4: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/4.jpg)
Mars Pathfinder Lands on Mars July 4 1997 Mission is successful
Behind the scenes… Sporadic total system resets on the rover Debugged on the ground, fixed by software patch
![Page 5: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/5.jpg)
Pathfinder Details
Software run on vxWorks – a multitasking RTOS Vehicle control running at high priority Lots of stuff running at medium priority Meteorological science running at low priority
Problem:1. Low priority software grabs a thread lock
2. High priority software blocks on the lock
3. Medium priority software runs for a long time
4. Total reboot triggered by watchdog timer
This is priority inversion Solutions exist, but you have to know when and
how to use them
![Page 6: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/6.jpg)
CS 7962 Lab 3
ARM7 boards 16364 total bytes of RAM 1024 bytes available for main stack 128 bytes available for interrupt stack
Students used iprintf() call for debugging Prints a string to serial port Uses up to about 2 KB of stack memory
Most groups called iprintf() from both the main context and interrupt context
Result Unpredictable operation due to memory
corruption Software crashes
![Page 7: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/7.jpg)
Stack Problems
The students Knew about stack overflow problems Knew the stack requirements of iprintf() And still made the mistake
![Page 8: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/8.jpg)
The Point #1
Easy: Hack up some embedded software that seems to work
Hard: Make a rocket take off, fly to Mars, land a rover,
drive it around, report back to Earth 1 bug == total mission failure
Write control software that’s going to run on 25 M hybrid vehicles 1 bug == product recall (at best)
Make a pacemaker that operates correctly for 10 years in every person using one 1 bug == lost lives, product recall, irreparable
damage to company reputation
![Page 9: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/9.jpg)
The Point #2 Embedded system isn’t just a collection of
isolated parts Many design decisions have implications
for the whole system – are we using: Threads? Interrupts? Heap allocation? Address spaces?
Many important system properties are global Stack and heap memory usage Effects of failures and bugs Energy usage Real-time deadlines
![Page 10: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/10.jpg)
The Point #3
Making a good embedded system isn’t just hacking
All of these are just as important: Understanding the requirements Understanding the application domain Platform choice Toolchain choice Software architecture Timing analysis Memory usage analysis Fault vulnerability analysis Testing Certification
![Page 11: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/11.jpg)
The Point #4
Reading the reference manual is easy PWM, ADC, DAC, SCI, SPI, UART, I2C, CAN, LIN,
802.15.4, …
Seeing the big picture is hard Main goal of my class: Help you see the
bigger picture
![Page 12: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/12.jpg)
Lab Hardware
Philips LPC 2129 Serial port for programming JTAG port for debugging
![Page 13: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/13.jpg)
Philips LPC2xxx
Basic idea: Philips licenses the ARM7TDMI-S core from ARM, adds lots of cool external stuff, manufactures the chips
LPC21xx 64 pins LQFP64 package – 1cm x 1cm No external bus
LPC22xx 144 pins LQFP144 package – 2cm x 2cm External bus
![Page 14: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/14.jpg)
LPC2129
Cost: $6.75 in large quantities Designed for automotive and control
applications Memory
16 KB on-chip SRAM 256 KB on-chip flash This has to suffice since there’s no external bus!
2 CAN channels CAN == Controller Area Network LAN for control applications Primarily used in automobiles Why 2 channels?
![Page 15: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/15.jpg)
More LPC2129
4 10-bit ADC channels A/D: Convert voltage in 0-3v range into a 10-bit
integer A/D is slow – typically interrupt on completion
4 external interrupt lines Lots of general-purpose I/O lines
Shared with other functionality
I2C and SPI Standard embedded serial busses Generally used in master-slave mode Of course, serial protocols can also be
implemented through bit-banging
![Page 16: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/16.jpg)
More LPC2129
2 UARTs Point-to-point serial communication Lots of convenient features to reduce CPU usage
FIFOs Buffer overrun detection Interrupts
2 timers 32-bit timers with 32-bit prescalers Lots of features!
Real-time clock Keeps calendar time
![Page 17: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/17.jpg)
More LPC2129 PWM
Pulse width modulation Sort of a cheapo D/A converter
Rapidly switch between low and high voltage, rely on external circuitry to average out
Watchdog timer Reboot wedged processor
PLL – phase locked loop Converts external 10-25 MHz clock into 10-60
MHz internal clock
MAM – memory accelerator module Prefetches instructions Exploits multiple banks of flash memory Solves the problem of core outrunning the flash
![Page 18: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/18.jpg)
More LPC2129
JTAG support Provide visibility and controllability into the
processor – used for debugging and testing
Power management Idle mode
Processor core shuts down until interrupt or reset arrives
Peripherals keep running Power down mode
RAM and registers saved Peripherals shut down Extremely low power consumption
![Page 19: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/19.jpg)
ARM Stuff
32-bit RISC Designed to be a compiler target
Lots of registers Conditional execution Most instructions can use barrel shifter
Multiple processor modes We use ARM7TDMI
Bottom end of the ARM family No caches or memory protection hardware Runs below 100 MHz
High end ARMs are pretty fast ~1 GHz
![Page 20: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/20.jpg)
![Page 21: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/21.jpg)
Example: GCD
int gcd (int i, int j)
{
while (i != j) {
if (i>j) {
i -= j;
} else {
j -= i;
}
}
return i;
}
![Page 22: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/22.jpg)
GCD in ARM Assembly
000000d4 <gcd>:
d4: e1510000 cmp r1, r0
d8: 012fff1e bxeq lr
dc: e1510000 cmp r1, r0
e0: b0610000 rsblt r0, r1, r0
e4: a0601001 rsbge r1, r0, r1
e8: e1510000 cmp r1, r0
ec: 1afffffa bne dc <gcd+0x8>
f0: e12fff1e bx lr
![Page 23: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/23.jpg)
Labs
1. Get started with the board
2. Data acquisition – angle measurement
3. Analysis and measurement of stack depth and interrupt latency
4. Audio input using ADC
5. Audio output using PWM
6. Audio DSP
7. CAN bus networking
8. Feedback control
9. Distributed control
![Page 24: Interesting Lecture - Embedded Systems](https://reader036.fdocuments.net/reader036/viewer/2022081414/550040884a7959c9478b46b7/html5/thumbnails/24.jpg)
That’s All
Class is supposed to be fun Offered Fall 2006 Talk to current students I hope you’ll take it