Migrate RTX to CMSIS-RTOS

Similar documents
EE4144: Basic Concepts of Real-Time Operating Systems

CODE TIME TECHNOLOGIES. Abassi RTOS. CMSIS Version 3.0 RTOS API

Create an USB Application Using CMSIS-Driver. Klaus Koschinsky Senior Field Applications Engineer

Lab 3b: Scheduling Multithreaded Applications with RTX & uvision

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

Getting Started with MDK. Create Applications with µvision for ARM Cortex -M Microcontrollers

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

Migrating to Cortex-M3 Microcontrollers: an RTOS Perspective

CMPE3D02/SMD02 Embedded Systems

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

VORAGO VA108xx FreeRTOS port application note

INTERRUPT MANAGEMENT An interrupt is a hardware mechanism used to service an event that can be external or internal to

RT3 - FreeRTOS Real Time Programming

CODE TIME TECHNOLOGIES. mabassi RTOS. Porting Document. SMP / ARM Cortex-A9 CCS

Lab 3a: Scheduling Tasks with uvision and RTX

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ARM Cortex-M0 Atollic

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

ArdOS The Arduino Operating System Reference Guide Contents

CODE TIME TECHNOLOGIES. µabassi RTOS. User s Guide

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts

Putting it All Together

Release Notes for ADuCM4x50 Device Family Pack 3.2.0

Lecture 3: Concurrency & Tasking

Short Term Courses (Including Project Work)

real-time kernel documentation

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document C28X CCS

Processes and Multitasking

Micrium µc/os II RTOS Introduction EE J. E. Lumpp

ARM TrustZone for ARMv8-M for software engineers

Introduction to the ThreadX Debugger Plugin for the IAR Embedded Workbench C-SPYDebugger

AN316 Determining the stack usage of applications

Using the FreeRTOS Real Time Kernel

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

GLOSSARY. VisualDSP++ Kernel (VDK) User s Guide B-1

Connectivity Framework Reference Manual

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. 8051/8052 Keil Compiler

Kinetis Software Optimization

Release Notes for ADuCM302x Device Family Pack 3.2.0

Release Notes for ADuCM4x50 Device Family Pack 3.1.2

Implementing Secure Software Systems on ARMv8-M Microcontrollers

Real-Time Programming

AC OB S. Multi-threaded FW framework (OS) for embedded ARM systems Torsten Jaekel, June 2014

Interrupt/Timer/DMA 1

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ATmega128 IAR

COMP 3361: Operating Systems 1 Midterm Winter 2009

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

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ATmega128 GCC

Embedded Systems. 5. Operating Systems. Lothar Thiele. Computer Engineering and Networks Laboratory

AN HONORS UNIVERSITY IN MARYLAND UMBC. AvrX. Yousef Ebrahimi Professor Ryan Robucci

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document. ATmega IAR

Embedded Software TI2726 B. 7. Embedded software design. Koen Langendoen. Embedded Software Group

ARM Cortex-M and RTOSs Are Meant for Each Other

Process Scheduling Queues

embos Real-Time Operating System embos plug-in for IAR C-Spy Debugger Document: UM01025 Software Version: 3.0 Revision: 0 Date: September 18, 2017

L2 - C language for Embedded MCUs

Quadros. RTXC Kernel Services Reference, Volume 1. Levels, Threads, Exceptions, Pipes, Event Sources, Counters, and Alarms. Systems Inc.

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document AVR32A GCC

FreeRTOS X. Task Notifications Semaphores Family Critical Section FreeRTOS Producer Consumer Tasks

Programming Embedded Systems

ARM Cortex core microcontrollers

In Class Assignment 2

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

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

FreeRTOS. Alberto Bosio. February 27, Université de Montpellier Alberto Bosio (UM) FreeRTOS February 27, / 52

CODE TIME TECHNOLOGIES. Abassi RTOS. Porting Document MSP430 GCC

Real Time Kernel v1.1

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

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

Exam TI2720-C/TI2725-C Embedded Software

Cortex-M3/M4 Software Development

embos Real-Time Operating System CPU & Compiler specifics for embos Visual Studio Simulation

Predictable Interrupt Management and Scheduling in the Composite Component-based System

NetBurner s uc/os RTOS Library

Forth and C on the Cortex-M3. Saturday, April 28, 12

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

Outline Background Jaluna-1 Presentation Jaluna-2 Presentation Overview Use Cases Architecture Features Copyright Jaluna SA. All rights reserved

