Tajana Simunic Rosing Department of Computer Science and ... › classes › wi17 › cse237A-a ›...

Post on 28-Jun-2020

12 views 0 download

Transcript of Tajana Simunic Rosing Department of Computer Science and ... › classes › wi17 › cse237A-a ›...

System Energy Efficiency Lab

seelab.ucsd.edu

Tajana Simunic RosingDepartment of Computer Science and EngineeringUCSD

What are embedded systems?

Systems which use computation to perform a specific function

Embedded within a larger device and environment

Heterogeneous & reactive to environment

Main reason for buying is not information processing

2

Embedded System Design

Verification and Validation

HardwareHardware components

3

Welcome to CSE 237A!

Instructor: Prof. Tajana Simunic Rosing Email: tajana.teach.ucsd@gmail.com; put CSE237a in subject line Office Hours: T 11:20-12:20pm; Th 5:00-6:00 PM @ CSE 2118

Admin: Kathleen Au Office: CSE 2272 Phone: (858) 822-1516; Email: k6au@eng.ucsd.edu

TAs: Christine Chan; csc019@eng.ucsd.edu Akanksha Maurya; amaurya@eng.ucsd.edu

Class Website: http://cseweb.ucsd.edu/classes/wi17/cse237A-a Grades: http://ted.ucsd.edu Discussion board: https://piazza.com/ucsd/winter2017/cse237a

4

About This Course

Part of a four course group

CSE 237A: Introduction to Embedded Systems

CSE 237B: Software for Embedded Systems

CSE 237C: Hardware for Embedded Systems

CSE 237D: Embedded Systems Design

Depth sequence:

Embedded Systems and Software

5

Course Objectives

Develop an understanding of the technologies behind the embedded computing systems technology capabilities and limitations of the hardware,

software components methods to evaluate design tradeoffs between different

technology choices. design methodologies

Overview of a few exciting research topics in embedded systems

For more details, see the schedule on the webpage

6

Course Requirements

No official graduate course as prerequisite

Knowledge Digital hardware, computer architecture (ISA, organization),

programming & systems programming, algorithms

Skills Advanced ability to program

We will be developing a loadable kernel module

Ability to look up references and track down pubs (Xplore etc) Ability to communicate your ideas (demos, presentations, reports)

Initiative Open-ended problems with no single answer requiring thinking and

research

Interest

7

Textbook & Assigned Reading

Recommended text:

By Peter Marwedel

2nd edition, Springer 2011

A set of papers will be required reading

will relate to the core topic of that class

you are expected to read it BEFORE the class

There are additional pointers to papers and web resources on the class website

8

Course Grading

Homeworks: 8%

Embedded systems projects: 45% Individual project 50%:

Energy-efficient real-time sensing app scheduler Part 1: 35%:

Compile the kernel, create a loadable kernel module, characterize the workloads running on the hardware

Part 2: 65%: Add HW sensors to the board and implement a real-time scheduler, adjust the scheduler so it

uses DVFS settings on the board

Team project 50%:

Topic of your choice, needs to have significant HW & SW components Proposal: 5% (assigned today)

Progress Report: 25%

Final demo and report: 70%

Exam: 45%

Class participation, attendance, engagement: 2% Come prepared to discuss the assigned paper(s)

9

Previous Years’ Final Projects

Driving Dashboard Simulator Engine Control Unit Time and Location Sensitive Messaging Protocol for

Automated Message Delivery Used laser interface for message delivery

Comparison of Ad-hoc Routing Algorithms Algorithms run on multiple sensor nodes

Context-aware energy management for healthcare applications Used body worn sensors plus phone for managing energy

User experience-aware non-volatile memory management How to leverage STT-RAM and PCRAM for responsive user

applications

Fire sniffing drones

10

Fire Sniffing Drones

Two autonomous drones leveraging air quality & other sensors,

relaying the processed context to the cloud collaborate to map the fire and RF

spectrum for the fire fighting troops on the ground

Individual Project with Raspberry Pi

Raspbian – Linux variant

Build and deploy a custom version onto our Raspberry Pi that extends default functionality

