Skip to content
Projects

About

A microkernel os for edge computing and AI, well ported on many platforms

AI & Machine Learning

How these counts are measured

What you can do

  • Microkernel core with scheduling, VM/MMU support, IPC, signals, semaphores, and SMP-aware code paths
  • User-space services including init, core, vfsd, sdfsd, displaymand, xserverd, netd, sshd, telnetd, and httpd
  • Native GUI and desktop stack with framebuffer rendering, themed window managers, and graphical apps
  • Networking tools including ssh, scp, ping, host, HTTPS test tooling, and WebSocket test tooling

Measured star growth

in 24h
+2
in 7 days
+3
in 15 days
+3
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

EwokOS

Language: English | 中文

Ask DeepWiki GitHub commit activity GitHub License

EwokOS is a lightweight microkernel operating system built for edge computing in the AI era, adapted to a wide range of platforms: QEMU, Raspberry Pi families, x86, RISC-V, Qualcomm 8gen3, NVIDIA Jetson Orin Nano, handhelds, and more. EwokOS is not a fork or modification of Linux or any other existing OS — the kernel, user-space services, GUI/window system, and native C library (libewoksys) are all written from scratch for this project; only portable third-party libraries (zlib, wolfssl, FreeType, etc.) and the cross-toolchain runtime are bundled on top. The project combines a small kernel with a large user-space stack — core services, storage, graphics, an X-like desktop, networking, and board-specific drivers — so the system stays elastically composable, and drivers or application modules can be replaced and upgraded at runtime. Standard GPU/compute APIs (GLES2/EGL, Vulkan, OpenCL, and the CUDA-compatible KUDA) with always-present CPU fallbacks let the same app binaries run on every target, up to on-device quantized LLM inference on real boards (see Why EwokOS Fits the AI Era). EwokOS also remains a practical platform for OS learning, system bring-up, and hands-on experimentation.

Author

Misa.Z [email protected]

What This Repository Contains

This repository is the main EwokOS source tree. It contains:

  • The microkernel core and architecture layers
  • Base userland, libc pieces, shell, and system daemons
  • GUI, display, audio, and image libraries
  • An X-like window system and desktop applications
  • Networking tools and services such as SSH, SCP, Telnet, HTTP, and ping
  • Machine-specific ports for QEMU, Raspberry Pi, x86, RISC-V, handhelds, and board variants
  • Extra software through the projects/ submodule (browser, emulators, games, GPU API stacks), plus machine-local apps under hardwares/*/

The build is intentionally machine-centric. Instead of one monolithic top-level build, each target under porting.qemu/ or hardwares/*/ provides its own kernel and rootfs recipes.

Latest Progress

Recent work visible in the current branch includes:

  • Dynamic DMA / contiguous shared-memory allocation: sys_dma and shm_contig are now range constraints over general allocable RAM instead of static carve-outs — contiguous runs are claimed on demand (mm_alloc_contig with page-migration compaction), idle pages stay reusable by every process, and the old multi-block DMA registration API and cacheable-flag variants were removed; sysinfo reports live occupancy instead of configured pool sizes
  • Vulkan on Qualcomm 8gen3 (Adreno 690): the projects/vulkan stack runs real GPU graphics/compute dispatches on the board, and vkolddisp is now a retro CRT terminal wired to /bin/shell; a fullscreen GPU wedge was root-caused to the cooperative rasterizer's one-workgroup-per-textured-triangle dispatch shape and fixed by tessellating fullscreen coverage into a grid mesh (pixel-exact, GPU path kept)
  • Four real GPU back ends now share one OpenGL ES 2.0 / EGL front end: Raspberry Pi 5 (VideoCore VII / V3D 7.1), Raspberry Pi 4/CM4 (VideoCore VI / V3D 4.2, the raspix image), Qualcomm 8gen3 (Adreno 690, mesa freedreno/ir3) and NVIDIA Jetson Orin Nano (GA10B Ampere, a hand-written NIR → sm_87 SASS compiler) — the same GLES apps run on CPU or any of the GPUs without source changes
  • KUDA (projects/kuda): a CUDA-driver-API-compatible compute layer (kuInit/kuModuleLoad/kuLaunchKernel, streams, events, occupancy) with a machine-independent core, a CPU simulation fallback and per-machine BSP back ends; on Adreno 690 its batched/chained compute launches drive quantized LLM inference at ~50 tok/s (Llama-3.2-1B Q4_K_M) and ~15.6 tok/s (Qwen3-4B Q4_K_M), board-measured
  • OpenCL 1.2 (projects/opencl) and Vulkan 1.0 (projects/vulkan) stacks: standard Khronos-style APIs with an always-present CPU device plus a GPU device on machines with a CL compute path (V3D CSD / Adreno); SPIR-V is interpreted on CPU or transpiled to on-device GLSL compute, with pixel-exact CPU fallback outside the GPU subset
  • New machine ports: hardwares/qcom/8gen3/ (Radxa Dragon SC8280XP, UEFI + PXE boot, NVMe rootfs, Adreno 690 GPU + Hexagon NPU) and hardwares/nvidia/orin.nano/ (Jetson Orin Nano Tegra234, UEFI boot, GA10B GPU with the full secure-boot chain and board-verified compute/3D)
  • Runtime dynamic loading (dlopen/dlsym/dlclose) on AArch64: a user-space ELF dynamic loader (libdl) over a new kernel anonymous-mapping window with real per-page W^X permissions, a cache-sync syscall, and a build-time generated host ABI export table — boot-verified by a self-test on porting.qemu (see Dynamic Library Support)
  • Ext3 ported as the default root filesystem: sdfsd now serves journaled, crash-safe ext3, with automatic ext2-compatible fallback when no journal is present; the kernel boot loader reads ext2/ext3 directly
  • SD card write performance improvements, including Raspberry Pi SD driver speed-ups, removal of per-write verification, and write-cache flushing tuned for ext3
  • Display rotation speed-ups via arch-accelerated graph_rotate_to_arch paths (ARM, AArch64, x86) and a faster display daemon
  • Larger projects (browser, macemu, minivmac, nesemu, opengl, video, saver) moved into the new projects/ tree
  • The opengl stack now exposes a standard OpenGL ES 2.0 / EGL API (libGLESv2/libEGL) over portablegl, with real GPU acceleration on Raspberry Pi 5, Qualcomm 8gen3 and Jetson Orin Nano that stays engaged across window resizes
  • macemu HiDPI mode support
  • Simplified, rewritten Makefiles across the system/ build trees