Arm TrustZone Armv8-M Primer

Hands-on Workshop: Freescale MQX and Tower System RTOS Getting Started (Part 2)

Freescale MQX RTOS for Kinetis SDK Release Notes version beta

Concurrent Programming

The components in the middle are core and the components on the outside are optional.

Concurrent Programming. Implementation Alternatives. Content. Real-Time Systems, Lecture 2. Historical Implementation Alternatives.

Micrium OS Kernel Labs

Virtual Machine Design

Contents. List of Figures... vi. List of Code Listings... viii. List of Tables... xi. List of Notation... xii

Background. Virtual Memory (2/2) Demand Paging Example. First-In-First-Out (FIFO) Algorithm. Page Replacement Algorithms. Performance of Demand Paging

Zilog Real-Time Kernel

Modeling Software with SystemC 3.0

embos Real-Time Operating System embos plug-in for IAR C-Spy Debugger Document: UM01025 Software Version: 3.1 Revision: 0 Date: May 3, 2018

Concurrency: Deadlock and Starvation

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

ECE 254/MTE241 Lab1 Tutorial Keil IDE and RL-RTX Last updated: 2012/09/25

VEOS high level design. Revision 2.1 NEC

μc/os-ii Real-Time Kernel for CrossCore Embedded Studio version Release Notes

Micriμm. Getting Started with Micriμm s. Matt Gordon, Sr. Applications Engineer. 9L05I Renesas Electronics America Inc.

Asynchronous Events on Linux

EMBEDDED SOFTWARE DEVELOPMENT. George Hadley 2017, Images Property of their Respective Owners

µc/os-ii Real-Time Kernel for CrossCore Embedded Studio version Release Notes

Faculty of Electrical Engineering, Mathematics, and Computer Science Delft University of Technology

What s An OS? Cyclic Executive. Interrupts. Advantages Simple implementation Low overhead Very predictable

Transcription:

Migrate to CMSIS-RTOS AN264, May 2014, V 1.0 Abstract This application note demonstrates how to migrate your existing based application to the new CMSIS-RTOS layer. Introduction The CMSIS-RTOS API is a generic RTOS interface for Cortex-M processor-based devices. CMSIS-RTOS provides a standardized API for software components that require RTOS functionality and therefore gives serious benefits to the users and the software industry. CMSIS-RTOS provides basic features that are required in many applications or technologies such as UML or Java (JVM). The unified feature set of the CMSIS-RTOS API simplifies sharing of software components and reduces learning efforts. Middleware components that use the CMSIS-RTOS API are RTOS agnostic. CMSIS-RTOS compliant middleware is easier to adapt. The ARM reference implementation of CMSIS-RTOS (CMSIS-RTOS ) is based on the kernel and is part of the CMSIS software pack. Prerequisites MDK-ARM Version 5.00 or above (/mdk5). A Device Family Pack (DFP) for your microcontroller device. Availability can be checked in the MDK5 pack installer or on /dd2.

Migrate from to CMSIS-RTOS Contents Abstract... 1 Introduction... 1 Prerequisites... 1 Differences... 2 Integrating CMSIS-RTOS in your Project for Migration... 3 Kernel Management... 4 NVIC Priority Group Settings... 4 Task Management... 5 Time Management... 6 Event Flag Management... 7 Mailbox Management... 7 Memory Allocation Functions... 7 Mutex Management... 8 Semaphore Management... 8 System Functions... 9 User Timer Management... 9 Revision History... 9 Differences The following table provides an overview of general differences between and CMSIS-RTOS. Time slice Response time is using kernel ticks as the standard unit for measuring periods CMSIS-RTOS CMSIS-RTOS fully relies on milliseconds as this provides a fully qualified timing base without knowing the configuration of a tick -no change- Memory requirements Code < 4KBytes / User Timer: 8 Bytes Code < 5KBytes / User Timer: 20 Bytes Terminology Tasks / Events Threads / Signals Delivery Integrated in MDK4 releases Part of CMSIS software pack System Tasks Init task created by user Main runs as first system task / 1 dedicated task for user timers Priorities Up to 250 numerical task priorities Up to 7 named thread priorities License MDK-ARM EULA BSD 3-clause license 2

