eecs 388: embedded systems - ku ittcheechul/courses/eecs388/w1.intro.pdf · ku fixed-wing uav 4 (*)...

Post on 20-May-2020

26 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

EECS 388: Embedded Systems

1. Introduction

Heechul Yun

1

Heechul Yun

• Associate Prof., Dept. of EECS

• Offices: 3040 Eaton, 236 Nichols

• Email: heechul.yun@ku.edu

• KU EECS faculty since 2013

• Education: UIUC (PhD), KAIST (MS, BS)

• Embedded software engineer at Samsung

• Research Areas– Embedded/real-time systems, OS, architecture

• More Information– http://ittc.ku.edu/~heechul

2

KU Fixed-wing UAV

3(*) Prasanth Vivekanandan, Gonzalo Garcia, Heechul Yun, Shawn Keshmiri. A Simplex Architecture for Intelligent and Safe Unmanned Aerial Vehicles. In RTCSA, IEEE, 2016.

KU Fixed-wing UAV

4(*) Prasanth Vivekanandan, Gonzalo Garcia, Heechul Yun, Shawn Keshmiri. A Simplex Architecture for Intelligent and Safe Unmanned Aerial Vehicles. In RTCSA, IEEE, 2016.

DeepPicar

• End-to-end deep learning: pixels to steering

• Using identical DNN with NVIDIA’s DAVE-2

5

More self-driving videos: https://photos.app.goo.gl/q40QFieD5iI9yXU42

Michael G. Bechtel, Elise McEllhiney, Minje Kim, Heechul Yun. “DeepPicar: A Low-cost Deep Neural Network-based Autonomous Car.”In RTCSA, 2018.

EECS 753

6

DeepPicar CompetitionEECS 753 Embedded Real-Time Systems Final Project

May 6, 2019

About This Class

• Textbook– Introduction to Embedded Systems:

A cyber-physical systems approach

– http://LeeSeshia.org/

• Objectives– Learn key concepts and practical skills

to develop cyber-physical/embedded systems

• Course website– http://ittc.ku.edu/~heechul/courses/eecs388

7

Course Structure

• Lecture– Embedded systems design and implementation– Focus on key concepts

• Quiz– Weekly online quizzes to check your understanding

• Lab– Hands-on embedded systems programming

experiences.

• Project– Self-driving car prototype

8

Lab

• HiFive1 (rev b) board– RISC-V micro-controller– Limited resources/performance– “Bare-metal” programming in C

• Directly access hardware w/o OS

• Raspberry Pi 4– Powerful quad-core ARM CPU– Run fully featured OS (Linux)– Standard PC-like programming

environment

9

HiFive 1 rev B

Raspberry Pi 4

Project

10

Raspberry Pi 4 (Linux)

HiFive1 rev B Microcontroller

Lidar

Camera

Intelligent controller(Vision based steering using DNN)

Safety controller(Basic control + emergency breaking)

Self-Driving Car

Grading

• Attendance: 5%

• Exam: 50% (Mid:20%, Final:30%)

• Quiz: 5%

• Lab: 30%

• Project: 10%

11

Grading

• 90+ : A

• 80-89: B

• 70-79: C

• 50-69: D

• 0-49: F

12

Policy

• Late submissions– 20% off each additional 24 hours delay (~24h = 80%, ~48h

= 60%, ~72h=40%, ~96h=20%, >96h = 0%)

• Cheating– You can discuss about code and help find bugs of your

peers. However, copying another’s code (e.g., from github) or writing code for someone else is cheating and, if identified, the involved students will be notified to the department chair

• Public code repository– Do not post your lab solutions on publicly accessible web

sites (e.g., GitHub). – Do not download other students’ solutions.

13

Schedule

• http://www.ittc.ku.edu/~heechul/courses/eecs388/schedule.html

14

15

Embedded Systems

• Computing systems designed for specific purpose.

• Embedded systems are everywhere

16

Internet of Things (IoT)

• IoT ~= Internet connected embedded systems

17

Cyber-Physical Systems (CPS)

• Cyber system (Computer) + Physical system (Plant)

• Still embedded systems, but integration of physical systemsis emphasized.

18

Real-Time Systems

• The correctness of the system depends on not only on the logical result of the computation but also on the time at which the results are produced

• A correct value at a wrong time is a fault.

• CPS are often real-time systems

– Because physical process depends on time

