Interrupt response times on Arduino and Raspberry Pi. Tomaž Šolc

Similar documents
Electronics Single Board Computers

I/O Systems (3): Clocks and Timers. CSE 2431: Introduction to Operating Systems

RPi General Purpose IO (GPIO) Pins

Advanced Embedded Systems

Kevin Meehan Stephen Moskal Computer Architecture Winter 2012 Dr. Shaaban

ECE 353 Lab 4. General MIDI Explorer. Professor Daniel Holcomb Fall 2015

F28HS Hardware-Software Interface: Systems Programming

Development of Real-Time Systems with Embedded Linux. Brandon Shibley Senior Solutions Architect Toradex Inc.

Lesson 7 Programming Embedded Galileo, Raspberry Pi, BeagleBone and mbed Platforms

Measuring the impacts of the Preempt-RT patch

ECE 471 Embedded Systems Lecture 12

Building Real-Time Embedded Applications on QduinoMC

w w w. b a s e t r a i n i n g i n s t i t u t e. c o

ECE 471 Embedded Systems Lecture 12

extended external Benchmarking extension (XXBX)

Low-Cost Microcontrollers

64 bit Bare Metal Programming on RPI-3. Tristan Gingold

EE414 Embedded Systems Lab 4. Interrupt. 1. Purpose. 2. Problem Statement

Embedded Linux With Raspberry Pi IOT

Cooking with Team 279

ECE 471 Embedded Systems Lecture 2

Department of Computer Science, Institute for System Architecture, Operating Systems Group. Real-Time Systems '08 / '09. Hardware.

Raspberry Pi Introduction

Embedded Technosolutions

ECE 471 Embedded Systems Lecture 12

EE4390 Microprocessors

Dongjun Shin Samsung Electronics

HOW TO INTEGRATE NFC FRONTENDS IN LINUX

How Linux RT_PREEMPT Works

System Energy Efficiency Lab seelab.ucsd.edu

ECE 598 Advanced Operating Systems Lecture 4

A Comparison of Scheduling Latency in Linux, PREEMPT_RT, and LITMUS RT. Felipe Cerqueira and Björn Brandenburg

[537] I/O Devices/Disks. Tyler Harter

ARDUINO YÚN MINI Code: A000108

Evaluation of Real-time Performance in Embedded Linux. Hiraku Toyooka, Hitachi. LinuxCon Europe Hitachi, Ltd All rights reserved.

Demand Code Paging for NAND Flash in MMU-less Embedded Systems. Jose Baiocchi and Bruce Childers

GUI Based Industrial Automation using Python under Linux

IoT.js. Next generation web for connected things. Samsung Electronics Software Center Piotr Marcinkiewicz 2017

Akaros. Barret Rhoden, Kevin Klues, Andrew Waterman, Ron Minnich, David Zhu, Eric Brewer UC Berkeley and Google

ADVANCED trouble-shooting of real-time systems. Bernd Hufmann, Ericsson

AUTOBEST: A United AUTOSAR-OS And ARINC 653 Kernel. Alexander Züpke, Marc Bommert, Daniel Lohmann

Kernel Internals. Course Duration: 5 days. Pre-Requisites : Course Objective: Course Outline

Tracing embedded heterogeneous systems

RetroBSD - a minimalistic Unix system. Igor Mokoš bsd_day Bratislava

Functions (API) Setup Functions

Computer Science Window-Constrained Process Scheduling for Linux Systems

Processor and Peripheral IP Cores for Microcontrollers in Embedded Space Applications

Introduction to the Raspberry Pi AND LINUX FOR DUMMIES

Architecture and OS. To do. q Architecture impact on OS q OS impact on architecture q Next time: OS components and structure

FMCAD 2011 (Austin, Texas) Jonathan Kotker, Dorsa Sadigh, Sanjit Seshia University of California, Berkeley

Real Time Application Interface focused on servo motor control

POWER-AWARE SOFTWARE ON ARM. Paul Fox

Performance evaluation of Linux CAN-related system calls