Collect metrics aboutworkloads running ondevice

Create a real-time schedulerto allow time-constrainedprocesses to executesuccessfully

12

Individual Project Part 1

Custom Raspbian build: Enable performance counters to be used to capture memory

and processor (CPU) metrics

Familiarization with build processes

Cross-compile code for Raspberry Pi Default compilation is for

x86-64 (amd64 architecture)

Goal is to compile programs for ARMv7 architecture

13

Individual Project Part 1

Simple program execution vs. kernel modules Programs in kernel space that extend underlying functionality

Build and compile kernelmodules Simple module

Main goal: Execute assemblycode to manipulatePC registers

Analyze program behavior Classify programs based on performance counter (PC)

results

14

Individual Project Part 2: Sensors

15

Raspberry PI has a few onboard sensors

Temperature sensors for CPU cores

External sensors and actuators

Can add multiple digital sensors via general-purpose input/output (GPIO)

ADC required to use analog sensors

WiringPI: Library to easily use GPIO

Programmable with Python, C, and C++

Many sensors available

You will integrate with Raspberry PI 2: button, LEDs, buzzer, shock, tracking, temperature

#include <wiringPi.h>

int main (void)

{

wiringPiSetup () ;

pinMode (0, OUTPUT) ;

for (;;)

{

digitalWrite (0, HIGH) ; delay (500) ;

digitalWrite (0, LOW) ; delay (500) ;

}

return 0 ;

}

Individual Project Part 2: Scheduler

Turn heterogeneous programs from a collection of sequential processes into a schedule by creating a real-time scheduler

Make scheduler implementation energy-efficient by leveraging different voltage-frequency settings of Raspberry PI 2

16

System Energy Efficiency Lab

seelab.ucsd.edu

17

Why platforms?

Embedded systems operate in, interact with, and react to an analog, real-time world

Sensors: provide measurements of the outside world Actuators: provide an output, or a means to modify the physical

world Platforms: everything in between – the framework that allows a

system to analyze sensors, process their data, and drive actuators

18

Platforms

Infrastructure between sensors and actuators

Especially important to embedded systems

Increased emphasis on embedded software structure and functionality

19

Embedded Platform Requirements

Operate within hardware/resource constraints

Real-time requirements

Safety/Reliability

Upgradability

Limited manual interfacing

Input/Output (I/O) interface

20

Microcontrollers

Low-power, low-capacity System-on-Chip (SoC) Processor core (eg. ARM7)

Memory (Flash ROM + RAM)

General-purpose I/O (GPIO)

Intended for sequential control rather than general computation

Interrupts for I/O handling, preemption

Programmable interval timer

Tools to implement models of computation

“Flash” the controller to upgrade

Software-driven GPIO + Conversion

21

Microcontrollers:Development Workflow

Software development Tools for formal models, models of

computation… …or just plain C!

Libraries: Input/Output (I/O) Analog-to-Digital conversion (ADC) &

Digital-to-Analog conversion (DAC) Basic memory management Interrupts, timing, and constraints

Compile for microcontroller (MCU) “Flash” the device – load the binary Execute!

22

System Energy Efficiency Lab

seelab.ucsd.edu

Tajana Simunic RosingDepartment of Computer Science and EngineeringUCSD

Class Overview

What’ve covered until now: Introduction & platforms

Where we are going today: Platforms cont. & CPUs

Due today: Article on CPUs

Upcoming: Individual project part 1 assigned next week on Tuesday

We will be using RPi3 for the project, NOT any other version

TAs: Akanksha Maurya

Email: amaurya@eng.ucsd.eduOffice hours: starting 1/18: W 11AM-12PM @ CSE B250A

Christine ChanEmail: csc019@eng.ucsd.eduOffice hours: 1/17 12-1PM @ CSE 3217; starting 1/23: M 10-11AM @ CSE B250A

No prof. office hour today, please email if you’d like to get together prior to the next office hour

Microcontrollers: Arduino

Atmel AVR microcontroller (ARM on higher-end models) I2C bus communication with custom modules – “shields” General-purpose Input/Output (GPIO) Microcontroller pins exposed with established interface for

