Bern RTOS: Kernel Software Requirements Specification

Title Image

Authors

  • Stefan Lüthi

License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

Introduction

Purpose

This document specifies and tracks the status of the requirements for all components that make up the Bern RTOS kernel. Other parts of the Bern RTOS are not part of this SRS.

Intended Audience

This document provides the Bern RTOS maintainer a complete set of features that are to be implemented tested. Users of the Bern RTOS can look-up which features are planned and request new ones. There is a GitLab issue for every functional requirement. Issues are used to discuss the content of a requirement and contain additional information for development.

To request a new requirement you can create an issue here. To change of the current behavior of the kernel create an enhancement issue here. Issues are tracked on GitLab but you can also use your GitHub or BitBucket account to log in.

Be advised that feature requests might be deferred until the end of Stefan Lüthi (@luethi) master thesis (summer 2022).

In general this document intends serve as a summary what the Bern RTOS can and will be able to do and why it is part of the RTOS.

Product Scope

The kernel is the core part of any RTOS. It schedules tasks, enables communication between them and manages resources. The Bern RTOS kernel aims to make highly concurrent applications safer than a bare-metal implementation.

Requirement State

A requirement can be in one of the following states:

  1. to review: The requirement was recently added and needs discussing first.

  2. planned: The implementation of the requirement is planned within the current project scope.

  3. done: The requirement is fulfilled (implemented and tested).

  4. invalid: The requirement is no longer relevant or valid.

Requirements are grouped by topic and represented with an epic, which can have one of three states:

  1. draft: All requirements within this epic are to be reviewed.

  2. active: The epic is active. The requirement state applies.

  3. inactive: The epic is no longer relevant or valid. All requirement states are invalid.

Acronyms

IPCInter-Process Communication
MPUMemory Protection Unit
ROMread-only memory
RTOSreal-time operating system
SRSsoftware requirements specification

Overall Description

Product Perspective

The objective of the Bern RTOS project is to implement a safe and secure RTOS for microcontrollers from scratch in the Rust programming language. The core part of the RTOS is the kernel. The figure below shows the kernel components and interfaces to other parts of the system.

Kernel Architecture Black: kernel components and interfaces, gray: external components

Product Functions

The kernel provides features to:

  • Schedule tasks
  • Synchronize resource accesses and tasks
  • Send messages between tasks
  • Use dynamic memory (heap)
  • Separate safe and unsafe code
  • Protect access of peripherals
  • Print log messages

User Personas

  • Maintainer: Project maintainer contribute to the Bern RTOS codebase. Their interest is in making embedded systems safe and secure.

  • Maker: A hobbyist who wants to write applications quickly without any fuss. The maker expects an RTOS that just works, supports the major platforms and provides many examples.

  • Developer: Developers use the Bern RTOS in products because it provides features that increase the safety and security of the overall system. They expect the kernel to run stable and with minimal overhead. The API documentation must be complete and examples must also cover complex scenarios.

  • Company: A company is interested in profit and in a safe/secure system. It will only use the Bern RTOS if safety/security features are built-in and thus can safe time in the development process. A company also expects minimal memory footprint in order for the kernel to run on low-cost hardware.

Operating Environment

The kernel is intended to run on microcontrollers. In contrast to general purpose operating systems the kernel cannot rely on memory management unit.

User Documentation

The kernel documentation consists of:

Assumptions and Dependencies

Memory Protection Unit (MPU)

It is assumed that a microcontroller provides a mechanism that allows the kernel to trap access from unprivileged tasks to restricted memory sections. This hardware feature is required for memory partitioning.

HAL Wrapper

The peripheral manager aims to restrict access to peripherals and shared buses. The manager must work with different HALs. Thus, it is assumed that Rust generics will allow for easy integration of different HAL into the peripheral manager.

Requirements

Functional Requirements

The functional requirements specify what the kernel is supposed to do. The requirements are grouped by kernel components. Each requirement has a user story and a priority. The acceptance criteria are refined before a sprint in the linked issue. At a later stage test should automatically update the verification status indicator.

F001: Tasks

EpicGitLab Epic
Document Statusactive

