ARM Cortex-M and RTOSs Are Meant for Each Other

Similar documents
IoT and Security: ARM v8-m Architecture. Robert Boys Product Marketing DSG, ARM. Spring 2017: V 3.1

Cortex-M3/M4 Software Development

Stellaris Robotic Evaluation Board and Micriµm µc/os-iii

The Next Steps in the Evolution of Embedded Processors

Implementing Secure Software Systems on ARMv8-M Microcontrollers

ELC4438: Embedded System Design ARM Cortex-M Architecture II

Design and Implementation Interrupt Mechanism

ARM TrustZone for ARMv8-M for software engineers

The ARM Cortex-M0 Processor Architecture Part-1

ARM Cortex -M for Beginners

Lecture notes Lectures 1 through 5 (up through lecture 5 slide 63) Book Chapters 1-4

ARM Cortex core microcontrollers

Interrupts (Exceptions) Gary J. Minden September 11, 2014

Kinetis Software Optimization

ARM CORTEX-R52. Target Audience: Engineers and technicians who develop SoCs and systems based on the ARM Cortex-R52 architecture.

Interrupts (Exceptions) (From LM3S1968) Gary J. Minden August 29, 2016

ARM architecture road map. NuMicro Overview of Cortex M. Cortex M Processor Family (2/3) All binary upwards compatible

Cortex-M Software Development

Embedded System Design

ARM Interrupts. EE383: Introduction to Embedded Systems University of Kentucky. James E. Lumpp

The Definitive Guide to the ARM Cortex-M3

The Next Steps in the Evolution of ARM Cortex-M

ARMv8-M Architecture Technical Overview

Programming Embedded Systems

Interrupt/Timer/DMA 1

ECE254 Lab3 Tutorial. Introduction to MCB1700 Hardware Programming. Irene Huang

Arm Cortex -M33 Devices

OUTLINE. STM32F0 Architecture Overview STM32F0 Core Motivation for RISC and Pipelining Cortex-M0 Programming Model Toolchain and Project Structure

AND SOLUTION FIRST INTERNAL TEST

Migrating to Cortex-M3 Microcontrollers: an RTOS Perspective

ARM Architecture and Assembly Programming Intro

Micriμm. For the way Engineers work

Hercules ARM Cortex -R4 System Architecture. Processor Overview

RM3 - Cortex-M4 / Cortex-M4F implementation

AN316 Determining the stack usage of applications

Running ARM7TDMI Processor Software on the Cortex -M3 Processor

Lab 4 Interrupt-driven operations

RM4 - Cortex-M7 implementation

COEN-4720 Embedded Systems Design Lecture 4 Interrupts (Part 1) Cristinel Ababei Dept. of Electrical and Computer Engineering Marquette University

Learning Embedded System using advanced Microcontroller and Real Time Operating System

Multitasking on Cortex-M(0) class MCU A deepdive into the Chromium-EC scheduler

ECE251: Thursday September 27

Cortex-M3 Reference Manual

References & Terminology

introduction to interrupts

µc/os-iii Performance Optimization ARM Cortex-M (Part 2)

ARM Roadmap Spring 2017

Measuring Interrupt Latency

Arm TrustZone Armv8-M Primer

real-time kernel documentation

Putting it All Together

A Developer's Guide to Security on Cortex-M based MCUs

Exception and fault checking on S32K1xx

M2351 Security Architecture. TrustZone Technology for Armv8-M Architecture

Interrupts and Low Power Features

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ARM Cortex-M3 CCS

Cortex-M4 Processor Overview. with ARM Processors and Architectures

Getting Started With the Stellaris EK-LM4F120XL LaunchPad Workshop. Version 1.05

6/20/2018. Lecture 2: Platforms & RTOS. Outline. Lab Setup (20 min) Labs work. Lecture: Platform + RTOS

5/11/2012 CMSIS-RTOS. Niall Cooling Feabhas Limited CMSIS. Cortex Microcontroller Software Interface Standard.

ARM Cortex -M33 Processor User Guide

Exceptions and Interrupts ARM Cortex M3

Final Exam Study Guide

Cortex-R5 Software Development

embos Real Time Operating System CPU & Compiler specifics for Texas Instruments MSP430 CPUs and Rowley compiler for MSP430 Document Rev.

Cortex-M3/M4 Software Desig ARM

embos Real-Time Operating System CPU & Compiler specifics for Texas Instruments using TI Code Composer for MSP430

