DEV Community

砂田沙耶
砂田沙耶

Posted on • Edited on

Introducing SPIKE-RT: The C Language Software Platform for LEGO SPIKE Prime

Overview
This article introduces SPIKE-RT, a software platform that enables C language programming for LEGO SPIKE Prime. Unlike existing platforms that primarily use MicroPython, SPIKE-RT provides a real-time operating system (RTOS) environment based on TOPPERS/ASP3, allowing for real-time programming and efficient hardware control. This makes it a valuable option for developers who require high performance and precise control in their SPIKE Prime projects.

What is SPIKE-RT?
SPIKE-RT is a real-time operating system (RTOS) based software platform designed for LEGO SPIKE Prime, developed as the successor to EV3RT. It is built on TOPPERS/ASP3 RTOS, providing a C language programming environment under the MIT license. SPIKE-RT aims to enable real-time programming and enhance control applications' reliability and performance on LEGO SPIKE Prime.
Image description

What is TOPPERS/ASP3?
TOPPERS/ASP3 is an open-source RTOS targeting embedded systems that require high reliability, safety, and real-time performance. It extends the μITRON 4.0 specification and supports preemptive multitasking with priority-based scheduling. Its architecture is designed to maintain real-time properties while facilitating complex application development.

Comparison with Existing Software Platforms

  • LEGO Education SPIKE App: The official platform that provides a programming environment using MicroPython and Scratch. It appears to be based on a MicroPython runtime.
  • Pybricks: An open-source platform for LEGO devices that supports programming using MicroPython. Image description

Both are based on the MicroPython runtime. Compared to SPIKE-RT, the following issues can be considered:

  • Limitations in Language Extensibility: Existing software assets written in C cannot be reused.
  • Constraints in Real-Time Performance: Issues such as garbage collection can affect real-time behavior. SPIKE-RT enables real-time programming with C, allowing the reuse of existing C software assets and supporting the development of applications with real-time requirements.

Device Support

SPIKE-RT supports a wide range of devices in the LEGO SPIKE Prime ecosystem:

Hub Internal Devices: Matrix LED, Single LED, Buttons, Accelerometer/Gyroscope (IMU), and Speaker. While external flash memory is not supported.

  • PUP (Powered Up) Devices: Color Sensor, Distance Sensor, Force Sensor, and Motors.

User Interface of SPIKE-RT
API Support:

  • TOPPERS/ASP3 API for real-time control
  • C Standard Library (Newlib)
  • SPIKE API for controlling LEGO SPIKE Prime devices Communication Interfaces:
  • Serial communication through PUP Port F (USART), USB Virtual COM Port, and Bluetooth Serial, all accessible via standard C I/O functions (fprintf()/fscanf()). Development Environment:
  • Compiler: GCC
  • Build System: GNU Make
  • Programming Method: USB DFU SPIKE-RT's user interface provides a flexible and familiar development environment for C programmers, supporting real-time device control and communication.

To see more
If you want to see a demonstration of SPIKE-RT in action, please refer to the following.

Reference
This article is based on information from https://github.com/spike-rt/materials/tree/main/2023-03-11_OSC2023OnlineSpring.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →