ZEPH 101 - Foundations of Zephyr RTOS Real Time C Programming
Duration: 5 Days
Intended Audience
Attendees are expected to be proficient C programmers and have a good working knowledge of Linux.
Introduction
The emphasis in this course is on programming with the Zephyr RTOS Kernel Services.These days the term Real-Time Operating System (RTOS) is used when referring to an operating system designed for use in embedded microprocessors or controllers. The Real Time part refers to the ability to implement applications that can rapidly responding to external events in a deterministic and predictable manner. RTOS based applications have to meet strict deadline constraints whilst meeting the requirements of the application. One way of ensuring that urgent operations are handled reliably is to set task priorities on each task and to assign higher priorities to those tasks that need to respond in a more timely manner.
Another feature of real time applications is the careful design and implementation of the communication and synchronization between the various tasks. The Zephyr RTOS was developed by Wind River Systems, and subsequently open sourced. Its design and implementation are oriented towards the development of time critical IoT (Internet of Things) and IIoT (Industrial Internet of Things) applications,and, consequently it has a rich feature set for building both wireless and wired networking applications. However, with a rich feature set comes a fairly steep learning curve.
This course covers the foundations of programming embedded systems applications using Zephyr's Kernel services. The course will be based on the NRF52840-DK and the Phytec Reel development kits. After introducing the Zephyr architecture as well as the Zephyr build and configuration processes it will focus on multi-tasking and interprocess communication using the Zephyr Kernel Services API. By analogy with embedded Linux courses this course will akin a Linux course that focuses on application development using the Posix API. In this case, however, it will be the Zephyr Kernel Services API that will be the API being used as well as the Posix API features supported by Zephyr.
Course Overview
Course Outline
The course will cover- Scheduling, Interrupts and Synchronisation
- Data Passing
- Memory Management
- Timing and timers
- Interrupt handlers
- Advanced programming patterns and idioms
- Object oriented C programming design patterns and idioms
- State machines - Finite, Extended, Statecharts
The course will, also, include coverage of
- The ARM Cortex-M0 and Cortex-M4 architectures
- Concepts and Patterns of Real-Time multitasking
- Understanding of Real-Time constraints
- Determinism
- Preemption
- Interrupts
- An overview of the Zephyr RTOS architecture
- Various Zephyr services and APIs
- An understanding of the Zephyr West build meta tool, CMake, Ninja and make
- Developing applications using Eclipse CDT with the Eclipse Plug-in for Zephyr
Suitable for which kinds of attendee ?
This course is for software engineers, field engineers and (project) managers planning to build relatively sophisticated IoT and IIoT applications running on resource constrained ARM Cortex M0, M4 systems.
Prerequisites
Attendees must be experienced C programmers with a good basic knowledge of embedded processor architectures and the application of embedded programming concepts.
Detailed Course Outline
- Overview of the Cortex-M Architecture
- Cortex Mx MPU Architecture Overview
- Stacks and stack pointers
- Running-modes and Privilege Levels
- Systick Timer rationale and uses
- Exception/Interrupt Mechanism - An Overview
- Interrut entry and return
- Implementation of interrupt handlers
- More advanced data structures and algorithms programming - a refresher
- Linked lists (singly and doubly linked)
- Circular buffers and circular lists - FIFOs
- Stacks - LIFOs
- Object oriented patterns and idioms in C
- Finite state machines - logic driven and data driven
- Extended finite state machines
- Statecharts - an overview
- Building Zephyr Applications
- Setting up a Command Line Zephyr Developmnt Environment on Linux
- Intensive overview of GIT
- Intensive overview of the West metat tool
- Intensive introduction to CMake
- Overview of make and ninja
- Overview of Cross Compilation and the Zephyr SDK
- Intensive overview of kernel configuration and KConfig
- Intensive overview of Device Tree
- Compiling application code
- Flashing code onto a target board
- Real-Time systems - Architectures and Programming Patterns
- Essential Real-Time Concepts - Hard vs. Soft real time
- Essential Real-Time Concepts - Hard vs. Soft real time
- Requirements analysis and design of real time systems - an overview
- Advantages of working with an embedded RTOS
- Multi-tasking aspects of Real Time systems analysis and design
- Task scheduling and pre-emption patterns used in Real Time Operating Systems
- RTOS intertask communication mechanisms and patterns
- Layered structure of Zephyr RTOS based applications
- Scheduling, Interrupts and Synchronisation
- Threads
- Scheduling
- System Threads
- Workqueue Threads
- Task lifecycles - creating and managing tasks
- The "forever loop" design pattern
- Interrupt driven vs. polling vs. hybrid application designs
- Polling API
- Interrupts
- Inter-process communication
- Semaphores and Mutexes
- Data passing - FIFO, LIFO, Stack
- Mailboxes
- Task mutual exclusion design patterns
- Critical sections
- Deadlocks and Priority Inversion
- Overview of Symmetric Multiprocessing (SMP) and Zephyr support for SMP
- Data passing and data sharing patterns
- Producer consumer scenarios
- Dining philosopher's case study - deadlock, livelock and starvation
- Workqueues
- Memory Management
- Memory Heaps
- Memory Slabs
- Memory Pools
- Memory based interprocess communication
- Timers and Timing
- Overview of Kernel Timing
- Timers and their uses
- Timer and workqueue coding patterns and idioms
- Interrupt handling patterns and idioms
- Deferred interrupt processing
- Tasks utilising interrupt synchronisation
- Queues and Interrupt Service Routines (ISRs)
- Interrupt nesting considerations
- One shot and auto-reload timer design patterns and idioms
- Memory management design patterns and idioms
- Buddy system
- Multi-level
- Thread safe
- Free memory monitoring and error handling
- Stack monitoring