19

Trends

• More powerful and cheaper computing

• More connected

20

Today’s Car

• A cyber-physical system: computers control the car

• Quiz. How many embedded processors are in a car?

– A: ~100s

21Simon Fürst, BMW, EMCC2015 Munich, adopted from OSPERT2015 keynote

Autonomous Car

• Human-like intelligence needs

– Sophisticated sensors and algorithms

– high-performance embedded computers

22

Semi autonomous car Fully autonomous car

https://www.latimes.com/business/autos/la-fi-waymo-self-driving-california-20181030-story.html

Tesla FSD Chip

• Super-computer on a car

23https://www.youtube.com/watch?time_continue=4988&v=Ucp0TTmvqOE

Today’s Airplane

• Avionics: electronic systems on an airplane

– Aviation + electronics

– Multiple subsystems: communications, navigation, display, flight control, management, etc.

• Modern avionics

– Increasingly computerized

24

Fly-by-wire

• Modern aircrafts rely on computers to fly

• Pilots do not directly move flight control surfaces (ailerons, elevator, rudder)

• Instead, Electronic Flight Control System (FCS) does.

25

FCS

YokeControl surfaces

Autopilot

• Specify desired track: heading, course, waypoints, altitude, airspeed, etc.

26

FCS

YokeControl surfaces

Modern Cyber-Physical Systems

• Cyber Physical Systems (CPS)

– Cyber (Computer) + Physical (Plant)

• Real-time

– Control physical process in real-time

• Safety-critical

– Can harm people/things

• Intelligent

– Can function autonomously

27

CPS Requirements

• Performance and efficiency– Meet deadlines in processing large amounts of real-time data

from various sensors (e.g., autonomous cars)– Many constraints: size, weight, and power (SWaP); cost

• Safety– Interact with the environment, human, in real-time– Can hurt humans, destroy things, blow up (e.g., Nuclear plants)– Need both logical and temporal (time) correctness

• Security– Communicate over the internet (cloud servers etc.)– Remote software update (fix bugs, …)– Run untrusted 3rd party software (e.g., Apple CarPlay)

28

Efficiency

• Many cyber-physical systems (CPS) need:

– More performance for higher autonomy

– Less cost, size, weight, and power

29

CMU’s “Boss” Self-driving car, circa 200710 dual-processor blade servers on the trunk

Audi’s zFAS platform. 2016-2018A single-board computer with multiple CPUs, GPU, FPGA

Audi A8

Compute Performance Demand

30Intel, “Technology and Computing Requirements for Self-Driving Cars”

Real-Time Data

• Big data needs powerful computers

31

Source: http://on-demand.gputechconf.com/gtc/2015/presentation/S5870-Daniel-Lipinski.pdf

Size, Weight, and Power (SWaP) Constraints

• Maximum performance with minimal resources

– Cannot afford too many or too power hungry ECUs

32Figure source: OSPERT 2015 Keynote by Leibinger

Modern System-on-a-Chip (SoC)

33

Core1 Core2 GPU NPU…

Memory Controller (MC)

Shared Cache

• Integrate multiple cores, GPU, accelerators

• Good performance, size, weight, power

• Introduce new challenges in real-time, security

DRAM

Mobileye EveQ4

• Real-time vision processor w/ DNN

• 2.5 teraflops @ 3W

• 8 cameras @ 36 fps

• Tesla uses EveQ3

• 14 cores

– 4 MIPS cores

– 10 vector cores

34

Nvidia’s Drive PX2 Platform

• 12 CPU + 2 GPU

– 8 Tegraflops @250W

• Real-time processing of

– Up to 12 cameras, radar, ..

– Deep Neural Network (DNN) for detection, classification

35

http://www.nvidia.com/object/drive-px.html

Tesla FSD Chip

• Super-computer on a car

36https://www.youtube.com/watch?time_continue=4988&v=Ucp0TTmvqOE

SoCs for intelligent CPS require performance and efficiency

Safety

• Many CPS are safety-critical systems

– Can harm people or things

37

CPS Challenge Problem: Prevent This

From Dr. Edward A. Lee, UCB

Safety Failures

39

• Computer controlled medical X-ray treatments

• Six people died/injured due to massive overdoses (1985-1987)

• Caused by synchronization mistakes

• 7 billion dollar rocket was destroyed after 40 secs (6/4/1996)