direct connection

25

• Merge traditional microcontrollers with an established library system and development environment (IDE)

• Simplify addressing & control• Program in C or C++• setup() – initialization• loop() – main loop• bootloader

General-Purpose Embedded Processing: ARM

Designed around embedded use Reduced Instruction Set Architecture (RISC) for reduced size,

power, cost

Specialized digital signal processing (DSP) instructions for I/O

Multiple CPU modes allow for interrupts, real-time operating system task scheduling and device monitoring

Conditional execution for nearly every CPU instruction

Single-instruction Multiple Data (SIMD) extensions for streaming data use

26

Direct ARM Deployment – ARM SDT

ARM Software Development Toolkit (SDT) – tools for CL and Windows: C, C++, Thumb compilers, assemblers & linkers

Project management software, utilities & debuggers

ARMulator – ARM core emulator

Workflow very similar to that of MCUs, but more tools and libraries to work with: Code optimization

Object-oriented programming

Memory management

ARM big.LITTLE

GPU processing27

ARM Deployment – Raspberry Pi 2

Low-tier ARM SoC (700 MHz) Flash-based persistent storage

Onboard 256/512MB RAM

GPIO for peripheral connectivity

I2C open-pin bus

Linux

USB-connected Ethernet + USB ports

HDMI Out

Application Development: Python, primary

C, C++, Ruby, supported

28

Using OS for ARM Deployment

Operating System (OS) takes care of system management – threads, memory & caching, I/O

Dozens of popular ARM operating systems

Linux (including RTLinux)

VxWorks (Real-TimeOperating System)

TinyOS (unofficial)

iOS

Android

Windows RT

…and more!

29

OS-based ARM Deployment: Linux

30

Draw upon Linux/Windows/iOS kernel Established libraries for common embedded operations

Application Framework Develop and deploy feature-rich, connected applications

Part of a larger system

Kernel/OS layer

Application/User space

OS-based ARM Deployment: Linux Development Process

Kernel: Compile source into installable image

Kernel modifications (e.g. enable kernel features)

Kernel Module: Compile C code into installable module (<module_name>.ko)

Kernel extensions (e.g. kernel-level operations that use/expose kernelfunctionality)

Applications Written in any language compilable/

interpretable on the machine

Run in user space

31

OS-based ARM Deployment: Raspberry Pi

Primarily use Linux-kernel-based OS Raspbian: Debian based Linux

Leading OS for Raspberry Pi

Port of Debian Wheezy

Useful precompiled software from Debian packages e.g., LibreOffice, web browsers

Optimized for hard float instructions

Pidora: Fedora based Linux

Arch Linux ARM: A light-weight OS, full control to competent users

Puppy Linux: Run from RAM with a minimal memory footprint

OpenELEC: Optimized for home media streaming

Available to use other popular OSs Windows 10, Ubuntu, …

32

OS-based ARM Deployment: AndroidFoundation: Linux Kernel

33

OS-based ARM Deployment: AndroidAndroid runtime: unique system alongside system libraries, OS

Libraries for compilation, core Java

Dalvik Virtual Machine – Android-optimized Java Virtual Machine

Enables full-fledged Java features (threading, memory mgmt)

34

Libraries for user (Angry Birds) and core apps (Phone, Browser)

Extensible, customizable resources & interfaces for applications

OS-based ARM Deployment: Android

35

OS-based ARM Deployment: Android

36

OS-based ARM Deployment:Android vs. Linux

Primary Android Development Low-level embedded computing

37

Trade off overhead, low-level efficiency for high-level feature-richness

Low-level functionality masked by infrastructure

More about Android: Kernel Layer

At heart, Android is based on Linux (Version 2.6 and higher)

Provides OS services: Memory Management

Process/thread handling

Network stack

Drivers – system, hardware devices, sensors, power management

Abstracts hardware away from software stack

Provides interface to Android Libraries

Kernel-level development is performed here Code is written in C, and entire OS is either compiled from source, or

cross-compiled for the device and installed as a module

Identical to Linux kernel development

38

Android OS Layer

System Libraries – abstracts kernel interface for Application Framework’s application programming interfaces (APIs)

