Hubris is a microcontroller operating system environment designed for deeply embedded systems with high reliability requirements. This article will delve into the design philosophy, functional features, and usage of Hubris.
Design Philosophy of Hubris
The core design goal of Hubris is to provide a safe and reliable operating system environment for resource-constrained embedded systems. It adopts a lightweight design, reducing memory usage and power consumption, while incorporating memory protection mechanisms to effectively prevent system crashes caused by software errors. Hubris is built on a message-passing mechanism, where tasks communicate through messages, avoiding concurrency issues brought by shared memory, thereby enhancing system stability and predictability.
Main Features of Hubris
-
• Lightweight Kernel: The Hubris kernel consumes very few resources, making it suitable for running on resource-constrained microcontrollers. It supports multitasking concurrency and provides core functions such as task scheduling, memory management, and interrupt handling.
-
• Memory Protection: Hubris divides memory space into multiple independent regions through a Memory Management Unit (MMU) or similar mechanisms, preventing interference between tasks. This greatly enhances system reliability and security.
-
• Message Passing: Hubris uses message passing as the primary means of communication between tasks. Tasks interact by sending and receiving messages, avoiding concurrency issues and data races associated with shared memory.
-
• Driver Support: Hubris provides a rich set of drivers supporting various peripherals such as UART, SPI, I2C, ADC, etc. These drivers are meticulously designed to ensure efficiency and reliability.
-
• Scalability: The architecture of Hubris is designed for good scalability, allowing users to add custom tasks and drivers easily. Users can extend the functionality of the system according to their needs.
-
• Debugging Support: Hubris is equipped with a debugger named Humility, facilitating system debugging and testing. Humility supports various debugging methods, such as online debugging, breakpoint debugging, and memory inspection.
Architecture of Hubris
The codebase of Hubris is organized by functional modules, mainly consisting of the following parts:
-
•
app/
: Contains binary files for applications, such as the firmware for Gimlet. -
•
build/
: Includes the build system and related crates. -
•
chip/
: Contains peripheral definitions and debugging support files for various microcontrollers. -
•
drv/
: Contains drivers, including simple driver library crates and complete server binary crates. -
•
idl/
: Contains interface definitions written using Idol. -
•
lib/
: Contains various utility libraries. -
•
stage0/
: Bootloader/Hypervisor mainly used for LPC55. -
•
support/
: Contains some interface and programming support files, such as fake certificates and programmer firmware images. -
•
sys/
: Contains the system parts of Hubris, including the kernel (sys/kern
), shared crates defining ABI (sys/abi
), and user libraries (sys/userlib
). -
•
task/
: Contains reusable tasks that are not drivers. -
•
test/
: Contains the testing framework and binaries for building testing frameworks for various boards. -
•
website/
: Contains the source code for the Hubris website.
Building and Using Hubris
Hubris uses a custom build system instead of directly using cargo build
or cargo run
. The build process is relatively complex, involving cross-compilation for multiple architectures. Developers can use the cargo xtask
command for building, flashing, debugging, and testing.
Conclusion
Hubris is a powerful microcontroller operating system environment that provides reliable solutions for developing deeply embedded systems. Its lightweight design, memory protection mechanisms, message-passing architecture, and robust debugging tools make it an ideal choice for developing high-reliability embedded applications.
Project address: https://github.com/oxidecomputer/hubris