• “caused by the complete loss of guidance and altitude information ” Caused by 64bit floating to 16bit integer conversion

Therac 25 Arian 5

Air France 447 (2009)

• Airbus A330 crashed into the Atlantic Ocean in 2009

• Caused in part by computer’s misguidance– Pitot tube (speed sensor) failure Flight Director (FD) malfunction

(shows “head up”) pilots follow the faulty FD enter stall

40http://www.spiegel.de/international/world/experts-say-focus-on-manual-flying-skills-needed-after-air-france-crash-a-843421.htmlhttp://www.slate.com/blogs/the_eye/2015/06/25/air_france_flight_447_and_the_safety_paradox_of_airline_automation_on_99.html

Stall

Normal

Lion Air Flight 610 (2018)

• Boeing 737 crashed into the Java See in 2018

• Caused by stall prevention system (MCAS)

– sensor error (plane is “stall”) nose down (to the ocean)

41

Ethiopian Air 302 (2019)

42

https://www.seattletimes.com/business/boeing-aerospace/failed-certification-faa-missed-safety-issues-in-the-737-max-system-implicated-in-the-lion-air-crash

Design Issues of 737 MAX’s MCAS

• Operated on a single AoA sensor– A single source of failure– Despite of having two redundant sensors

• Repeated activation– No limit on how much the system can push the plane

downward – MCAS > pilot’s manual control

• Planned solutions– Use both sensors– Limited activation to limit the potential harm– MCAS < pilot’s manual control

43

https://www.boeing.com/commercial/737max/737-max-software-updates.page

Lufthansa A321 (2014)

• Similar prior incidents that didn’t kill people.

• Faulty AoA sensor readings (ice) trigger an automated stall prevention system, resulting 4,000 ft loss of altitude

• “When Alpha Prot is activated due to blocked AOA probes, the flight control laws order a continuous nose down pitch rate that, in a worst case scenario, cannot be stopped with backward sidestick inputs, even in the full backward position.”

44

https://avherald.com/h?article=47d74074

Lufthansa A321 (2014)

• Three redundant AoA sensors, but two freeze up simultaneously.

• The correct sensor’s outputs were discarded.

45

Tesla Autopilot (2016)

46http://www.nytimes.com/interactive/2016/07/01/business/inside-tesla-accident.html

• Tesla autopilot failed to recognize a trailer resulting in a death of the driver

NHTSA Report

• Both the radar and camera sub-systems are designed for front-to-rear collision prediction mitigation or avoidance.

• The system requires agreement from both sensor systems to initiate automatic braking.

• The camera system uses Mobileye’s EyeQ3 processing chip which uses a large dataset of the rear images of vehicles to make its target classification decisions.

• Complex or unusual vehicle shapes may delay or prevent the system from classifying certain vehicles as targets/threats

47

https://static.nhtsa.gov/odi/inv/2016/INCLA-PE16007-7876.PDF

NHTSA Report

• Object classification algorithms in the Tesla and peer vehicles with AEB technologies are designed to avoid false positive brake activations.

• The Florida crash involved a target image (side of a tractor trailer) that would not be a “true” target in the EyeQ3 vision system dataset and

• The tractor trailer was not moving in the same longitudinal direction as the Tesla, which is the vehicle kinematic scenario the radar system is designed to detect

48

https://static.nhtsa.gov/odi/inv/2016/INCLA-PE16007-7876.PDF

Tesla Autopilot (2019)

• Similar condition

49https://www.ntsb.gov/investigations/AccidentReports/Pages/HWY19FH008-preliminary-report.aspx

Uber Self-Driving Car (2018)

50

• Kill a pedestrian crossing a road in Arizona

https://www.nytimes.com/2018/03/19/technology/uber-driverless-fatality.html

NTSB Report

• The system first registered radar and LIDAR observations of the pedestrian about 6 seconds before impact

• Software classified the pedestrian as an unknown object, as a vehicle, and then as a bicycle with varying expectations of future travel path.

• At 1.3 seconds before impact,the system determined that an emergency braking maneuver was needed

• Emergency braking maneuvers are not enabled while the vehicle is under computer control, to reduce the potentialfor erratic vehicle behavior

51https://www.ntsb.gov/investigations/AccidentReports/Reports/HWY18MH010-prelim.pdf

Failures in CPS have consequences

Security

• CPS must be secure– Should prevent malicious access/use of the system

