cancel
Showing results for 
Search instead for 
Did you mean: 

SuperTinyKernel (STK) - lightweight embedded multi/single-core multithreading

neutroncode
Associate II

Hi STM Devs!

I would like to introduce a thread scheduling library - SuperTinyKernel (STK).

Its GitHub repo: https://github.com/dmitrykos/stk

You can check capabilities in detail on GitHub but briefly STK can:

  • Soft and hard real-time support: STK supports cooperative scheduling for “soft real-time” tasks, you can also enable hard real-time mode (KERNEL_HRT) for periodic tasks with guaranteed deadlines.
  • Static and dynamic tasks: Define all tasks at startup (KERNEL_STATIC) or allow tasks to be created and destroyed at runtime (KERNEL_DYNAMIC).
  • Low-power friendliness: STK puts MCU into a low-power mode when there are no runnable tasks (task calls Sleep).
  • Tiny footprint: Minimal C++ abstractions (no STL, no heavy namespaces) keep the kernel small and simple.
  • Portability: Supports ARM Cortex-M and RISC-V RV32 MCUs.
  • Multi-core support: Fully implemented for Cortex-M and RISC-V.
  • x86 development mode: Compile & debug your code on a PC before flashing to the MCU, which helps with early testing and unit tests.
  • Open-source License: MIT: Open for commercial, closed-source, open-source - your choice.

There are ready to use STM32 examples for STM32F051 MCU (STM32F0DISCOVERY dev board), STM32F103 (NUCLEO-F103RB dev board), STM32F407 (STM32F4DISCOVERY dev board): 

https://github.com/dmitrykos/stk/tree/main/build/example/project/eclipse/stm

Any questions? Please ask, also you are welcome to participate in STK's GitHub repository.

1 ACCEPTED SOLUTION

Accepted Solutions
Issamos
Lead II

Hello @neutroncode 

Thank you so much for sharing this repo with the community. Hope that ST Create a dedicated space for user’s contribution on the ST Community. This will help users to find helpful examples or inspiration for new projects.

Best Regards.

II

View solution in original post

3 REPLIES 3
Issamos
Lead II

Hello @neutroncode 

Thank you so much for sharing this repo with the community. Hope that ST Create a dedicated space for user’s contribution on the ST Community. This will help users to find helpful examples or inspiration for new projects.

Best Regards.

II

Hi @Issamos

Thank you for a warm welcome! 

STK is probably one of the easiest and fastest ways to add multi-threading to STM32 MCUs for new and existing bare-metal ISR-only projects, it has no board-specific dependencies or portability layers, fits any custom design based on STM32 MCU. Therefore I hope ST Community will find it useful and practical.

Best regards,

Dmitry.

neutroncode
Associate II

Since the initial post there was an active development happening on STK and it has grown to a more convenient tool for embedded development, so wanted to highlight the progress:

  • Scheduling strategies: Besides existing Round-Robin (RR) new scheduling strategies were added: Fixed-Priority (FP, similar to FreeRTOS), Smooth Weighted Round-Robin (SWRR), Rate-Monotonic (RM), Deadline-Monotonic (DM), including Worst Case Reaction Time (WCRT) analysis, Earliest Deadline First (EDF), custom (via ITaskSwitchStrategy). It is probably the only open-source scheduler that has such a rich set of scheduling strategies.

  • Synchronization API: Besides CriticalSection there is a set of synchronization primitives now: SpinLock, Mutex, Event, ConditionVariable, Semaphore, Pipe primitives for inter-task, inter-core synchronization. Synchronization is optional via KERNEL_SYNC kernel mode, so it does not bloat FLASH/RAM.

  • Traceability: STK now supports tracing of tasks scheduling with a SEGGER SystemView.

  • C interface: For C-only projects STK got a fully-featured C interface.

If there are any questions, please ask!