Migrate from to CMSIS-RTOS Integrating CMSIS-RTOS in your Project for Migration The following section lists the required steps for migrating an existing project from to CMSIS-RTOS. 1. Create a backup of your project. 2. Replace _Conf.c with _Conf_CM.c. 3. The new configuration file _Conf_CM.c shows up in the project tree under CMSIS. Open it and transfer the following settings from your old configuration to your new configuration. 4. Change the API function calls as explained in the individual functional chapters following. This chart helps to map the configuration settings from the old to the new configuration file: / _Conf.c Number of concurrent running tasks Default Task stack size (See Note 1) Number of tasks with user-provided stack (See Note 2) Check for stack overflow Processor mode for thread execution Timer clock value [Hz] Timer tick value [us] Round-Robin Task switching Round-Robin Task Timeout [ticks] CMSIS-RTOS / _Conf_CM.c Number of concurrent running threads Default Thread stack size Main Thread stack size Number of threads with user-provided stack size Total stack size for threads with user-provided stack Check for stack overflow Run in privileged mode Timer clock value [Hz] Timer tick value [us] Round-Robin Task switching Round-Robin Task Timeout [ticks] Number of user timers Timers Callback Queue size (See Note 3) ISR FIFO Queue size Notes: ISR FIFO Queue size 1) Set the Main Thread stack size to the Task stack size or the user stack size used in the (now obsolete) os_sys_init_user call (see Kernel Management). 2) Remove all the user stack objects allocated in your project for os_tsk_create_user. The total size of all those objects is the value required for Total stack size for threads with user-provided stack. 3) Also enable the User Timers and allocate a sufficient Timer Thread stack size according to worst case stack usage of all timer callback functions. The following chapters cover individual functional blocks and discuss differences. Detailed descriptions of types, functions and arguments are available in the CMSIS-RTOS documentation. Hint: Enable the Text Completion options in Edit -> Settings. Once you included the cmsis_os.h in any module the code completion and function parameter display will be of great help when integrating the new CMSIS- functions. 3