• But many CPS are open to various attacks– Networked CPS are especially vulnerable

• Examples– Stuxnet: Iranian nuclear power

plant hacking– Vermont power grid hack by Russia– Remote hack into cars (Jeep)– Police drone hacking– Sensor hacking: GPS spoofing.

IMU spoofing

52

Stuxnet (2010)

• The first known cyber weapon– Modify centrifuges’ rotation speed to their destruction

53https://spectrum.ieee.org/telecom/security/the-real-story-of-stuxnet

Targeted Iranian nuclear facility

Drone GPS Spoofing (2012)

• Fool GPS sensors

– Attacker can control the trajectory of the UAV

54https://radionavlab.ae.utexas.edu/images/stories/files/papers/drone_hack_shepard.pdf

Remote Attack on Jeep (2015)

55

https://www.wired.com/2015/07/hackers-remotely-kill-jeep-highway/

• Able to remotely (via cellular network) control steering, brake, and other critical functions via the car’s infotainment system

Ukraine Power Grid Attack (2016)

• Attack on SCADA control network of a power grid in Ukraine, causing blackout on 80K users.

56

https://www.antiy.net/p/comprehensive-analysis-report-on-ukraine-power-system-attacks/

Pacemaker Hack (2017,2018)

57

https://www.wired.com/story/pacemaker-hack-malware-black-hat/

https://www.theguardian.com/technology/2017/aug/31/hacking-risk-recall-pacemakers-patient-death-fears-fda-firmware-update

Triton (2018)

58

https://securingtomorrow.mcafee.com/other-blogs/mcafee-labs/triton-malware-spearheads-latest-generation-of-attacks-on-industrial-systems/

• Attack safety systems of industrial control systems

– Target an oil plant in Saudi Arabia

IoT WiFi Attacks (2019)

59https://hackaday.com/2019/09/05/esp8266-and-esp32-wifi-hacked/

Challenges

• Complexity

• Reliability

• Security

• Time Predictability

60

Complexity

61

Complexity

62

Image source: https://hbr.org/resources/images/article_assets/hbr/1006/F1006A_B_lg.gif

Example: F-22

• In 2007, 12 F-22s were going from Hawaii to Japan.

• After crossing the IDL, all 12 experienced multiple crashes.– No navigation– No fuel subsystems– Limited

communications– Rebooting didn’t help

• F-22 has 1.7 million lines of code F-22 Raptor

Complex software is hard to write and verify

Reliability

• Transient hardware faults

– Single event upset (SEU)• Due to alpha particle, cosmic radiation

– Manifested as software failures• Crashes

• Silent data corruption (wrong output)

– Bigger problem in advanced CPU• Increased density, frequency higher chance for transient faults

64

http://www.cotsjournalonline.com/articles/view/102279

Example: SRAM Soft Error Rate (SER)

• SRAM SER vs. technology scaling

– Per-bit SER decreases

– Per-chip SER increases (due to higher density)

65

Ibe et al., “Scaling Effects on Neutron-Induced Soft Error in SRAMs Down to 22nm Process” (Hitachi)

Complex hardware may be less reliable

Security

• General principles– Confidentiality: no data disclosure to unauthorized parties

– Integrity: data cannot be modified by unauthorized parties

– Availability: data/system must be available when needed

– Safety: do no physical harm (critical in CPS)

• Defender’s disadvantage– An attackers needs to find one vulnerability; while the

defender needs to prevent ALL vulnerabilities.

• Challenges– Many access vectors

– Many attack techniques

66

Access Vectors

67Comprehensive Experimental Analyses of Automotive Attack Surfaces, USENIX Security, 2011

Goto Fail Bug

68

err = 0. . .hashOut.data = hashes + SSL_MD5_DIGEST_LEN;hashOut.length = SSL_SHA1_DIGEST_LEN;if ((err = SSLFreeBuffer(&hashCtx)) != 0)goto fail;if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0)goto fail;if ((err = SSLHashSHA1.update(&hashCtx, &clientRandom)) != 0)goto fail;if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0)goto fail;if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)goto fail;goto fail; if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0)goto fail;

err = sslRawVerify(...); // This code must be executed. . .

fail:SSLFreeBuffer(&signedHashes);SSLFreeBuffer(&hashCtx);Return err;

MISTAKE! THIS LINE SHOULD NOT BE HERE

