jnaulet / OpenPicoRTOS

Very small, safe, lightning fast, yet portable preemptive RTOS with SMP support
MIT License
46 stars 4 forks source link
8051 arduino arm avr c2000 c28x cortex-m mips pic32 powerpc raspberry raspberry-pi-pico risc-v riscv rtos smp tinyavr vle

picoRTOS

OpenPicoRTOS Latest Release Commits since

Very small, safe, lightning fast, yet portable preemptive RTOS with SMP support.

Quick Presentation

picoRTOS is a small hard RTOS with as little overhead as humanly possible.

Table of contents

  1. Book of requirements
  2. How to use
  3. API Documentation
  4. Supported architectures
  5. Featured devices
  6. Working principle
  7. Inter-processus communication
  8. Shared priorities
  9. Interrupt management
  10. Staging tree
  11. Featured demos

Book of requirements

OpenPicoRTOS has been designed with these requirements in mind:

More information here: https://github.com/jnaulet/OpenPicoRTOS/blob/main/etc/Requirements.md

How to use

Step1: Preparation of your project

To create a project compatible with OpenPicoRTOS you first need to add a specific kind of Makefile to your project.
You can find a very basic template here: https://github.com/jnaulet/OpenPicoRTOS/blob/v1.9.x/etc/Makefile.template

Step2: configuration of your project

Simply type:

# make menuconfig

screenshot

And configure your project according to your needs. You can find a lot of examples in the demo directory.

Step3: Compilation of your project

# make

Step4: Static analysis of your project

# make staticcheck

or, alternatively:

# make splint
# make cppcheck

Bonus: all availables targets

Using the template makefile automatically offers you access to a new set of targets for the OpenPicoRTOS build system, directly in your project directory:

Cleaning targets:
  clean           - Remove most generated files but keep the config and
                    enough build support to build external modules
  mrproper        - Remove all generated files + config + various backup files
  distclean       - mrproper + remove editor backup and patch files

Configuration targets:
  config          - Update current config utilising a line-oriented program
  nconfig         - Update current config utilising a ncurses menu based program
  menuconfig      - Update current config utilising a menu based program
  xconfig         - Update current config utilising a QT based front-end
  gconfig         - Update current config utilising a GTK based front-end
  oldconfig       - Update current config utilising a provided .config as base
  localmodconfig  - Update current config disabling modules not loaded
  localyesconfig  - Update current config converting local mods to core
  silentoldconfig - Same as oldconfig, but quietly, additionally update deps
  defconfig       - New config with default from ARCH supplied defconfig
  savedefconfig   - Save current config as ./defconfig (minimal config)
  allnoconfig     - New config where all options are answered with no
  allyesconfig    - New config where all options are accepted with yes
  allmodconfig    - New config selecting modules when possible
  alldefconfig    - New config with all symbols set to default
  randconfig      - New config with random answer to all options
  listnewconfig   - List new options
  oldnoconfig     - Same as silentoldconfig but set new symbols to n (unset)

Other generic targets:
  all             - Build target

Test targets:
  check           - Run static analysis on all basic platforms + unit tests

Static analysis targets:
  splint          - Run splint -checks on the source code
  cppcheck        - Run cppcheck --enable=all on the source code
  staticcheck     - Run both previous checks

  make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build

API Documentation

HTML documentation of the complete API is available in the documentation directory and at the following address: https://jnaulet.github.io/OpenPicoRTOS

Supported architectures

Single core

Multi-core SMP

Simulation

Featured devices

Working principle

On every new cycle (tick), picoRTOS stops the execution of the current task and runs the highest priority task available.
A few criterias make a task available for scheduling, it has to be:

Any syscall (picoRTOS_schedule, picoRTOS_sleep or picoRTOS_sleep_until) will allow picoRTOS to run the next highest priority task available until it reaches idle or a new tick occurs and the cycle starts over.

Task execution order goes from highest (0) to lowest (CONFIG_TASK_COUNT - 1) priority.

Example:

tick: prio0 -> prio1 -> prio2 -> ... (towards idle)   
tick: prio0 -> prio1 -> prio2 -> ... (towards idle)
...

No memory management is offered, everything is static, which makes the static analyzer's job much easier for critical applications.

Inter-processus communication

The following IPCs are provided:

Shared priorities

Version 1.7 introduces shared priorities for tasks, a.k.a round-robin scheduling.

When several tasks share the same priority, the order of execution (highest to lowest priority) doesn't change, but these tasks will be executed alternatively, on a tick modulo basis.

Example with 2 tasks (B & C) sharing a priority of 1:

tick 0: taskA (prio 0) -> taskB (prio 1) -> taskD (prio 2) -> ...    
tick 1: taskA (prio 0) -> taskC (prio 1) -> taskD (prio 2) -> ...  
tick 2: taskA (prio 0) -> taskB (prio 1) -> taskD (prio 2) -> ...  
tick 3: taskA (prio 0) -> taskC (prio 1) -> taskD (prio 2) -> ...  
...

Interrupt management

Version 1.5 introduces contextual interrupt management as an experimental feature.

All architectures are supported (at least partially) at the moment.

This feature should be used with care, as interrupts tend to destroy the real-time part in "RTOS".

Staging tree

Version 1.8 introduces the staging tree.

This tree contains code that builds & fits the book of requirements but could not be tested for one reason or the other.

This code should be considered highly experimental until validation.

Featured demos

Basic demo code is provided for the following boards:

A portability demo is available in demo/amigaball-lcd and works with the follwing boards (+0.96" LCD):