Description

A task is an entity of work. It is the basis of any RTOS. A task can be run periodically, on a specific event or only once.

Requirements

IDTitleUser StoryPriorityStatus
F001-1TasksAs a developer, I want to create tasks, so that I can separate independent code sections.highdone
F001-2Task PrioritiesAs a developer, I want to assign priorities to tasks, so that important tasks run on time.highdone
F001-3Task PrivilegesAs a developer, I want to give tasks privileges, so that only certain tasks can access resources.lowto review
F001-4Time SlicingAs a developer, I want the CPU to be shared between tasks with equal priority, so that I don't have to bother with switching active tasks.mediumdone
F001-5Scheduling AlgorithmsAs a developer, I want to select a scheduling algorithm at compile time, so that configure the RTOS to my needs.lowto review
F001-6TicklessAs a developer, I want to disable time slicing in the scheduler, so that I can use the RTOS on ultra low power systems.lowto review
F001-7Async/AwaitAs a developer, I want to use Rusts async/await features, so that I can write code that is easier to understand than with callbacks.lowto review
F001-8Software One-Shot TimerAs a developer, I want to schedule an event at some specific time, so that I can defer an action with little overhead.mediumto review
F001-9Software Repetitive TimerAs a developer, I want to schedule periodic events in some interval, so that I can trigger short actions with little overhead.mediumto review
F001-10Kernel ISRAs a maintainer, I want to handle interrupts in the kernel, so that I can check that context and permissions are correct.mediumdone
F001-11User ISRAs a developer, I want to register interrupt service routines, so that I can handle interrupt driven events.mediumplanned
F001-12Low Latency ISRAs a developer, I want to handle time critical events without kernel interference, so that my system can react with minimal latency.lowto review

Questions

QuestionAnswer

Out of Scope

  • The worst case execution time (WCET) model will not be covered

F002: Synchronization Primitives

EpicGitLab Epic
Document Statusactive

Description

Synchronization primitives provide the most basic and essential form of communication between tasks. They protect resources, synchronize work and trigger actions.

Requirements

IDTitleUser StoryPriorityStatus
F002-1MutexAs a developer, I want that a single resource can only access from one task at a time, so that I can share resources between tasks without data hazards.highdone
F002-2Priority InversionAs a developer, I want no unbounded priority inversion to occur when a tasks tries to access a shared resource, so that a task doesn't starve.mediumplanned
F002-3Counting SemaphoreAs a developer, I want to create an object that can be taken/given a multiple times, so that I can synchronize multiple tasks.highdone
F002-4Event FlagsAs a developer, I want to trigger an action on a combination of events, so that I can react to system events efficiently.lowplanned

Questions

QuestionAnswer

Out of Scope

F003: Message Queues

EpicGitLab Epic
Document Statusactive

Description

Data can be transferred safely between tasks with message queues.

Requirements

IDTitleUser StoryPriorityStatus
F003-1Message QueueAs a developer, I want to send messages from one task to another, so that I can communicate data between tasks.highdone
F003-2Message Queue SizeAs a developer, I want to allocate a queue of fixed size within a task, so that no messages get lost when they're not read immediately.mediumdone
F003-3Message Queue AccessAs a developer, I want to send messages from multiple tasks to one queue, so that the memory overhead from the queues is minimal.mediumdone
F003-4FIFO Message QueueAs a developer, I want the queue to be of FIFO manner, so that the order of messages is preserved.mediumdone
F003-5Reference MessagingAs a developer, I want to send data efficiently, so that large data blocks can be exchanged without excessive overhead of copying data.lowdone

Questions

QuestionAnswer

Out of Scope

F004: Memory Management

EpicGitLab Epic
Document Statusactive

Description

Volatile and non-volatile memory are critical components for safety and security. This component is responsible for managing access to any memory.

Requirements

IDTitleUser StoryPriorityStatus
F004-1Stack OverflowAs a maintainer, I want to trap stack overflows, so that no other task gets corrupted.highdone
F004-2HeapAs a maker, I want to use Rusts dynamic container types, so that I can use modern programming paradigms.mediumdone
F004-3Memory PoolAs a developer, I want to use a deterministic dynamic memory (heap) without fragmentation, so that I don't get fragmentation issues from long run times.mediumdone
F004-4Pool ConfigurationAs a developer, I want to structure the heap at run time, so that I have maximum flexibility in my code.lowdone
F004-5Unsafe IsolationAs a developer, I want to run unsafe libraries in isolation, so that I can use preexisting code without corruption of my safe application.lowto review
F004-6Kernel IsolationAs a maintainer, I want to isolate the kernel memory from user code, so that an error in user code cannot corrupt the whole system.mediumdone

Questions

QuestionAnswer

Out of Scope

F005: Peripheral Management

EpicGitLab Epic
Document Statusdraft

Description

Peripherals are hardware components integrated in the MCU which are not part of the CPU core. They drive board components and form an interface to physical world outside the embedded system. This management component assures that access to the peripherals is easy, safe and secure.

Requirements

IDTitleUser StoryPriorityStatus
F005-1Peripheral AccessAs a developer, I want to choose which parts of the software are allowed to access peripherals at compile time, so that rogue/malicious task destablizes the embedded system.lowto review
F005-2Peripheral SharingAs a developer, I want to share bus interfaces amongst multiple tasks, so that separate drivers for hardware components that run on the same bus.mediumto review
F005-3Power ManagementAs a maintainer, I want the RTOS to track the power state of each peripheral, so that the kernel can select sleep modes autonomously.lowto review
F005-4Embedded HALAs a maker, I want to use the embedded-hal, so that I can use existing device drivers.mediumto review

Questions

QuestionAnswer

Out of Scope

F006: Log

EpicGitLab Epic
Document Statusactive

Description

Logs are essential for system and application debugging. They provide information after a failure occurred even if no debug interface was connected.

Requirements

IDTitleUser StoryPriorityStatus
F006-1Log SourcesAs a developer, I want to post log messages from any part of the application, so that I can track down software bugs.highdone
F006-2Log MessageAs a developer, I want any log message to state its origin, time and severity, so that I can filter irrelevant messages out.highdone
F006-3Log BackendsAs a developer, I want to select the log backends at compile time, so that I can use any hardware interface to output log information.meidumdone
F006-4Log Run Time FilterAs a developer, I want to filter log messages per backend at run time, so that I only receive message that are important for me.lowdone
F006-5Log Compile Time FilterAs a developer, I want to filter log messages at compile time, so that I only the necessary log code is added to flash memory.mediumdone
F006-6RTOS TracingAs a developer, I want the kernel to provide a generic interface for event tracing, so that I can use any software to trace my application.mediumdone
F006-7SEGGER SystemViewAs a developer, I want the tracing backend to support SEGGER SystemView, so that I can use a simple GUI to analyze my application.mediumdone

Questions

QuestionAnswer

Out of Scope

Non-functional Requirements

The non-functional requirements specify how the kernel is supposed to be. These quality attribute apply to all components of the system. They have no definition of done, as non-functional requirements apply for every release.

The priority refers to the importance for the project that the requirement is met. All non-functional requirements should be met, but if two are contradicting the one with higher priority will be preferred.

N001: Modularity

Epic
Document Statusactive

Description

A kernel runs on different platforms. A modular design allows the user to scale the kernel for its application. Modularity also increases flexibility because components can be replaced.

Requirements

IDTitleUser StoryPriority
N001-1Kernel DependenciesAs a maintainer, I want the dependencies between the kernel components to be kept at a minimum, so that I can rewrite/replace components.high
N001-3Application DependenciesAs a company, we want to keep RTOS specific code to a minimum, so we can switch to another RTOS if we need to.low
N001-4HAL InterfaceAs a developer, I want to use my own HAL, so that I can reuse preexisting code.high
N001-5Kernel ConfigurationAs a developer, I want to enable/disable individual kernel components, so that I can tailor the kernel to my needs.medium

Questions

QuestionAnswer

Out of Scope

N002: Hardware

Epic
Document Statusactive

Description

The amount of memory and safety features depend on the MCU in use. A small memory footprint will allow the kernel to run on any system.

Requirements

IDTitleUser StoryPriority
N002-1ST Nucleo SupportAs a maker, I want to run a preconfigured RTOS on an STM32-Nucleo Board, so that I can start coding my application.low
N002-2Flash RequirementsAs a developer, I want to kernel with all components enabled to use < 20kB of flash memory, so that the kernel uses <10% of a medium-sized MCU with 256kB flash memory.medium
N002-3RAM RequirementsAs a developer, I want to kernel with all components enabled to use < 5kB of RAM, so that the kernel uses < 10% of a medium-sized MCU with 56kB RAM.medium
N002-4Min. Flash RequirementsAs a developer, I want to a minimal version of the kernel to use < 5kB of flash memory, so that the kernel uses < 10% of a small-sized MCU with 64kB flash memory.low
N002-5Min. RAM RequirementsAs a developer, I want to kernel with all components enabled to use < 2kB of RAM, so that the kernel uses < 10% of a medium-sized MCU with 36kB RAM.low
N002-6ARMv7E-M SupportAs a company, we want to kernel to support ARMv7E-M (ARM Cortex-M4/M7) MCU with MPU, so that we can choose from many high-performance MCUs and have a stable supply chain.high
N002-7ARMv7-M SupportAs a company, we want to kernel to support ARMv7-M (ARM Cortex-M3) MCU with MPU, so that we can choose from many medium-performance MCUs and have a stable supply chain.medium

Questions

QuestionAnswer

Out of Scope

  • ARMv6-M (ARM Cortex-M0+) support is not of priority for the moment, as its MPU and atomic operation instructions are limited
  • ARMv8-M (ARM Cortex-M23/M33) support will be added at some point in the future
  • RISC-V support is currently not planned, because they have a small market share

N003: Safety & Security

Epic
Document Statusactive

Description

The kernel safety mechanism provide reliable system performance. Its security mechanisms protect the system from attacks on interfaces.

Requirements

IDTitleUser StoryPriority
N003-1Application SecurityAs a developer, I want that code from an unsafe partition cannot corrupt my application.high
N003-2Kernel SecurityAs a maintainer, I want that no code outside the kernel space can crash the kernel.high
N003-3ToolchainAs a maintainer, I want to use Rusts stable toolchain, so that the kernel doesn't rely on unstable language features.medium

Questions

QuestionAnswer

Out of Scope

  • Ferrocene (formerly Sealed Rust) - a Rust subset for safety critical applications - might become a requirement at some point in the future

N004: Timeliness

Epic
Document Statusactive

Description

Embedded systems react to their environment. They must do so in a timely manner, or the system as a whole might become unstable.

Requirements

IDTitleUser StoryPriority
N004-1Task LatencyAs a developer, I want high-priority tasks to be called within 1 us after an event occurs (on an ARM Cortex-M4 @ 72 MHz).medium
N004-2ISR LatencyAs a developer, I want time-critical user ISR to be called within 1 us after the interrupt occurred (on an ARM Cortex-M4 @ 72 MHz).medium

Questions

QuestionAnswer

Out of Scope

N005: Usability

Epic
Document Statusactive

Description

The kernel aims to be easy-to-use, so that new users can accommodate to its API fast and to reduce the number bugs overall.

Requirements

IDTitleUser StoryPriority
N005-1Multi-Threading SyntaxAs a developer, I want to use common Rust multi-threading syntax, so that I can get started easily.high
N005-2Kernel Tool IntegrationAs a developer, I want that kernel tools are integrated into Cargo, so that I can use a system I'm familiar with.low
N005-3ExamplesAs a maker, I want to build my application on existing examples, so that I have a running application with little effort.low

Questions

QuestionAnswer

Out of Scope

Changelog

Requirement changes of the Bern RTOS kernel will be tracked in this document. See Commits in GitLab for details.

v1.2 (2022-08-03)

New Requirements

  • None

Modifications

  • Update issue states

v1.1 (2021-10-27)

New Requirements

  • None

Modifications

  • Add changelog
  • Update issue states and links

v1.0 (2021-04-08)

New Requirements

  • All requirements

Modifications

  • None