These items come directly from the latest commits in the current checkout and reflect active development rather than historical roadmap text.

Architecture Overview

EwokOS follows a microkernel-oriented design:

  • The kernel handles low-level memory management, scheduling, interrupts, IPC, semaphores, signals, and process state
  • User-space services implement most system behavior, including boot orchestration, service discovery, filesystems, display management, and networking
  • Graphics is built on framebuffer/display services plus an X-like window system
  • Networking is implemented through user-space drivers and daemons
  • Machine ports provide the BSP, boot glue, storage drivers, interrupt/timer setup, and deployment flow for each target

Core Runtime Flow

At a high level:

  1. The kernel boots and initializes MMU, IRQ, DMA/shared memory, scheduler state, and platform services.
  2. The kernel launches /sbin/init.
  3. init starts core user-space services such as core, vfsd, and storage helpers.
  4. Machine-specific init scripts bring up console, GUI, network, and X sessions.
  5. When X is enabled, the default desktop session launches window manager and desktop tools.

Why EwokOS Fits the AI Era

AI-driven development and AI workloads both favor systems that are small, recomposable, and forgiving of rapid change. EwokOS's microkernel design happens to provide exactly that:

  • Elastic system configuration. The kernel stays minimal; almost everything else — filesystems, display, networking, drivers — is a user-space service assembled per target. Each machine port composes its own rootfs from independent recipes (make basic / network / gui / x), so a system can scale from a headless sensor node to a full GPU desktop by adding or removing modules, not by re-architecting the kernel. An AI agent (or a product line) can generate a new device configuration by recombining existing services.
  • Drivers and services that can be replaced at runtime. Drivers are ordinary processes registered with the core service registry, not kernel code. The registry explicitly allows a replacement process to re-register the same service id once the previous owner is gone, so a driver or daemon can be upgraded by dropping in a new binary and restarting it — no kernel rebuild, no reboot, and clients re-discover the service through the same id. A buggy AI-generated driver crashes in user space and can be swapped out, instead of panicking the whole system.
  • Application modules that upgrade themselves. With the dlopen plugin facility (AArch64, kernel-enforced W^X), an application can load new ET_DYN modules from /lib at runtime against a stable host ABI. Shipping a new capability — a codec, an operator kernel, a UI plugin — means copying a .so into the rootfs, not relinking or reflashing the app. Combined with per-service upgrades above, the system supports continuous, piecemeal evolution rather than monolithic image updates.
  • AI workloads already run on-device. The KUDA compute layer drives quantized LLM inference on Adreno 690 (~50 tok/s on Llama-3.2-1B Q4_K_M), the Hexagon NPU has a native test stack, and every GPU API (GLES/Vulkan/OpenCL/KUDA) keeps an always-present CPU back end. The same app binary runs on any target and the hardware only adds speed — a natural fit for heterogeneous edge-AI deployment where the available accelerator varies board to board.
  • A codebase an AI agent can actually own. The kernel is small enough to read end to end, there is no hosted-libc or distro dependency chain, and the QEMU flow gives a complete build → boot → test loop (make && make run) on a laptop. That makes EwokOS a practical substrate for AI-assisted OS development: an agent can understand the whole system, modify a driver or service, and verify the change in an emulator within minutes.

Highlights

  • Microkernel core with scheduling, VM/MMU support, IPC, signals, semaphores, and SMP-aware code paths
  • User-space services including init, core, vfsd, sdfsd, displaymand, xserverd, netd, sshd, telnetd, and httpd
  • Native GUI and desktop stack with framebuffer rendering, themed window managers, and graphical apps
  • Networking tools including ssh, scp, ping, host, HTTPS test tooling, and WebSocket test tooling
  • Multiple machine ports for QEMU, Raspberry Pi families, x86, RISC-V, handheld devices, and special-purpose boards
  • Ext3 root filesystem image generation in-tree as the default (journaled, with ext2-compatible fallback); FAT32 support is also part of the broader stack
  • Real GPU acceleration on four GPU targets — Broadcom VideoCore VI (Pi 4/CM4) and VII (Pi 5), Qualcomm Adreno 690 and NVIDIA GA10B (Ampere) — behind standard GLES2/EGL, Vulkan, OpenCL and CUDA-compatible (KUDA) APIs
  • Runtime dynamic loading (dlopen) of ET_DYN plugin .so objects on AArch64, with kernel-enforced W^X and a POSIX <dlfcn.h> API

Directory Structure

