SuperTinyKernel (STK) - lightweight embedded multi/single-core multithreading for NXP Cortex-M MCUs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SuperTinyKernel (STK) - lightweight embedded multi/single-core multithreading for NXP Cortex-M MCUs

828 Views
neutroncode
Contributor I

Hi NXP Devs!

Not really a question here. 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 any ARM Cortex-M MCU.
  • 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 MCUXpresso examples for NXP K26/K66 MCU (FRDM-K66F dev board) and i.MX RT105 (IMXRT1050-EVKB dev board): https://github.com/dmitrykos/stk/tree/main/build/example/project/nxp-mcuxpresso

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

0 Kudos
Reply
1 Reply

345 Views
neutroncode
Contributor I

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!

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2253453%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ESuperTinyKernel%20(STK)%20-%20lightweight%20embedded%20multi%2Fsingle-core%20multithreading%20for%20NXP%20Cortex-M%20MCUs%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2253453%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20NXP%20Devs!%3C%2FP%3E%3CP%3ENot%20really%20a%20question%20here.%26nbsp%3B%3CSPAN%3EI%20would%20like%20to%20introduce%20a%20thread%20scheduling%20library%20-%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ESuperTinyKernel%20(STK)%3C%2FSTRONG%3E%3CSPAN%3E.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EIts%20GitHub%20repo%3A%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdmitrykos%2Fstk%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fdmitrykos%2Fstk%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSPAN%3EYou%20can%20check%20capabilities%20in%20detail%20on%20GitHub%20but%20briefly%20STK%20can%3A%3C%2FSPAN%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSTRONG%3ESoft%20and%20hard%20real-time%20support%3C%2FSTRONG%3E%3A%20STK%20supports%20cooperative%20scheduling%20for%20%E2%80%9Csoft%20real-time%E2%80%9D%20tasks%2C%20you%20can%20also%20enable%20hard%20real-time%20mode%20(KERNEL_HRT)%20for%20periodic%20tasks%20with%20guaranteed%20deadlines.%3C%2FLI%3E%3CLI%3E%3CSTRONG%3EStatic%20and%20dynamic%20tasks%3C%2FSTRONG%3E%3A%20Define%20all%20tasks%20at%20startup%20(KERNEL_STATIC)%20or%20allow%20tasks%20to%20be%20created%20and%20destroyed%20at%20runtime%20(KERNEL_DYNAMIC).%3C%2FLI%3E%3CLI%3E%3CSTRONG%3ELow-power%20friendliness%3C%2FSTRONG%3E%3A%20STK%20puts%20MCU%20into%20a%20low-power%20mode%20when%20there%20are%20no%20runnable%20tasks%20(task%20calls%20Sleep).%3C%2FLI%3E%3CLI%3E%3CSTRONG%3ETiny%20footprint%3C%2FSTRONG%3E%3A%20Minimal%20C%2B%2B%20abstractions%20(no%20STL%2C%20no%20heavy%20namespaces)%20keep%20the%20kernel%20small%20and%20simple.%3C%2FLI%3E%3CLI%3E%3CSTRONG%3EPortability%3C%2FSTRONG%3E%3A%20Supports%20any%20ARM%20Cortex-M%20MCU.%3C%2FLI%3E%3CLI%3E%3CSTRONG%3EMulti-core%20support%3C%2FSTRONG%3E%3A%20Fully%20implemented%20for%20Cortex-M%20and%20RISC-V.%3C%2FLI%3E%3CLI%3E%3CSTRONG%3Ex86%20development%20mode%3C%2FSTRONG%3E%3A%20Compile%20%26amp%3B%20debug%20your%20code%20on%20a%20PC%20before%20flashing%20to%20the%20MCU%2C%20which%20helps%20with%20early%20testing%20and%20unit%20tests.%3C%2FLI%3E%3CLI%3E%3CSTRONG%3EOpen-source%20License%3A%20MIT%3C%2FSTRONG%3E%3A%20Open%20for%20commercial%2C%20closed-source%2C%20open-source%20-%20your%20choice.%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThere%20are%20ready%20to%20use%20MCUXpresso%20examples%20for%20%3CSTRONG%3ENXP%20K26%2FK66%20MCU%3C%2FSTRONG%3E%20(FRDM-K66F%20dev%20board)%20and%20%3CSTRONG%3Ei.MX%20RT105%3C%2FSTRONG%3E%20(IMXRT1050-EVKB%20dev%20board)%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fdmitrykos%2Fstk%2Ftree%2Fmain%2Fbuild%2Fexample%2Fproject%2Fnxp-mcuxpresso%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fdmitrykos%2Fstk%2Ftree%2Fmain%2Fbuild%2Fexample%2Fproject%2Fnxp-mcuxpresso%3C%2FA%3E%3C%2FP%3E%3CP%3EAny%20questions%3F%20Please%20ask%2C%20also%20you%20are%20welcome%20to%20participate%20in%20STK's%20GitHub%20repository.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2303157%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20SuperTinyKernel%20(STK)%20-%20lightweight%20embedded%20multi%2Fsingle-core%20multithreading%20for%20NXP%20Cortex-M%20M%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2303157%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESince%20the%20initial%20post%20there%20was%20an%20active%20development%20happening%20on%20STK%20and%20it%20has%20grown%20to%20a%20more%20convenient%20tool%20for%20embedded%20development%2C%20so%20wanted%20to%20highlight%20the%20progress%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CP%3E%3CSTRONG%3EScheduling%20strategies%3C%2FSTRONG%3E%3A%20Besides%20existing%20%3CEM%3ERound-Robin%20(RR)%3C%2FEM%3E%20new%20scheduling%20strategies%20were%20added%3A%26nbsp%3B%3CEM%3EFixed-Priority%3C%2FEM%3E%20(FP%2C%20similar%20to%20FreeRTOS)%2C%20%3CEM%3ESmooth%20Weighted%20Round-Robin%3C%2FEM%3E%20(SWRR)%2C%20%3CEM%3ERate-Monotonic%3C%2FEM%3E%20(RM)%2C%20%3CEM%3EDeadline-Monotonic%3C%2FEM%3E%20(DM)%2C%20including%20Worst%20Case%20Reaction%20Time%20(WCRT)%20analysis%2C%20%3CEM%3EEarliest%20Deadline%20First%3C%2FEM%3E%20(EDF)%2C%20custom%20(via%20ITaskSwitchStrategy).%20It%20is%20probably%20the%20only%20open-source%20scheduler%20that%20has%20such%20a%20rich%20set%20of%20scheduling%20strategies.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3ESynchronization%20API%3C%2FSTRONG%3E%3A%20Besides%20%3CEM%3ECriticalSection%3C%2FEM%3E%20there%20is%20a%20set%20of%20synchronization%20primitives%20now%3A%20%3CEM%3ESpinLock%3C%2FEM%3E%2C%20%3CEM%3EMutex%3C%2FEM%3E%2C%20%3CEM%3EEvent%3C%2FEM%3E%2C%20%3CEM%3EConditionVariable%3C%2FEM%3E%2C%20%3CEM%3ESemaphore%3C%2FEM%3E%2C%20%3CEM%3EPipe%3C%2FEM%3E%20primitives%20for%20inter-task%2C%20inter-core%20synchronization.%20Synchronization%20is%20optional%20via%20KERNEL_SYNC%20kernel%20mode%2C%20so%20it%20does%20not%20bloat%20FLASH%2FRAM.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3ETraceability%3C%2FSTRONG%3E%3A%20STK%20now%20supports%20tracing%20of%20tasks%20scheduling%20with%20a%20%3CEM%3ESEGGER%20SystemView%3C%2FEM%3E.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSTRONG%3EC%20interface%3C%2FSTRONG%3E%3A%20For%20C-only%20projects%20STK%20got%20a%20fully-featured%20C%20interface.%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EIf%20there%20are%20any%20questions%2C%20please%20ask!%3C%2FP%3E%3C%2FLINGO-BODY%3E