Amortised Optimisation as a Means to Achieve Genetic Improvement

POWER MANAGEMENT AND ENERGY EFFICIENCY

Enabling Hybrid Parallel Runtimes Through Kernel and Virtualization Support. Kyle C. Hale and Peter Dinda

A Global Operating System for HPC Clusters

Measuring Interrupt Latency

Here to take you beyond. ECEP Course syllabus. Emertxe Information Technologies ECEP course syllabus

IoT Project Proposals

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Lab Assignment Each team will independently implement the launch interceptor specification For this assignment, you re writing portable C code

ARM Powered SoCs OpenEmbedded: a framework for toolcha. generation and rootfs management

Nano RK And Zigduino. wnfa ta course hikaru4

ARDUINO YÚN Code: A000008

Usable Simulink Embedded Coder Target for Linux

CSC227: Operating Systems Fall Chapter 1 INTERRUPTS. Dr. Soha S. Zaghloul

Operating Systems Design 25. Power Management. Paul Krzyzanowski

Hardware OS & OS- Application interface

An Incubator Project in the Apache Software Foundation. 13 July 2016

Lab 2 - RASPNet layer 1 und 2

Embedded Technosolutions

Lesson 2 Prototyping Embedded Software on Arduino on Arduino boards. Chapter-9 L02: "Internet of Things ", Raj Kamal, Publs.: McGraw-Hill Education

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University

RaRa Academy: Raspberry Pi. Karl Heinz Kremer - K5KHK

IoT Based Traffic Signalling System

Task Based Programming Revisited Real Time Operating Systems

1.8inch LCD Module USER MANUAL

Carl Peto. 10th August 2017 SWIFT FOR ARDUINO

Mobile Operating Systems Lesson 01 Operating System

SimXMD Simulation-based HW/SW Co-debugging for field-programmable Systems-on-Chip

Efficiency and memory footprint of Xilkernel for the Microblaze soft processor

ECE 471 Embedded Systems Lecture 2

Lesson 6 Intel Galileo and Edison Prototype Development Platforms. Chapter-8 L06: "Internet of Things ", Raj Kamal, Publs.: McGraw-Hill Education

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Memory Management

Hardware/Software Codesign of Schedulers for Real Time Systems

Microcontroller Basics

Path analysis vs. empirical determination of a system's real-time capabilities: The crucial role of latency tests

ECE 471 Embedded Systems Lecture 15

UFCETW-20-2 Examination Answer all questions in Section A (60 marks) and 2 questions from Section B (40 marks)

F28HS Hardware-Software Interface: Systems Programming

Microcomputing for Art

VxWin RT. KUKA Roboter GmbH Blücherstrasse 144 D Augsburg Folie 1

EMBEDDED SYSTEMS WITH ROBOTICS AND SENSORS USING ERLANG

Implementation work on open source web of things servers and gateways. Dave Raggett, W3C

EMBEDDED LINUX ON ARM9 Weekend Workshop

W4118: interrupt and system call. Junfeng Yang

Power Management for Embedded Systems

RT-MaG: an open-source SIMULINK Toolbox for Linux-Based Real-Time Robotic Applications

BR03 Raspberry Pi Zero Bridge

Transcription:

Interrupt response times on Arduino and Raspberry Pi Tomaž Šolc tomaz.solc@ijs.si

Introduction Full-featured Linux-based systems are replacing microcontrollers in some embedded applications for low volumes, difference in BOM price is insignificant very little difference in physical size cheaper software development (proprietaty toolchains, asm vs. gcc, Python, Javascript,...) simpler debugging (JTAG vs. shell access, gdb) 65x30 mm $5.00 69x53 mm $25.00

A significantly different approach to real-time tasks general-purpose OS pre-emptive kernel, priority scheduling application-profile CPU core SMP, cache, pipelining, parallelism, MMU... 1 GHz clock, 1 GB RAM, 10 GB storage gross overprovisioning No OS or simple RT-OS hw. interrupt priority, low system overhead microcontroller-profile CPU core well-defined instruction lengths, access times... 10 MHz clock, 10 kb RAM, 100 kb storage predictability