iOS 7.0.6Data SecurityAvailable for: iPhone 4 and later, iPod touch (5th generation), iPad 2 and later

Impact: An attacker with a privileged network position may capture or modify data in sessions protected by SSL/TLS

Description: Secure Transport failed to validate the authenticity of the connection. This issue was addressed by restoring missing validation steps.

Buffer Overflow

• What is wrong with this code?

69

#define BUFFER_SIZE 256int process_args(char *arg1){

char buffer[BUFFER SIZE];strcpy(buffer,arg1);...

}

int main(int argc, char *argv[]){

process_args(argv[1]);...

}

Before After executing strcpy(buffer, arg1)

Linux Kernel Buffer Overflow Bugs

70

Complex software has lots of security bugs

Software Attacks on Hardware

71https://meltdownattack.com/

Micro-Architectural Side-Channels

• Many micro-architectural components contain hidden state which leaks secret– often via observable timing variations

• Known to exist in cache, DRAM bank, OoO speculation, branch predictor, etc.

• Logically correct, proven software is also vulnerable

72

Spectre Attack

• Wrong branch is speculatively taken.

• x is maliciously chosen by the attacker.

• The attacker probes arrary2 to recover secret: array1[x]

73

(Cache) Timing Channel Attack

• By measuring access timing differences of a memory location, an attacker can determine whether the memory is cached or not.

• This can be used to leak secret information

• Methods: Flush + Reload, Prime + Probe, etc.

74Image source: M. Lipp et al., “Meltdown,” arXiv Prepr., 2018.

Row of CellsRowRowRowRow

Wordline

Victim Row

Victim RowAggressor Row

RowHammer Attacks

75Credit: This slide is from Dr. Yoongu Kim’s presentation slides of the following paper:

“Flipping Bits in Memory Without Accessing Them: An Experimental Study of DRAM Disturbance Errors,” In ISCA, 2014

• Repeatedly opening and closing a DRAM row can induces bit flips in adjacent rows storing sensitive data (e.g., page table)Complex hardware may not be secure

Time Predictability

• At low-level, hardware is deterministic timing

• At higher-levels, not so much ignore timing– Pipeline, caches, Out-of-order execution,

speculation, ISA

– Process, thread, lock, interrupt

• Focus on average case, not worst-case. No guarantees– Fine in cyber world

– Real-world doesn’t work that way

76

From Dr. Edward A. Lee, UCB

Timing Predictability

• Q. Can you tell exactly how long a piece of code will take to execute on a computer?

– Used to be (relatively) easy to do so.

• Measure timing. Use the timing for analysis.

– Very difficult to answer in today’s computers

• Pipeline, cache, out-of-order and speculative execution, multicore, shared cache/dram very high variance.

77

Cache Denial-of-Service Attacks

LLC

Core1 Core2 Core3 Core4

victim attackers

• Observed worst-case: >300X (times) slowdown

– On popular in-order multicore processors

– Due to contention in cache write-back buffer

>300X

M. G. Bechtel and H. Yun. “Denial-of-Service Attacks on Shared Cache in Multicore: Analysis and Prevention.” In RTAS, 2019

Safety and Real-Time

79https://youtu.be/Jm6KSDqlqiU

Complex system may not be time predictable

Related Areas

• CPS/embedded systems development requires inter disciplinary approach

– EECS (on cyber systems)

• Computer architecture

• Real-time systems

• Formal method

• Software engineering

– Aerospace, and other engineering (on physical)

• Physical systems (plant/actuator) modeling/control

80

Topics

• Focus on design

• CPU & memory

• I/O interface

• Sensors & actuators

• Interrupt & multitasking

• Real-time scheduling

• Advanced topics

81

Summary

• Embedded systems– Purpose built systems

– Everywhere as more “things” are computerized

– Related terminologies: Cyber-Physical Systems (CPS), real-time systems, Internet-of-things (IoT)

– Efficiency, safety, security are essential but difficult

• This course– Learn concepts and skills to develop embedded

systems.

82

Crew

• Teaching Assistants– Yiju Yang

• Email: y150y133@ku.edu• Office hours: TBD• Office: 3002 EATON

– Xiaohan Zhang• Email: speed1224@ku.edu• Office hours: TBD• Office: 3002 EATON

– Arin Dutta• Email: arindutta40@ku.edu• Office hours: TBD• Office: 3002 EATON

83

Appendix

84

top related