ewokos/
├── README.md
├── LICENSE
├── kernel/
│   ├── dev/                  # Common kernel device headers
│   ├── kernel/               # Kernel core: proc, IPC, VM, scheduler, syscalls
│   ├── lib/                  # Kernel-side helper libraries and ext2/ext3 readers
│   ├── loadinit/             # Early userspace loading helpers
│   └── platform/             # ARM, AArch64, RISC-V, x86 architecture code
├── system/
│   ├── basic/                # Base userland, shell, core services, libc pieces
│   ├── gui/                  # Display, graphics, fonts, audio/image helpers
│   ├── network/              # Network tools, daemons, and related libraries
│   ├── platform/             # Userland platform build rules
│   └── xwin/                 # X-like window system, libs, apps, and WMs
├── porting.qemu/
│   ├── kernel/               # Recommended QEMU virt kernel target
│   └── system/               # Recommended QEMU virt rootfs target
├── hardwares/
│   ├── clockwork/            # Clockwork Pi PicoCalc target
│   ├── lego.ev3/             # LEGO Mindstorms EV3 port
│   ├── miyoo/                # Miyoo handheld port
│   ├── nvidia/               # NVIDIA Jetson Orin Nano port (GA10B GPU)
│   ├── orangepi/             # Orange Pi port
│   ├── qcom/                 # Qualcomm 8gen3 port (Adreno 690 GPU + Hexagon NPU)
│   ├── raspi5/               # Raspberry Pi 5 port and add-ons
│   ├── raspix/               # Raspberry Pi family ports and many overlays
│   ├── virt.riscv/           # QEMU RISC-V virt target
│   ├── x2lite.rk3128/        # RK3128 target
│   └── x86/                  # x86 PC-style target
└── projects/                 # Larger standalone projects: browser, camera, cube,
                              # ereader, games, git, imgui, kuda, llm, macemu,
                              # minivmac, nesemu, nx11, opencl, opengl, re3,
                              # saver, sdl2, video, vulkan

