How ashishyesale7/sage-os works
Project Type and Purpose
• SAGE OS is a bare-metal, multi-architecture operating system with an integrated AI subsystem.
• Purpose: Autonomously learn, adapt, and evolve on hardware (Raspberry Pi and x86) via an AI HAT+ accelerator and embedded machine learning.
File Structure
• Top-level directories:
• boot/ → Architecture-specific bootloaders (ARM, x86, RISC-V, multiboot)
• kernel/ → Core kernel in C/Assembly + AI subsystem in C (and Rust in prototype)
• drivers/ → Low-level hardware drivers: UART, I2C, SPI, VGA, AI HAT+
• scripts/ → Build, test, CI/CD, security scanning, ISO creation
• sage-sdk/ → SDK for writing modules/apps against SAGE OS syscalls and AI APIs
• prototype/, minimal/ → Early/reference implementations
• dist/, iso/ → Release artifacts (images, ISOs)
• Build and CI configs: Makefile, Dockerfiles, GitHub Actions workflows.
README for Additional Insights
• Layers: Bootloader → Kernel Core → AI Subsystem → Shell UI → Hardware
• Tech stack: ARM Assembly, C, Rust, Python, QEMU, Docker, CMake, TinyML
• Features: Multi-arch builds, containerized CI, CVE scanning, QEMU testing.
Main Components and Their Roles
a. Hardware Layer
• Raspberry Pi 3/4/5 (ARM) and x86 (i386, x86_64), AI HAT+ accelerator.
b. Bootloader Layer
• boot/*.S: Early assembly stages, multiboot entry, CPU initialization.
c. Kernel Core
• kernel/kernel.c, memory.c, shell.c, stdio.c
• Rust core in prototype (future evolution).
d. AI Subsystem
• kernel/ai/ai_subsystem.c/.h
• Communicates with AI HAT+ via SPI/I2C drivers.
e. Drivers
• drivers/*: UART, VGA, SPI, I2C, Serial, AI HAT+
• Hardware Abstraction Layer for Pi and x86.
f. Shell & CLI
• kernel/shell.c: Exposes commands (meminfo, ai info, reboot).
g. SDK & User Modules
• sage-sdk/: C and Python examples, headers, libraries, model builder, NAS trainer.
h. Build & Test Infrastructure
• scripts/, Dockerfiles, Makefile, GitHub workflows, QEMU runner.
i. Security & CI/CD
• CVE scan scripts, GitHub Actions for code quality, security, multi-arch builds.
Relationships and Data Flow
• Bootloader → Loads Kernel Core into memory → Initializes Drivers → Starts AI Subsystem → Launches Shell
• Shell commands invoke kernel services and AI APIs → Drivers mediate hardware access → AI Subsystem may trigger reconfiguration.
• Build scripts cross-compile per architecture and package images → Docker/GitHub CI runs builds, tests, security scans → Generates artifacts in dist/ and build-output/.
Architectural Patterns & Principles
• Layered Modular Architecture: Clear separation Boot → Kernel → Drivers → Subsystems → SDK.
• Hardware Abstraction: Single driver API for multiple architectures.
• Cross-Compilation & Containerization: Build once, deploy everywhere.
• Self-Adaptive AI Loop: Monitoring → Inference → Reconfiguration.
Detail
• Subsystem, its language (C, Assembly, Rust), and its build artifacts (ELF, IMG, ISO).
• Interactions with QEMU for emulation and Docker for containerized builds.
• Security scanning step between CI and release artifact generation.