Kernel-level interfaces are abstracted and extended with developer libraries

Common Libraries: SystemC: C library, optimized for embedded Media: playback and decoding of common formats Surface Manager: display subsystem, composes multiple implementations of 2D,

3D graphics LibWebCore: web browser engine SGL, 3DLib: 2D, 3D graphics, respectively SQLite: compact database engine – within Android, used for app data storage

Library development is performed here Code is written in C/C++, and OS is either compiled from source Platform designers introduce special libs, hooks to custom sensors, etc.

39

Android Runtime

Sits alongside system libraries – unique to Android and Java-based operating systems

Libraries for compilation, core Java libraries

Dalvik Virtual Machine – Android-specific JVM

Interface b/w compiled Java apps and underlying Linux kernel

Enables full-fledged Java features (threading, memory management)

40

Application Framework

The heart of the Android front-end Sits on top of JVM and system libraries, provides functionality for

both user (Angry Birds, etc.) and core applications (Phone, Browser, etc.)

Contains system resources and interfaces needed for applications, extensible with new, custom libraries Enables reusability of reliable modules – the power of Android Views for display, Content Providers for data access, Resource

Manager for system resources, Notification and Activity Managers

Application development is performed on top of this Code is written in Java, using libraries found in the App

Framework

41

Android Application Development

Individual applications are composed of Application Components

Activities: each UI screen + interaction elements (applications can have multiple activities)

Services: background, long-running processes, with no UI components

Content Providers: application data storage interface, for file system, SQLite, etc.

Broadcast Receivers: non-UI listener for system events and broadcast messages

42

Summary

Class overview:

We’ll cover the highlights of embedded HW, control systems, signals & systems, embedded SW and embedded system modeling

Platforms for embedded system development

HW

Small and low-power (e.g. Arduino)

Mid range e.g Raspberry PI

Larger size e.g. larger FPGA boards

SW

Development environments mostly based on C (e.g. Arduino)

OS and development environment (e.g. Linux for RPi2, Andriod)

Next: we start on overview of embedded HW components

UCSD Note #1:

Basic Needs Resources

• Are you eating properly? Do you have adequate access to nutritious

food? Do you have stable housing? Are you homeless or couch

surfing?

• If you or someone you know is suffering from food and/or

housing insecurities, please note:

• The Triton Food Pantry (in the old Student Center),

https://www.facebook.com/tritonfoodpantry/ , is free and

anonymous, and includes produce.

• Financial aid resources, the possibility of emergency grant funding,

and off-campus housing referral resources are available.

• CAPS and college deans can connect students to the above

resources, as well as other community resources and support.

UCSD Note #2:

Sexual Violence and Harassment

The Office for the Prevention of Harassment & Discrimination (OPHD) provides assistance to students, faculty,

and staff regarding reports of bias, harassment, and discrimination. OPHD is the UC San Diego Title IX office.

Title IX of the Education Amendments of 1972 is the federal law that prohibits sex discrimination in educational

institutions that are recipients of federal funds. Jacobs School students have the right to an educational

environment that is free from harassment and discrimination.

Students have options for reporting incidents of sexual violence and sexual harassment. Sexual violence

includes sexual assault, dating violence, domestic violence, and stalking. Information about reporting options

may be obtained at OPHD at (858) 534-8298, ophd@ucsd.edu or http://ophd.ucsd.edu. Students may receive

confidential assistance at CARE at the Sexual Assault Resource Center at (858) 534-5793, sarc@ucsd.edu

or http://care.ucsd.edu or Counseling and Psychological Services (CAPS) at (858) 534-3755

or http://caps.ucsd.edu.

Students may feel more comfortable discussing their particular concern with a trusted employee. This may be a

Jacobs School student affairs staff member, a department Chair, a faculty member or other University official.

These individuals have an obligation to report incidents of sexual violence and sexual harassment to OPHD.

This does not necessarily mean that a formal complaint will be filed.

If you find yourself in an uncomfortable situation, ask for help. The Jacobs School is committed to upholding

University policies regarding nondiscrimination, sexual violence and sexual harassment.