Key Source Directories

  • kernel/kernel/src/: scheduler, process model, IPC, MMU, IRQ, semaphore, signal, syscall dispatch
  • kernel/platform/: architecture-specific boot, interrupt, and MMU code
  • system/basic/sys/: init, core, vfsd, and rootfs/filesystem daemons
  • system/basic/bin/: shell and command-line tools
  • system/gui/: display stack, graphics libraries, font and image support
  • system/xwin/: X client libraries, input helpers, window managers, and desktop apps
  • system/network/: network commands, libraries, and daemons
  • hardwares/*/kernel/: board support packages and per-target boot logic
  • hardwares/*/system/: per-target rootfs packaging, drivers, config, and init scripts
  • hardwares/*/3rd/: board overlays and third-party device integrations

Supported Architectures

Architecture Tool Prefix Notes
ARM32 arm-none-eabi- Used by several classic ARM and embedded targets
AArch64 aarch64-none-elf- Used by porting.qemu, Raspberry Pi 5, and modern ARM64 ports
RISC-V 64 riscv64-unknown-elf- Used by hardwares/virt.riscv/
x86 / x86_64 target-specific toolchain flow Implemented in the dedicated hardwares/x86/ port

Target Support Matrix

Support below is based on the checked-in source tree and build recipes in this checkout. Hardware validation depth can vary by board.

Target Path Architecture Typical Use Current Support Level Notes
porting.qemu/ ARM32 / AArch64 QEMU bring-up and development Recommended, most complete SMP, ext3 rootfs, VirtIO block/net/input/sound, 9P host share
hardwares/raspix/ ARM family Raspberry Pi family Strong, board-focused Broad add-on ecosystem under 3rd/, Wi-Fi, camera, audio, LCD/touch overlays
hardwares/raspi5/ AArch64 Raspberry Pi 5 Active and advancing WLAN, USB host, Bluetooth HID (keyboard/mouse/gamepad), fan control, NVMe FS daemon, LCD HAT integrations; VideoCore VII GPU 2D/3D
hardwares/qcom/8gen3/ AArch64 Radxa Dragon QCOM8GEN3 (SC8280XP / 8cx Gen3) Active hardware port Adreno 690 GPU (GLES/Vulkan/OpenCL/KUDA), Hexagon NPU, UEFI + PXE boot, NVMe ext3 rootfs, WLAN/BT/USB
hardwares/nvidia/orin.nano/ AArch64 NVIDIA Jetson Orin Nano (Tegra234) Bring-up port GA10B GPU (secure boot + compute + 3D board-verified), UEFI loader, ramfs rescue shell, Ethernet, BPMP/PCIe/I2C/GPIO/SDHCI/xHCI foundation
hardwares/x86/ x86 / x86_64 PC-style QEMU target Strong Full machine-local kernel and system recipes with GUI/X stack
hardwares/virt.riscv/ RISC-V 64 QEMU RISC-V virt Good kernel and desktop bring-up Base, GUI, and X flow present; network integration is lighter than porting.qemu
hardwares/miyoo/ ARM32 Handheld target Active port Custom drivers for audio, graphics, storage, and handheld-specific setup
hardwares/orangepi/ ARM / AArch64 family Orange Pi board work In-tree port Kernel, system, and board packaging files are present
hardwares/lego.ev3/ ARM32 LEGO Mindstorms EV3 In-tree port Includes EV3-specific drivers and packaging flow
hardwares/x2lite.rk3128/ ARM32 RK3128 target In-tree port Kernel and system recipes are present
hardwares/clockwork/picocalc/ ARM target Clockwork Pi PicoCalc Specialized target Separate board package with custom kernel/system setup
hardwares/raspix/3rd/clockwork/uconsole/ console/display environment Clockwork uConsole support files Specialized support tree raspix overlay focused on device/display and board support assets

Board and Peripheral Support

The tree already includes a large amount of board-specific and peripheral work.

Storage and Filesystems

  • Ext3 root filesystem image generation is the default build flow, with journaling for crash safety; cards without a journal are served in ext2-compatible mode
  • The kernel boot loader can read ext2/ext3 directly to load init
  • FAT32 support has also been ported into the stack
  • SD and MMC support exist across many machine BSPs, with recent write-path speed-ups (faster Raspberry Pi SD transfers, removed per-write verification)
  • Raspberry Pi 5 includes nvmefsd in its system drivers

Display and Input

  • Framebuffer-based display stack
  • X-like desktop window system
  • Multi-display work is actively landing
  • USB keyboard and mouse support on QEMU and x86-style targets
  • Bluetooth keyboard, mouse, and gamepad support on Raspberry Pi targets through the unified btd daemon: both classic BR/EDR HID and BLE HOGP links, with pairing/bonding persistence (/etc/bt/bt.json), several simultaneous classic and LE sessions, and per-link release synthesis so a dropped device never leaves a stuck key. Reports are re-published by hid_keybd, hid_moused, and hid_joystickd and feed the standard X input stack (xim_none/xmouse), so Bluetooth devices drop into the same chain as USB ones
  • Touch controller integrations under Raspberry Pi add-on trees such as gt911 and xpt2046
  • Many LCD HAT and Waveshare-style overlay trees for Raspberry Pi boards

Networking

  • User-space networking stack and daemons
  • ssh, scp, ping, host, telnet, https_test, and ws_test
  • sshd, telnetd, httpd, and machine-specific network drivers
  • Raspberry Pi WLAN work with Broadcom-related sources under hardwares/raspix/ and hardwares/raspi5/

Graphics and Desktop

  • Framebuffer rendering, 2D helpers, fonts, PNG/JPEG/GIF/SVG/TGA support
  • Arch-accelerated graphics paths, including scaling and rotation (graph_rotate_to_arch) for ARM, AArch64, and x86
  • X client libraries in both C and C++ forms
  • Desktop apps such as xterm, xread, ximg, xlog, xapps, clock, cards, and mine
  • Alternate window managers under system/xwin/xwm/ (opencde, ewokwm, misawm, openlook)
  • A software OpenGL ES 2.0 / EGL stack (opengl) with on-device GLSL compilers and real GPU offload on Raspberry Pi 5 (VideoCore VII), Raspberry Pi 4/CM4 (VideoCore VI, raspix), Qualcomm 8gen3 (Adreno 690) and Jetson Orin Nano (GA10B) — see 3D Graphics and OpenGL
  • Vulkan 1.0 (vulkan) and OpenCL 1.2 (opencl) stacks with CPU + GPU devices, and KUDA (kuda), a CUDA-driver-API-compatible compute layer — see GPU Compute: Vulkan, OpenCL and KUDA

3D Graphics and OpenGL

The projects/opengl tree provides a real OpenGL ES 2.0 / EGL stack that runs on EwokOS without a hosted GPU driver. Apps write standard GLES2/EGL code — <GLES2/gl2.h> + <EGL/egl.h>, glCreateShader/glDrawArrays/eglSwapBuffers — and never touch the back end directly:

  • gles (libs/gles) — the standard API front end, built as libGLESv2.a + libEGL.a and shipping the usual GLES2/GLES3/EGL/KHR headers. It layers a CPU GLSL ES interpreter (src/glsl) and a single engine adapter (src/engine/pgl_engine.c) over portablegl. An app links only -lEGL -lGLESv2 (plus glcommon and the system X/graph libs); portablegl and the machine's GPU compiler back end are merged into libGLESv2.a as private intermediates and stay invisible.
  • portablegl (libs/gles/portablegl) — a small, self-contained OpenGL ES 2.x-style rasterizer (vertex/fragment shaders, VBOs, textures, depth test) that renders into an EwokOS framebuffer. It is the engine behind the GLES API.
  • glcommon (libs/glcommon) — math and GL helper utilities shared by the apps.
  • pglcompiler (libs/gles/pglcompiler) — the vendored mesa GLSL → NIR front end shared by every GPU-capable machine (upstream pin in VENDORED.txt). Each machine pairs it with its own back end, selected by PGL_G3D_COMPILER_DIR in the machine's system/make.inc:
    • v3dcompiler (hardwares/raspi5/system/libs/v3dcompiler) — the mesa Broadcom V3D back end: GLSL ES 3.10 → NIR → VIR → V3D 7.1 QPU code, compiled on the device.
    • v3dcompiler (hardwares/raspix/system/libs/v3dcompiler) — the same mesa Broadcom back end built for V3D 4.2 (Pi 4/CM4, VideoCore VI). The shared raspix image queries the live V3D version at init and declines to the CPU/NEON rasterizer on unsupported silicon (Pi 3's V3D 2.1 has no CSD compute; Pi 5 boards use the raspi5 image).
    • adrenocompiler (hardwares/qcom/8gen3/system/libs/adrenocompiler) — the mesa freedreno/ir3 back end targeting Adreno 690 (a6xx, SC8280XP), with the compute NIR lowerings the gallium driver normally performs.
    • nvcompiler (hardwares/nvidia/orin.nano/system/libs/nvcompiler) — a hand-written pure-C NIR → sm_87 SASS back end for GA10B (Ampere): SASS encoder + register allocator + structured control flow, synthesized into a cubin and launched through the GPU's QMD path. Validated bit-exactly against nvcc 13.5 sm_87 output and by a differential warp-emulator oracle on the host.

On most targets the GLES calls rasterize entirely on the CPU (portablegl with NEON acceleration where available, driven by the interpreter in gles/src/glsl). On GPU-capable machines the same app binary additionally offloads geometry to the real GPU — the engine adapter picks CPU vs GPU per draw, so no app-side change is needed:

Machine GPU Shader path Dispatch path
hardwares/raspi5/ VideoCore VII (V3D 7.1, 12 QPUs) mesa GLSL → NIR → VIR → QPU CSD compute shaders via g2dd
hardwares/raspix/ (Pi 4/CM4) VideoCore VI (V3D 4.2) mesa GLSL → NIR → VIR → QPU CSD compute shaders via g2dd
hardwares/qcom/8gen3/ Adreno 690 (a6xx) mesa GLSL → NIR → ir3 Adreno CP ring / IB submissions via g2dd
hardwares/nvidia/orin.nano/ GA10B (Ampere, 8 SMs, sm_87) hand-written NIR → SASS → cubin QMD launches on GR compute channels

Because the V3D 7.1 binner cannot rasterize real primitives on BCM2712, opengl transforms, lights, and rasterizes geometry in CSD compute shaders compiled by the vendored mesa compiler, dispatched through the g2dd daemon (pgl_g3d → g2dclient → g2dd → bsp_g3d → vc_pgl3d); the Adreno and GA10B paths use the same two-pass compute-rasterizer shape on their own silicon. The GPU path is gated by PGL_G3D=yes, exported from the system/make.inc of all four machines; its two-pass compute rasterizer (a per-vertex transform pass plus a one-lane-per-triangle raster pass) makes it faster than the CPU rasterizer for scenes such as the teapot demo. On the Orin Nano the real ocean shader compiles on-board (~0.1 s) and renders fullscreen 3840×2160 at 18–23 fps through GA10B. The GPU also stays engaged across window resizes — the offload framebuffer is allocated with grow-only geometric headroom, so a drag-to-resize collapses into a handful of reallocations instead of one per event and never exhausts the kernel's contiguous shared-memory pool (which would otherwise silently latch the app back to CPU).

The opengl apps (teapot, gears, 3ddemo, matrix, Fireworks, imgui_demo) and the shadertoy-style fullscreen-compute demos exercise both paths through the same GLES2/EGL front end. The machine compiler back ends are validated on the host before ever running on the device — e.g. the nvcompiler differential oracle (tests/host/Makefile.host, a sm_87 warp emulator checked against a NIR reference interpreter and nvdisasm) and the Adreno shader host builds (adrenocompiler/tests).

For the full per-platform GPU story (VideoCore IV/VI/VII, Adreno 690, GA10B), see the wiki chapter 27 GPU Support Across the Mainstream Platforms (中文).

GPU Compute: Vulkan, OpenCL and KUDA

Beyond GLES, projects/ ships three standard-API compute/graphics stacks. All of them follow the same pattern: a device-agnostic runtime core with an always-present CPU back end, plus a GPU back end contributed by the machine BSP, so an app binary is identical on every target and the GPU can only add speed, never change results.

Vulkan (projects/vulkan)

A Vulkan 1.0 API stack (libvulkan.a + the Khronos vulkan/ headers). SPIR-V modules are parsed and validated once at vkCreateShaderModule; the software device interprets them, while the GPU back end transpiles the supported subset to GLSL ES 3.10 compute shaders, compiles them with the machine's on-device compiler (pglcompiler + back end) and dispatches through the g2dd CL verbs (bsp_cl → V3D CSD on Raspberry Pi 5, Adreno CP on 8gen3). Graphics draws go through a generated two-pass geometry rasterizer that reproduces the CPU rasterizer pixel-exactly. Anything outside the GPU subset is declined, never mis-compiled, and runs transparently on the CPU; compiled programs are cached across launches. Apps: vkteapot, vkmatrix, vkfonts, and vkolddisp (a retro CRT terminal wired to /bin/shell); CLI tools: vkinfo, vktest.

OpenCL (projects/opencl)

An OpenCL 1.2 API stack (libOpenCL.a + the CL/ headers) exposing two devices: a CPU device running a software OpenCL-C subset VM, and, on machines whose bsp_cl reports hardware support, a GPU device. The GPU back end transpiles the parsed OpenCL-C AST to GLSL ES 3.10 compute (clc_to_glsl), compiles it on-device and runs each NDRange as one dispatch over the g2dd CL path; kernels outside the GPU subset fall back to the CPU device. Tools and demos: clinfo, cltest, vector_add, saxpy, matmul.

KUDA (projects/kuda) — CUDA-compatible driver API

KUDA is a CUDA-driver-API-compatible compute layer: function names use the ku* prefix and enums KU_*, while the types (CUresult, CUcontext, CUmodule, CUstream, ...), error codes and _v2 aliases follow NVIDIA's driver API, so CUDA driver-API sources compile against it with only the API-prefix rename. The implemented scope (M0) covers init/device/context, cubin module loading, function attributes, device memory management, kernel launch, streams/events and the occupancy API; PTX JIT (compile offline with nvcc -cubin), arrays/textures, graphics interop, unified memory, IPC and graphs are out of scope.

The library is split into a machine-independent core and per-machine BSP back ends:

  • libkuda.a (projects/kuda/libs/kuda) — handle validation, object lifetime, launch-parameter packing, streams/events/occupancy, plus a built-in CPU simulation back end so the whole API works on machines without a GPU. Weak BSP fallbacks keep a core-only link alive everywhere.
  • libkudabsp.a (per machine, under hardwares/<vendor>/<hw>/system/libs/kuda) — binary-image parsing, the device model and the hardware back end. On Adreno 690 (hardwares/qcom/8gen3) modules are precompiled GLSL compute operator images (ops.q8b, generated from .comp shaders through the ir3 compiler by a host tool); launches run through the g2dd CL path with deferred batching (small launches share one driver round trip), chained IB submissions (one doorbell + one fence per batch) and ring queueing, over pooled DMA/shm device memory. This operator layer powers on-device quantized LLM inference (Q4_K GEMV): board-measured ~50 tok/s on Llama-3.2-1B Q4_K_M and ~15.6 tok/s on Qwen3-4B Q4_K_M (see hardwares/qcom/8gen3/docs/q8b-kuda-gemv-optimization.md and q8b-kuda-test-flow.md).
  • On Jetson Orin Nano the ga10b driver consumes real nvcc-produced sm_87 cubins and launches them through QMDs on GR compute channels (the full ACR/GSP secure-boot chain, PMU RTOS, FECS/GPCCS context switch and a vectorAdd cubin launch are board-verified); the cubin parser and QMD builder are shared with projects/kuda. See hardwares/nvidia/orin.nano/docs/ga10b-3d-handover.md.

For the implementation walkthrough (core/BSP split, CPU simulator, ops.q8b format, launch batching and the LLM operator set), see the wiki chapter 28 KUDA: a CUDA-Compatible Compute Layer (中文).

Extra Software

  • projects/ holds the larger standalone projects: a web browser, the ereader TXT/PDF reader, macemu and minivmac Macintosh emulators, nesemu, re3, the opengl / vulkan / opencl / kuda GPU stacks, sdl2, imgui, nx11, games, git, camera, cube, llm, video, and saver
  • hardwares/qcom/8gen3/system/bin/nputest/ provides the QCOM8GEN3 native HTP test window and npudemo CLI, with bundled model resources
  • Some installations depend on submodules being checked out locally

Project Components

Kernel

The kernel source under kernel/ includes:

  • Process scheduler and ready queues
  • IPC, kernel event queues, and semaphore handling
  • Signal delivery and syscall dispatch
  • MMU, DMA, shared memory, and kernel allocators
  • SMP-related support
  • Architecture-specific boot and interrupt handling

Base User Space

The base system under system/basic/ includes:

  • Shell, login flow, and standard command-line tools
  • Core services such as init, core, and vfsd
  • Filesystem helpers and rootfs daemons
  • Basic libc and utility libraries (see C Library, Standards, and Bundled Libraries)

GUI and X Stack

The graphics stack is split between system/gui/ and system/xwin/:

  • Display, font, graph, and audio/image support libraries
  • X client libraries and input helpers
  • Desktop apps and window managers
  • Machine-specific display configs and init scripts

Network Stack

The network tree under system/network/ provides:

  • Interactive tools such as ssh, scp, ping, and host
  • Network daemons such as sshd
  • Additional services and drivers wired in through machine-specific system trees

C Library, Standards, and Bundled Libraries

EwokOS ships its own C library, libewoksys, instead of relying on a hosted libc. It provides ISO C standard headers plus a POSIX-like API subset, layered over the cross-toolchain runtime (newlib + libgloss), with openlibm for math and softfloat for software floating point on ARM32.

The default link group is declared per architecture in system/platform/<arch>/make.rule:

# AArch64 / x86
EWOK_LIBC = --start-group -lewoksys -lc -lgloss --end-group
# ARM32 additionally links the software FP runtime
EWOK_LIBC = --start-group -lewoksys -lc -lgloss -lsoftfloat --end-group $(LIBGCC)

libc Source Layout

  • system/basic/libc/libewoksys/ — the native EwokOS C library: standard headers, POSIX-like implementations, and the EwokOS system API (IPC, VFS, devices, shared memory, processes, logging)
  • system/basic/libc/libgloss/ — toolchain syscall glue (_open, _close, _read, _write, _lseek, _stat, _fstat, _sbrk, _kill, _fork, _wait, _getpid, _gettimeofday, _isatty, ...)
  • system/basic/libc/softfloat/ — software floating-point / aeabi runtime helpers used on ARM32 (-mfloat-abi=softfp)

Supported Standards

ISO C (C90/C99 subset) — provided by the libewoksys headers: <stdio.h>, <stdlib.h>, <string.h>, <strings.h>, <ctype.h>, <math.h>, <assert.h>, <errno.h>, <setjmp.h>, <time.h>, <float.h>, <inttypes.h>, <stdarg.h>, <stddef.h>, <wchar.h>, <malloc.h>.

POSIX-like API — a practical subset oriented at embedded and system programming:

Area Headers Representative APIs
Process & files <unistd.h>, <fcntl.h>, <dirent.h>, <sys/stat.h>, <sys/wait.h> fork/exec family, getpid/getuid/getgid, dup/dup2/dup3, pipe, getcwd/chdir, fsync, truncate/ftruncate, sysconf, daemon, wait
Memory <sys/mman.h>, <malloc.h> mmap/munmap with PROT_* / MAP_* flags
Signals <signal.h> signal handlers and delivery
Threads <pthread.h>, <semaphore.h> mutexes, condition variables, rwlocks, barriers, keys, pthread_once, attributes, cancel/detach/join, POSIX semaphores
Terminal, I/O multiplexing & scheduling <termios.h>, <sched.h>, <poll.h>, <sys/select.h> termios control, poll/select readiness, sched_yield
Shared memory & IPC <sys/shm.h>, <sys/ipc.h> shmget/shmat/shmdt/shmctl
System info & scatter/gather I/O <sys/ioctl.h>, <sys/uio.h>, <sys/utsname.h>, <sys/resource.h>, <sys/statvfs.h>, <sys/time.h>, <sys/times.h> ioctl, readv/writev, uname, resource/statvfs queries, time-of-day
Misc utilities <getopt.h>, <glob.h>, <fnmatch.h>, <libgen.h>, <err.h> argument parsing, globbing, pattern matching, path helpers
Dynamic loading <dlfcn.h>, <dl/dl.h> dlopen/dlsym/dlclose/dlerror/dladdr, plus the EwokOS host-ABI extensions dl_host_publish/dl_host_lookup/dl_host_abi_version (AArch64)

BSD Sockets — via the socket library (system/network/libs/socket): <sys/socket.h>, <netinet/in.h>, <arpa/inet.h>, <netinet/if_ether.h>, <netinet/ether.h>, with socket, bind, listen, accept, connect, send/recv, sendmsg/recvmsg, shutdown, socketpair, getsockname/getpeername, gethostbyname, and inet_addr/inet_ntoa/inet_pton/inet_ntop.

C++ — libcxx (C++ runtime support) plus libewokstl, a lightweight STL subset: string/wstring, vector, list, deque, queue, stack, set, map, unordered_set, unordered_map, algorithm, iterator, functional, memory, tuple, utility, iostream/sstream/fstream, and the header-only object++ (UniObject) helper.

The libc favors a compact, embedded-appropriate subset. A few hosted-libc features are intentionally absent or simplified — for example vprintf is not provided; use vfprintf(stdout, ...) instead.

Commonly Bundled Libraries

Beyond libc, the tree builds a set of static libraries grouped under system/*/libs:

Library Location Purpose
ewoksys system/basic/libc/libewoksys Native EwokOS system API: IPC, VFS/vdevice, processes, shared memory, DMA, logging (slog/klog), timers, sessions
openlibm system/basic/libs/openlibm Math library (-lopenlibm)
zlib system/basic/libs/zlib Deflate compression (-lz)
tinyjson system/basic/libs/tinyjson Minimal JSON parser/builder
sd / ext2 / ext3 / fat32 system/basic/libs/* Storage and filesystem readers/writers
elf system/basic/libs/elf ELF parsing/loading
dl system/basic/libs/dl Runtime dynamic loader: POSIX dlopen/dlsym/dlclose plus the generated host ABI export table (-ldl)
gpio / usb system/basic/libs/* GPIO and USB helper libraries
socket system/network/libs/socket BSD sockets client API
wolfssl system/network/libs/wolfssl TLS/SSL
libwebsockets system/network/libs/libwebsockets WebSocket client/server
libtinyhttpsc system/network/libs/libtinyhttpsc Tiny HTTPS client
ntpc system/network/libs/ntpc NTP client
graph / g2dclient system/gui/libs/* 2D framebuffer graphics and 2D-acceleration client
display / displayman system/gui/libs/* Display service client libraries
font / freetype / libiconbuf system/gui/libs/* Font rendering (bitmap + FreeType)
libpng / libjpeg / libgif / libtga / libsvg system/gui/libs/* Image codecs
libogg / libvorbis / minimp3 system/gui/libs/* Audio codecs
textgrid / gterminal system/gui/libs/* Text grid and terminal emulation
keyb / mouse system/gui/libs/* Keyboard and mouse input clients
x / x++ / widget++ system/xwin/libs/* X-like window system client libs (C, C++, widget toolkit)

The graphics and window-system groups are also declared in make.rule as EWOK_LIB_GRAPH and EWOK_LIB_X, so applications can link them as a unit.

Dynamic Library Support (dlopen)

EwokOS links every program statically, so there is no ld.so and no ELF interpreter. Runtime dynamic loading is provided instead as an explicit plugin facility: dlopen() loads an ET_DYN shared object built with -fPIC -shared, relocates it against the host's exported ABI, and returns an opaque handle. It is implemented and boot-verified on AArch64 (porting.qemu); the kernel anonymous-mapping window that enforces W^X exists only under #ifdef __aarch64__, and other architectures fall back to heap emulation without per-page permissions.

Three pieces cooperate:

  • Kernel (kernel/kernel/src/svc.c, kernel/kernel/src/mm/mmu.c, kernel/kernel/include/mm/mmu.h)
    • SYS_CACHE_SYNC cleans the D-cache to PoU and broadcasts an I-cache invalidate, because EL0 cannot run dc civac / ic ivau itself (SCTLR_EL1.UCI is left clear). Without it, freshly-copied plugin code could never be fetched.
    • SYS_MMAP_ANON / SYS_MPROTECT / SYS_MUNMAP draw from a per-process 256 MB anonymous window (DL_WINDOW_*, 64 KB slots) with real per-page permissions, so a plugin's text is mapped read-only-and-execute and its data read-write — true W^X. The window is released on process exit, including abnormal exit, in proc_funeral.
  • libdl (system/basic/libs/dl) — the user-space ELF dynamic loader: ET_DYN parsing, the mandatory DT_HASH symbol table, R_AARCH64_RELATIVE/GLOB_DAT/JUMP_SLOT relocations, DT_NEEDED dependency loading, .init_array/.fini_array ctor/dtor ordering, reference counting, dlerror, and dladdr.
  • Host ABI table (system/basic/libs/dl/gen_export.sh) — because a static ET_EXEC has no .dynsym (--export-dynamic is a no-op), the host's exportable surface is generated at build time by nm-ing the EWOK_LIBC archives into a sorted, strongly-referenced table (__ewok_dl_abi[], ~730 symbols). Application-owned symbols are added at runtime with dl_host_publish().

libc routes mmap/mprotect/munmap/getpagesize to the new syscalls, falling back to the heap emulation when the window is absent.

Using it

A plugin is a normal -fPIC shared object; the host links EWOK_LIB_DL (-ldl $(EWOK_LIBC)) and installs plugins into the rootfs /lib (the loader's default search path is /lib:/usr/lib:/system/lib):

#include <dlfcn.h>

void* h = dlopen("/lib/libdemo.so", RTLD_NOW);
int (*fn)(int) = (int (*)(int))dlsym(h, "demo_entry");
if(fn) fn(42);
dlclose(h);

Two deliberate deviations from glibc/musl: RTLD_LAZY is accepted but binding is always eager, and RTLD_NEXT is refused by dlsym() (RTLD_DEFAULT works). dlerror() is per-process rather than per-thread.

The bin/dltest app is a boot-time self-test that exercises the whole stack — host ABI, absolute/soname/DT_NEEDED loading, cross-object relocation, ctor/dtor ordering, refcounting, dladdr, error paths, eight simultaneous objects with slot release/reuse, and a wxfault mode that provably takes a data abort when writing to a plugin's read-only text. On porting.qemu it reports 94 checks, 0 failures.

For the full mechanism, see the wiki chapter 25 Runtime Dynamic Loading (dlopen) (中文).

Host Requirements

At minimum you need:

  • make
  • A matching cross toolchain for the architecture you want to build
  • QEMU for emulator targets
  • e2tools and mke2fs or e2fsprogs for ext2/ext3 image creation

Typical Linux Packages

sudo apt-get install make qemu-system-arm qemu-system-aarch64 qemu-system-misc e2tools e2fsprogs

On macOS, install the same categories of tools with Homebrew or another package manager, plus the cross compilers required for the target architecture.

Quick Start with porting.qemu

porting.qemu/ is the easiest place to start because it runs entirely in QEMU and has the most complete out-of-the-box development flow.

1. Build the Root Filesystem

cd porting.qemu/system
make x
make sd

This stages the root filesystem under system/build_aarch64/virt/rootfs/ and creates root_aarch64.img under porting.qemu/system/. The image is ext3 by default; pass FS=ext2 to make sd for an ext2 image instead.

2. Build the Kernel

cd porting.qemu/kernel
make

The default porting.qemu configuration is:

  • ARCH=aarch64
  • SMP=yes
  • PAGE_SIZE=16k

Recent kernel work also adds 64k page support for AArch64-oriented ports.

3. Run in QEMU

cd porting.qemu/kernel
make run

The current QEMU recipe includes:

  • RAM framebuffer output
  • VirtIO block storage
  • VirtIO network
  • VirtIO tablet and keyboard devices
  • VirtIO sound
  • 9P host sharing mounted as hostshare
  • Optional host forwarding through QEMU_HOSTFWD or QEMU_NETDEV

4. Log In

Default users from system/basic/etc/passwd:

User Password
root root
misa misa
guest empty

Useful Build Targets

porting.qemu/system

make basic    # base userland only
make network  # base userland + networking
make gui      # framebuffer GUI stack
make x        # full desktop stack
make projs    # build the projects/ apps (after the system build)
make projs vulkan opengl  # build only the named projects
make sd       # generate ext3 rootfs image (FS=ext2 supported)
make clean
make clean projs          # clean only projects/, keep the system build
make clean projs vulkan   # clean only the named projects

porting.qemu/kernel

make          # build the kernel image
make asm      # generate kernel assembly listing
make run      # boot QEMU with GUI
make run-headless
make run-gui  # same as make run (explicit GUI form)
make run-gui-hvf  # GUI run accelerated with QEMU HVF (host CPUs)
make runasm   # boot with instruction tracing
make debug    # QEMU paused with GDB server on :26000
make debugasm
make gdb

Common Variants

# Build a 32-bit ARM virt rootfs and kernel
cd porting.qemu/system && make ARCH=arm x && make ARCH=arm sd
cd ../kernel && make ARCH=arm && make ARCH=arm run

# Force a specific QEMU display backend
QEMU_DISPLAY_OPTS=cocoa make run

# Customize host forwarding
QEMU_HOSTFWD='hostfwd=tcp:127.0.0.1:2022-:22' make run

Working with Other Targets

Most machine ports follow the same pattern:

  1. Build the target root filesystem in hardwares/<target>/system
  2. Generate the ext2/ext3 image or board-specific storage image
  3. Build the kernel in hardwares/<target>/kernel
  4. Run in QEMU or deploy to SD card, eMMC, or board storage as appropriate

For SD-card-oriented flows, see hardwares/README.md and the per-target recipes under hardwares/*/system.

Source Reading Guide

If you want to understand the codebase quickly, start here:

  1. kernel/kernel/src/ for scheduler, process state, IPC, signals, and VM
  2. kernel/platform/ for boot, interrupts, and MMU differences by architecture
  3. system/basic/sys/ for init, core, and vfsd
  4. system/gui/ and system/xwin/ for graphics, desktop, and X client APIs
  5. system/network/ for daemons, tools, and protocol support
  6. porting.qemu/ for the simplest full boot path
  7. hardwares/raspix/ and hardwares/raspi5/ for the most active hardware bring-up work

Documentation

  • DeepWiki
  • porting.qemu/ and hardwares/*/ for target-specific build files
  • kernel/platform/ and system/platform/ for architecture and build rules
  • hardwares/README.md and per-target docs/ trees for board notes and screenshots

Notes on Submodules

This repository may rely on submodules depending on your checkout state. The current .gitmodules file references trees such as:

  • hardwares
  • projects

If a directory mentioned in the documentation is missing locally, initialize submodules before building or exploring the full software set.

Contributing

Contributions are welcome. Bug reports, platform notes, board bring-up findings, documentation improvements, and pull requests are all useful.

License

This project is licensed under the terms in LICENSE.

Explore related projects

Loading…