Motivation for experiment What kind of interrupt response times can be expected from these systems out-of-the-box? Test most straightforward implementations Examples from manuals, first results on web search,... First implementation typically also the last (cheaper to go with higher-performance hardware than study and optimize prototype, lack of time, expertise,...) Two platforms commonly used as starting points e.g. hardware startups making IoT devices, SMEs (not specialized industries with large existing teams)

Experiment setup Task: on PIN rising edge raise POUT signal generator GW Instek AFG-2005 Device under test oscilloscope Tektronix TDS 2002B PC signal generator outputs a square wave signal with period >> t t oscilloscope measures time between rising edges on PIN and POUT lines PC stores results for later analysis

Hardware Arduino Uno Atmel ATmega328p, AVR architecture, 16 MHz clock Arduino IDE 1.0.5 (C++) Raspberry Pi Zero Broadcom BCM2835, ARM11 architecture, 1 GHz clock Raspbian Jessie OS (2016-03-18 image, Linux 4.1.19+) Python 2.7.9, RPi.GPIO 0.6.2

Software implementations Arduino Uno interrupt service routine on GPIO interrupt using attachinterrupt() standard library call. busy polling loop using digitalread() std. library call. Raspberry Pi Zero native, kernel space - Linux.ko module using»gpio consumer«interface. native, user space - Compiled C program using sysfs interface for GPIO. interpreted Python script using RPi.GPIO library.

Experiment setup

Results Arduino, IRQ t min = 8.9476 μs t avg = 9.0673 μs t max = 14.0163 μs Arduino, polling t min = 6.6675 μs t avg = 8.6581 μs t max = 14.8937 μs R-Pi, native, kernel space t min = 6.0367 μs t avg = 12.6761 μs t max = 43.7788 μs R-Pi, native, user space t min = 179.9882 μs t avg = 280.5045 μs t max = 511.2023 μs R-Pi, Python t min = 143.1988 μs t avg = 212.9129 μs t max = 377.4056 μs

Results (histogram 0-600 μs)

Results (histogram 0-50 μs)

Discussion of results Arduino response times unexpectedly inconsistent Measured >5 μs spread, should be 0,25 μs given CPU clock, instruction lengths R-Pi kernel mode code on average close to Arduino R-Pi has >60x faster CPU clock Less consistent (kernel has many other ISRs to serve) Interpreted Python implementation faster than native userspace code? Tested on an otherwise idle system on R-Pi.

Cause of Arduino inconsistency Standard library keeps timer0 enabled. Timer overflow interrupt competes with GPIO interrupt. If timer0 is disabled, measurements fit theory. t min = 8.9485 μs t avg = 9.0526 μs t max = 9.1986 μs Δt = 0.2501 μs

Why is Python faster than C? Python RPi.GPIO library mmaps GPIO registers to its own process address space removes need for syscalls when changing POUT state. syscall still needed when waiting for PIN edge interrupt vectors not directly accessible from userspace. syscalls are slow (context switch into kernelspace) Initial native userspace implementation used sysfs GPIO lines exposed as special files in /sys filesystem. 3 POSIX syscalls per POUT state change: open(), write(), close()

Why is Python faster than C? A native userspace implementation using mmap approach is faster than Python.

Effect of CPU load on R-Pi With default setup, R-Pi has lower response times when CPU is loaded compared to idle! Power saving feature ondemand governor lowers CPU clock from 1 GHz to 700 MHz when CPU is idle. Changing governor to performance produces expected results

Conclusions Complex systems can be counterintuitive simpler is not always faster profiling and measurements are important R-Pi can be»good enough«for some real-time tasks average times comparable to microcontrollers when using kernel driver but upper bound is not predictable expectations for reliability of consumer devices are decreasing - often features are more important.»it's good enough if it works 90% of the time«

Questions? Tomaž Šolc tomaz.solc@ijs.si source code and raw data at https://github.com/avian2/interrupt-response-times