Transcript CS 7962 lecture - University of Utah
Today
Advanced embedded systems
The point of the course Hardware stuff Software stuff
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
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
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.
2.
3.
4.
Low priority software grabs a thread lock High priority software blocks on the lock Medium priority software runs for a long time Total reboot triggered by watchdog timer This is priority inversion
Solutions exist, but you have to know when and how to use them
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
Stack Problems
The students
Knew about stack overflow problems Knew the stack requirements of iprintf() And still made the mistake
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
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
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
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
Lab Hardware
Philips LPC 2129 Serial port for programming JTAG port for debugging
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
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?
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
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
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
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
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
Example: GCD
int gcd (int i, int j) { while (i != j) { if (i>j) { i -= j; } else { j -= i; } } return i; }
GCD in ARM Assembly
000000d4
Labs
4.
5.
6.
7.
8.
9.
1.
2.
3.
Get started with the board Data acquisition – angle measurement Analysis and measurement of stack depth and interrupt latency Audio input using ADC Audio output using PWM Audio DSP CAN bus networking Feedback control Distributed control
That’s All
Class is supposed to be fun Offered Fall 2006 Talk to current students I hope you’ll take it