kernel_dart 1.0.0 copy "kernel_dart: ^1.0.0" to clipboard
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 #

  1. Overview
  2. Why kernel_dart?
  3. Architecture
  4. Supported Platforms
  5. Getting Started
  6. CLI Reference
  7. Project Structure
  8. Memory Layout
  9. Examples
  10. Driver Development
  11. Building from Source
  12. Roadmap
  13. Contributing
  14. 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
}
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.

  1. Fork the repo
  2. Create a feature branch (git checkout -b feat/my-feature)
  3. Commit changes (git commit -m 'feat: add my feature')
  4. Push and open a Pull Request

License #

MIT Β© 2026 kernel_dart contributors. See LICENSE.

0
likes
130
points
7
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

Ultra-lightweight bare-metal kernel enabling Dart AOT apps to run directly on embedded ARM/x86 hardware without a traditional operating system.

Repository (GitHub)
View/report issues

Topics

#dart #kernel #embedded #bare-metal #aot

License

MIT (license)

Dependencies

archive, args, collection, crypto, ffi, logging, meta, path, process, yaml

More

Packages that depend on kernel_dart