Migrate from to CMSIS-RTOS Kernel Management os_sys_init os_sys_init_user os_sys_init_prio CMSIS-RTOS -obsolete- -obsolete- -obsolete- CMSIS-RTOS s first thread is main. You can move all code from the initialization task to main function replacing any os_sys_init* calls. For compatibility reasons, call oskernelinitialize() and oskernelstart() in your main function. This is not required in the current releases of CMSIS-RTOS, but can cause malfunction in future releases or when using a different CMSIS- RTOS compliant RTOS. For example, see the following implementation of main: int main (void) { oskernelinitialize (); // initialize peripherals here // initialize CMSIS-RTOS // create 'thread' functions that start executing, // example: tid_name = osthreadcreate (osthread(name), NULL); oskernelstart (); // start thread execution After system initialization main can be used as a fully functional thread or it can be deleted (see Task Management). If you return from main, as in the above example, the thread will be properly terminated and removed from the thread list. Main cannot be restarted without a system reset after that. NVIC Priority Group Settings The initialization of CMSIS-RTOS reads out the NVIC Priority Group configuration and sets the system handlers to the correct priority. If custom settings of groups are made after the startup code executes, the system may be miconfigured. Make sure that you set the PendSV to the lowest level available after configuration of your custom interrupt priorities and groupings. NVIC_SetPriority(PendSV_IRQn, <new priority>); In the next chapter you will learn how to transfer your task creation to the new thread management of CMSIS RTOS. 4

Migrate from to CMSIS-RTOS Task Management os_tsk_create os_tsk_create_ex os_tsk_create_user os_tsk_create_user_ex os_tsk_delete os_tsk_delete_self os_tsk_pass os_tsk_prio os_tsk_prio_self os_tsk_self isr_tsk_get OS_TID CMSIS-RTOS osthreadcreate osthreadcreate osthreadcreate osthreadcreate osthreadterminate osthreadterminate(osthreadgetid()) osthreadyield osthreadsetpriority osthreadsetpriority(osthreadgetid() osthreadgetid -not availableosthreadid osthreadcreate replaces all variants of os_tsk_create_* in a single function. A major difference is the way tasks are defined and declared. The prototype now carries an optional argument that can be passed by osthreadcreate. The macro osthreaddef statically declares the initial priority level and user stack size for the thread. // task definition: task void taskname (void) { // task create os_tsk_create(taskname); //CMSIS-RTOS thread definition and declaration void ThreadName (void const *arg); osthreaddef (ThreadName, osprioritynormal, 1, 0); void ThreadName (void const* arg) { //CMSIS thread create osthreadcreate(osthread(threadname), NULL); Besides defining and creating tasks vs. CMSIS-RTOS threads, all other thread management tasks can be migrated using the above table. Hint: The task prototype of CMSIS-RTOS now has an optional parameter. This can be freely used to pass any arguments to the task. This might be useful to configure multiple instances of a task to e.g. use different hardware resources, etc 5

Migrate from to CMSIS-RTOS Time Management os_dly_wait os_itv_set os_itv_wait os_time_get CMSIS-RTOS osdelay -not availableosdelay or User Timers oskernelsystick The osdelay function is the only timed wait function in CMSIS-RTOS. os_itv_wait is no longer available but you can recreate this functionality using periodic user timers (see the User Timer section). If a periodic interval task should run on the same as priority the user timer task is configured to, transform that task to a user timer callback. If multiple periodic interval tasks at different priorities are used, it is recommended that the callback function only uses ossignalset to wake up the respective thread based on the priorities defined. Example: ostimerid Timer1_Id; void Timer1_Callback (void const *arg) { /* Periodic tasks that formerly where in the interval task or wake up task with ossignalset(id_of_interval_task, 0x0001); */ ostimerdef (Timer1, Timer1_Callback); Timer1_Id = ostimercreate (ostimer(timer1), ostimerperiodic, NULL); ostimerstart (Timer1_Id, 10); 6

Migrate from to CMSIS-RTOS Event Flag Management os_evt_clr os_evt_get os_evt_set os_evt_wait_and os_evt_wait_or isr_evt_set CMSIS-RTOS ossignalclear ossignalclear ossignalset ossignalwait -not availableossignalset ossignalclear combines the functions os_evt_clr and os_evt_get. Thus it is not possible to functionally replace the os_evt_wait_and function from. A special isr_evt_set function is no longer required. ossignalset is safe to be used on interrupt level. Mailbox Management os_mbx_check os_mbx_declare os_mbx_init os_mbx_send os_mbx_wait CMSIS-RTOS osmailalloc(,0) osmailqdef osmailcreate osmailput osmailget isr_mbx_check osmailalloc(, 0) isr_mbx_receive osmailget(, 0) isr_mbx_send osmailput Memory Allocation Functions _declare_box* _init_box* _alloc_box _calloc_box _free_box CMSIS-RTOS ospooldef ospoolcreate ospoolalloc ospoolcalloc ospoolfree 7

Migrate from to CMSIS-RTOS Mutex Management os_mut_init os_mut_release os_mut_wait OS_ID OS_MUT CMSIS-RTOS osmutexcreate(osmutex()) osmutexrelease osmutexwait osmutexdelete osmutexid osmutexdef() Example of Declaration: osmutexdef (MutexIsr); osmutexid mutex_id; mutex_id = osmutexcreate (osmutex (MutexIsr)); Example of Usage: osmutexwait (mutex_id, 0); //Wait until a Mutex becomes available. osmutexrelease(mutex_id); //Release a Mutex. Threads that wait for the same mutex will go into READY state. Semaphore Management os_sem_init os_sem_send os_sem_wait isr_sem_send OS_ID OS_SEM CMSIS-RTOS ossemaphorecreate(ossemaphore()) ossemaphorerelease ossemaphorewait ossemaphorewait ossemaphoredelete ossemaphoreid ossemaphoredef() Example of Declaration: ossemaphoreid semaphore; ossemaphoredef(semaphore); // Semaphore ID // Semaphore definition semaphore = ossemaphorecreate(ossemaphore(semaphore), 1); Example of Usage: val = ossemaphorewait (semaphore, 1); // Wait 1ms for the free semaphore if (val > 0) { // No time-out / semaphore was acquired // The interface is free now ossemaphorerelease (semaphore); // Return a token back to a semaphore 8

Migrate from to CMSIS-RTOS System Functions os_resume os_suspend tsk_lock tsk_unlock CMSIS-RTOS CMSIS-RTOS does not provide System Functions that lock the Kernel like does. This can be considered poor practice. If you want to lock the scheduler for a specific operation, it is recommended that you implement a Supervisor Call (SVC) function. See CMSIS-RTOS User Guide. User Timer Management os_tmr_create os_tmr_kill os_tmr_call CMSIS-RTOS ostimercreate ostimerdelete -not availableostimerstart ostimerstop Revision History May 2014: Initial Version 9