embos Real Time Operating System CPU & Compiler specifics for RENESAS SH2 CPUs and RENESAS HEW4 Document Rev. 1

ARM Cortex core microcontrollers 3. Cortex-M0, M4, M7

An unrivalled feature-set and unprecedented integration

Software Design Challenges for heterogenic SOC's

ARM Processor Architecture

Cortex-A9 MPCore Software Development

Preemptive Scheduling

ARM. Cortex -M7 Devices. Generic User Guide. Copyright 2015 ARM. All rights reserved. ARM DUI 0646A (ID042815)

Lab 3a: Scheduling Tasks with uvision and RTX

embos Real Time Operating System CPU & Compiler specifics for ARM core with ARM RealView Developer Suite 3.0 Document Rev. 1

Chapter 4. Enhancing ARM7 architecture by embedding RTOS

Cortex-M Processors and the Internet of Things (IoT)

Introduction to Armv8.1-M architecture

ECE254 Lab3 Tutorial. Introduction to Keil LPC1768 Hardware and Programmers Model. Irene Huang

embos Real Time Operating System CPU & Compiler specifics for RENESAS SH2A CPUs and KPIT GNU compiler Document Rev. 1

Experiment 3. Interrupts. Hazem Selmi, Ahmad Khayyat

AN4838. Managing memory protection unit (MPU) in STM32 MCUs. Application note. Introduction

embos Real-Time Operating System CPU & Compiler specifics for Renesas RX using Renesas CCRX compiler and e2studio

IAR PowerPac RTOS for ARM Cores

EE458 - Embedded Systems Exceptions and Interrupts

ARM RTX Real-Time Operating System A Cortex-M Optimized RTOS that Simplifies Embedded Programming

Contents of this presentation: Some words about the ARM company

Debugging with System Analyzer. Todd Mullanix TI-RTOS Apps Manager Oct. 15, 2017

Chapter 5. Introduction ARM Cortex series

Course Introduction. Purpose: Objectives: Content: 27 pages 4 questions. Learning Time: 20 minutes

ARM Processors for Embedded Applications

Last 2 Classes: Introduction to Operating Systems & C++ tutorial. Today: OS and Computer Architecture

CISC RISC. Compiler. Compiler. Processor. Processor

Designing, developing, debugging ARM Cortex-A and Cortex-M heterogeneous multi-processor systems

Lecture 2: September 9

ARMv8-A Software Development

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

NXP LPC4000: Cortex -M4/M0 Lab

Transcription:

ARM Cortex-M and RTOSs Are Meant for Each Other FEBRUARY 2018 JEAN J. LABROSSE

Introduction Author µc/os series of software and books Numerous articles and blogs Lecturer Conferences Training Entrepreneur Micrium founder (acquired by Silicon Labs in 2016) Embedded Systems Innovator Embedded Computer Design Innovator of the Year award (2015) Jean.Labrosse@SiLabs.com www.silabs.com/ew2018 2

What Is an RTOS? - Multitasking Software that manages the time of a CPU Application is split into multiple tasks The RTOS s job is to run the most important task that is ready-to-run 3

What Is an RTOS? s Each task: Is assigned a priority based on its importance Its own set of CPU registers (Thinks it has the CPU all to itself) Requires a stack Manages its own variables, arrays and structures Possibly manages I/O devices Contains YOUR application code CPU Registers (CPU+FPU+MPU) I/O Device(s) (Optional) (Priority) Stack (RAM) Variables Arrays Structures (RAM) 4

What Is an RTOS? Event Driven High Priority Wait For Event Event Occurs void (void) { initialization; while (1) { Wait for event to occur; Perform task operation; } } Low Priority 5

What Is an RTOS? Preemptive Scheduling Signal ISR Event Occurs RTOS Resumes High Priority Wait For Event RTOS Resumes Low Priority Low Priority 6

ARM Cortex-M - Introduction A family of 32-bit processors Introduced in 2004 RISC architecture Many derivatives Cortex-M0/M0+ Cortex-M3 (MPU) Cortex-M4 (MPU, FPU, DSP) Cortex-M7 (MPU, FPU, DSP, Cache) Cortex-M23 (MPU) Cortex-M33 (MPU, FPU, TrustZone) ARMv6-M ARMv7-M ARMv7-M ARMv7-M ARMv8-M ARMv8-M The most popular CPU architecture in the world! 7

ARM Cortex-M Features Summary Privileged / non-privileged modes Mandatory NVIC Support of nka and KA Easy to disable/enable interrupts Dedicated stack for ISRs Exception handlers / ISRs can be written in C MPU ARMv8-M Stack Limit Registers TrustZone Dual MPU CoreSight Debug Port Tail chaining Dedicated timer for RTOS tick Dedicated context switch handler CLZ for scheduling Low-power mode via WFI 8

ARM Cortex-M - Features Privileged / non-privileged modes System code (ISRs, Some s) runs in privileged mode Enable/disable interrupts (both at the CPU and NVIC) Changing MPU (if present) settings s run with limited privileges Mandatory NVIC (Nested Vectored Interrupt Controller) Same for all Cortex-Ms Supports up to 256 exception/interrupt sources Each exception/interrupt can be assigned a priority Support of nka and KA nka (non-kernel Aware) have near immediate response KA (Kernel Aware) interact with tasks 9

ARM Cortex-M - Features Easy to disable/enable interrupts KA_InterruptDisable: Save current BASEPRI; // Save current interrupt disable level Set BASEPRI to 0x40; // Set nka boundary KA_InterruptsEnable: Set BASEPRI to saved value; // Restore previously saved interrupt level Dedicated stack for ISRs s uses the PSP (Process Stack Pointer) Half of the CPU registers are pushed onto the PSP upon entering the ISR Half of the FPU registers are pushed onto the PSP (if an FPU is present) Support of Lazy Stacking ISRs use the MSP (Main Stack Pointer) Avoids having to oversize the stack of each task for ISR code PSP Stack MSP ISR Stack 10

ARM Cortex-M - Features Exception handlers / ISRs can be written in C void MyISR (void) { // ISR code } Tail chaining Dedicated timer for RTOS tick (SysTick) 24-bit hardware timer reserved for RTOSs Dedicated context switch exception handler (PendSV) Runs at the lowest priority 11

ARM Cortex-M - Features CLZ for scheduling 0 8 16 24 31 0 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 8 Zeros Highest Priority Ready Bitmap of Priorities that are Ready-to-Run Low-power mode via WFI (Wait-For-Interrupt) void OSIdle (void) { while (1) { WFI(); // Enter Low Power Mode } } 12

ARM Cortex-M - MPU Process separation Prevent tasks from corrupting stack or memory of other tasks Prevent unprivileged tasks from accessing peripherals Prevent execution out of RAM Prevents code injection attacks MPU registers loaded at context switch 13

ARM Cortex-M ARMv8-M TrustZone TM Isolation of code/data Improve security Stack limit registers Stack overflow detection Dual MPU Non-Secure Secure One for non-secure and one for secure MSP ISR Stack MSP ISR Stack Stack MSPLIM Stack MSPLIM PSP PSP PSPLIM PSPLIM 14

ARM Cortex-M - Debug Port Core debugging: Halting Single stepping Resume Reset USB or Ethernet Segger J-Link JTAG Cortex-M Debug Cortex-M Port R/W Memory or I/O Register accesses Up to 8 hardware breakpoints Up to 4 hardware watchpoints Optional instruction trace Data trace Instrumentation trace (printf() like) 32 channels R/W Profiling counters CPU PC sampling On-the-fly memory and I/O accesses Can be a security risk for deployed systems though 15

ARM Cortex-M Debug Port Micrium s µc/probe TM Allows for tools to monitor an embedded system non-intrusively Memory or I/O values can be displayed or changed LIVE and graphically Live RTOS awareness state stack usage CPU usage Run counters Interrupt disable time Kernel objects Etc. www.micrium.com 16

ARM Cortex-M Debug Port Segger s SystemView TM Displays the execution profile of RTOS-based systems Displayed live Trigger on any task or ISR Visualizing the execution profile of an application Helps confirm the expected behavior of your system Measures CPU usage on a per-task basis Min/Max/Avg task run time Counts the number of task executions Display the occurrence of events in your code Traces can be saved for post-analysis or record keeping www.segger.com 17

Conclusion ARM s Cortex-M was designed from the get-go to be RTOS friendly Privileged / non-privileged modes Mandatory NVIC Support of nka and KA Easy to disable/enable interrupts Dedicated stack for ISRs Exception handlers / ISRs can be written in C Tail chaining Dedicated timer for RTOS tick Dedicated context switch handler CLZ for scheduling Low-power mode via WFI MPU ARMv8-M (Stack Limit Registers, TrustZone, Dual MPU) CoreSight debug port Once an RTOS is ported to a Cortex-M, the RTOS works on all Cortex-M From any manufacturer 18

Thank you! SILABS.COM