kernel_dart 1.0.0
kernel_dart: ^1.0.0 copied to clipboard
Ultra-lightweight bare-metal kernel enabling Dart AOT apps to run directly on embedded ARM/x86 hardware without a traditional operating system.
kernel_dart π¦Ύ #
A revolutionary ultra-lightweight embedded OS kernel (~2 MB) written in Dart.
Run Dart AOT-compiled applications directly on bare-metal hardware β no Linux, no RTOS, no overhead.
Table of Contents #
- Overview
- Why kernel_dart?
- Architecture
- Supported Platforms
- Getting Started
- CLI Reference
- Project Structure
- Memory Layout
- Examples
- Driver Development
- Building from Source
- Roadmap
- Contributing
- License
Overview #
kernel_dart bridges Dart with the world of bare-metal and embedded computing.
Instead of the traditional stack:
[Application] β [Runtime] β [OS Kernel] β [Hardware]
kernel_dart collapses everything into a single 2 MB bootable image:
[Dart AOT Binary + Microkernel] β [Hardware]
Key numbers at a glance:
| Metric | Traditional Linux | kernel_dart |
|---|---|---|
| Disk footprint | 300 MB+ | ~2 MB |
| Boot time | 30 s β 2 min | 100β300 ms |
| RAM (idle) | 50 MB+ | < 4 MB |
| Attack surface | Large | Minimal |
Why kernel_dart? #
| Pain point with traditional approach | kernel_dart solution |
|---|---|
| Full OS required (hundreds of MB) | Microkernel + Dart runtime in 2 MB |
| Slow boot (30 s+) | Direct hardware boot in < 300 ms |
| No direct hardware access | Full memory-mapped I/O, GPIO, UART, I2C |
| Large attack surface | Minimal TCB; Dart type-safety included |
| Complex toolchain | Single CLI: kernel_dart build/flash/run |
Architecture #
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Dart Application Code β
β (IoT logic, controllers, servers β¦) β
ββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌββββββββββββββββββββββββββ
β Dart Runtime Library β
β (Collections, async, isolates, FFI) β
ββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌββββββββββββββββββββββββββ
β kernel_dart Core Libraries β
β GPIO Β· UART Β· IΒ²C Β· SPI Β· Timer Β· Network β
ββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌββββββββββββββββββββββββββ
β Microkernel (512 KB) β
β Memory Manager Β· Scheduler Β· IRQ Handler β
β Device Driver Framework Β· IPC β
ββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌββββββββββββββββββββββββββ
β Hardware Abstraction Layer (HAL) β
β ARM CPU Β· MMU Β· GIC Β· AXI/APB Bus β
ββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
ββββββββββββββββββββββΌββββββββββββββββββββββββββ
β Bootloader (32 KB) β
β CPU init Β· Memory setup Β· Image decompress β
ββββββββββββββββββββββ¬ββββββββββββββββββββββββββ
β
β¬ Hardware
Supported Platforms #
| Platform | Architecture | Status |
|---|---|---|
| Raspberry Pi 3/4 | ARM Cortex-A | β Supported |
| Raspberry Pi Zero | ARM Cortex-A | β Supported |
| STM32F4 | ARM Cortex-M | π Beta |
| STM32H7 | ARM Cortex-M | π Beta |
| ESP32 | Xtensa LX6 | π Beta |
| Generic ARM | ARMv7/ARMv8 | β Supported |
| x86-64 (QEMU) | x86-64 | π§ͺ Experimental |
| RISC-V | RV64GC | π Planned |
Getting Started #
Prerequisites #
# Install Dart SDK (>= 3.0.0)
brew install dart # macOS
sudo apt install dart # Ubuntu/Debian
# Install cross-compilation toolchain
sudo apt install gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
# Install QEMU for emulation
sudo apt install qemu-system-arm
Install kernel_dart CLI #
dart pub global activate kernel_dart
Quick Start #
# Create a new bare-metal Dart project
kernel_dart new my_app --platform raspberry_pi
cd my_app
# Build bootable image
kernel_dart build --target arm64
# Flash to SD card
kernel_dart flash --device /dev/sdb
# OR run in QEMU emulator
kernel_dart emulate --platform raspberry_pi
CLI Reference #
kernel_dart <command> [options]
Commands:
new Create a new kernel_dart project
build Compile and link a bootable image
flash Write image to a physical device
emulate Run image in QEMU
clean Remove build artifacts
info Show platform and memory information
doctor Check toolchain and dependencies
Global options:
--verbose, -v Verbose output
--help, -h Show help
--version Show version
build options:
--target <arch> Target architecture: arm64|arm|x86_64 (default: arm64)
--platform <name> Target board: raspberry_pi|stm32|esp32|generic_arm
--output <file> Output binary path (default: build/kernel.bin)
--optimize Enable AOT optimizations (default: true)
--strip Strip debug symbols
--compress Compress final image with gzip (default: true)
flash options:
--device <path> Block device path, e.g. /dev/sdb
--offset <bytes> Write offset in bytes (default: 0)
emulate options:
--platform <name> Board to emulate
--memory <MB> RAM size in MB (default: 512)
--debug Start GDB server on port 1234
Project Structure #
kernel_dart/
βββ bin/
β βββ kernel_dart.dart # Main executable entry point
β βββ cli.dart # Full CLI implementation
βββ lib/
β βββ kernel_dart.dart # Public library barrel
β βββ src/
β βββ compiler/ # Dart β AOT compilation pipeline
β βββ bootloader/ # Bootloader generators (ARM/x86/UEFI)
β βββ kernel/ # Microkernel (memory, scheduler, IRQ)
β βββ runtime/ # Dart runtime + GC + FFI bridge
β βββ drivers/ # UART, GPIO, Timer, SPI, I2C
β βββ utils/ # Image builder, ELF parser, hex tools
β βββ config/ # Platform config, memory layout
β βββ platform/ # Board-specific support files
βββ native/ # C/Assembly low-level code
β βββ bootloader/ # startup_arm.S, startup_x86.S, linker.ld
β βββ kernel/ # context_switch.S, memory.c, interrupts.c
β βββ drivers/ # uart.c, timer.c
βββ example/ # Runnable bare-metal examples
βββ test/ # Unit tests
βββ doc/ # Detailed documentation
βββ scripts/ # Build, flash, CI scripts
βββ tools/ # QEMU runner, GDB wrapper, profiler
Memory Layout #
0x00000000 βββββββββββββββββββββββββββββββββββ
β Bootloader (32 KB) β
0x00008000 βββββββββββββββββββββββββββββββββββ€
β Kernel Code & Data (512 KB) β
0x00088000 βββββββββββββββββββββββββββββββββββ€
β Dart Runtime (512 KB) β
0x00108000 βββββββββββββββββββββββββββββββββββ€
β Device Drivers (384 KB) β
0x00168000 βββββββββββββββββββββββββββββββββββ€
β App Code (AOT Dart) (512 KB) β
0x001E8000 βββββββββββββββββββββββββββββββββββ€
β Read-Only Data (rodata) β
0x00208000 βββββββββββββββββββββββββββββββββββ€
β Initialized Global Data β
0x00228000 βββββββββββββββββββββββββββββββββββ€
β BSS (zero-initialized) β
0x00248000 βββββββββββββββββββββββββββββββββββ€
β Heap (grows β) β
0x10000000 βββββββββββββββββββββββββββββββββββ€
β Memory-Mapped I/O β
β (UART, GPIO, Timer, I2C, SPI) β
0xFFFFFFFF βββββββββββββββββββββββββββββββββββ
Examples #
Hello World #
import 'package:kernel_dart/kernel_dart.dart';
void main() {
final uart = UARTDriver(baseAddress: 0x09000000, baudRate: 115200);
uart.print('Hello from Dart Bare Metal!\r\n');
final stats = MemoryManager.instance.getMemoryStats();
uart.print('Free RAM: ${stats.freeMemory} bytes\r\n');
while (true) {} // spin
}
Blink LED #
import 'package:kernel_dart/kernel_dart.dart';
void main() {
final gpio = GPIODriver(baseAddress: PlatformConfig.raspberryPi.gpioBase);
const ledPin = 17;
gpio.setDirection(ledPin, GPIODirection.output);
while (true) {
gpio.writeLevel(ledPin, GPIOLevel.high);
BusyWait.milliseconds(500);
gpio.writeLevel(ledPin, GPIOLevel.low);
BusyWait.milliseconds(500);
}
}
IΒ²C Sensor Read #
import 'package:kernel_dart/kernel_dart.dart';
void main() {
final uart = UARTDriver(baseAddress: 0x09000000, baudRate: 115200);
final i2c = I2CDriver(baseAddress: PlatformConfig.raspberryPi.i2cBase);
const bmp280Addr = 0x76;
final chipId = i2c.readByte(bmp280Addr, 0xD0);
uart.print('BMP280 chip ID: 0x${chipId.toRadixString(16)}\r\n');
while (true) {
final raw = i2c.readWord(bmp280Addr, 0xFA);
final temp = (raw >> 4) / 100.0;
uart.print('Temp: ${temp.toStringAsFixed(2)} Β°C\r\n');
BusyWait.seconds(1);
}
}
Building from Source #
git clone https://github.com/your-org/kernel_dart.git
cd kernel_dart
dart pub get
dart run bin/cli.dart doctor # check toolchain
dart run bin/cli.dart build --target arm64 --platform raspberry_pi
Roadmap #
- β ARM64 bootloader generator
- β Microkernel (memory manager, scheduler, IRQ handler)
- β UART, GPIO, Timer, SPI, I2C drivers
- β Raspberry Pi & generic ARM platform support
- β QEMU emulation runner
- β RISC-V support
- β LittleFS lightweight filesystem
- β TCP/IP network stack
- β Secure boot + image signing
- β OTA firmware update
- β GDB JTAG debugging integration
Contributing #
PRs are welcome! Please read CONTRIBUTING.md first.
- Fork the repo
- Create a feature branch (
git checkout -b feat/my-feature) - Commit changes (
git commit -m 'feat: add my feature') - Push and open a Pull Request
License #
MIT Β© 2026 kernel_dart contributors. See LICENSE.