Skip to content

Felix-Garci/Embedded-Computer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESP32 Handheld OS: A Custom RTOS-Based Smart Terminal

A complete operating system for handheld devices based on ESP32 and FreeRTOS. This project implements a modular kernel architecture, a custom transactional file system, and advanced connectivity capabilities (AI Chat, UDP Mesh Messaging), all running on a low-cost, high-efficiency microcontroller.

Front PCB Front PCB Back

🚀 Key Features

  • True Multitasking Architecture: FreeRTOS-based kernel with segregated tasks for UI Rendering (50Hz), Input Sampling (High Speed), Network Communications, and Business Logic.

  • Custom Flash File System: A Log-Structured File System designed from scratch featuring:

    • Automatic Wear Leveling and Garbage Collection to extend Flash memory life.
    • Power-loss corruption protection via Atomicity and Journaling.
    • Dynamic partitioning based on key prefixes.
  • Modular Application Engine: Uses the Factory design pattern to dynamically load, unload, and manage the lifecycle of "Apps" to optimize RAM usage.

  • Hybrid Connectivity:

    • Online Mode: REST Client for interaction with LLMs supporting stream responses.
    • Local Mode: Decentralized "Walkie-Talkie" style chat via UDP Broadcast over local network (Serverless).
  • Smart Input: Experimental predictive text engine based on N-Grams to speed up typing.

  • Power Management: Smart Deep Sleep with hardware interrupt wake-up and critical state persistence.

🛠️ Software Architecture

The system abandons the simple setup/loop paradigm in favor of a professional layered architecture:

graph TD
    H["Hardware (ESP32)"] --> D["Drivers (Pantalla, Teclado, Flash)"]
    D --> K[Kernel / CoreSystem]
    K --> OS[FreeRTOS Tasks]
    OS --> T1[Input Task]
    OS --> T2[UI Render Task]
    OS --> T3[Network/UDP Task]
    K --> AM[App Manager]
    AM --> App1[Calculator]
    AM --> App2[AI Chat]
    AM --> App3[Messaging]
    AM --> App4[Text Reader]
Loading

🧠 The Core (CoreSystem)

Acts as the central orchestrator (Singleton). It manages the application lifecycle, injects hardware dependencies, and controls the state machine transitions.

💾 Memory Management (FlashManager)

nstead of using standard file systems (SPIFFS/LittleFS), a direct driver over SPI Flash ( Flash.cpp / FlashInterface.cpp) was implemented to allow:

  1. Append-Only Writing: Maximizes speed and flash lifespan.

  2. Address Virtualization: Apps access data using keys ( MSG_ID, BOOK_TEXT) without knowing physical hex addresses.

  3. Garbage Collection (GC): An intelligent background process compacts fragmented sectors when necessary, recovering space without losing active data.

📱 Integrated Applications

  • AI Chat: Client for language models (GPT/Claude/Local). Allows conversation with an AI, configuring parameters such as MODEL and CONTEXT directly in Flash.
  1. Messaging (Local): Local instant messaging system. Devices on the same WiFi network automatically discover each other and exchange messages via UDP packets.

  2. Text Reader: A book/document reader with smooth pagination, capable of reading large files stored in dedicated partitions.

  3. Calculator: Mathematical utilities with a dedicated graphical interface.

  4. Settings: Control panel for managing WiFi, brightness, and system parameters.

⚡ Hardware & Design

The system is designed to run on custom hardware.

Circuit Schematic

Esquema del Circuito

PCB Design

Diseño PCB

Diseño PCB - Render 3D Diseño PCB - Render 3D Inferior

📂 Estructura del Proyecto

  • lib/APPS: Business logic for each application (Calculator, AI Chat, etc.).
  • lib/BASICS: Low-level drivers (Flash, Battery, Screen, Keyboard).
  • lib/APPS/CoreSystem: Kernel, State Machine, and Application Manager.
  • src/main.cpp: FreeRTOS tasks and interrupts initialization.
  • docs/: schematics and diagrams.

© 2025 Felix - Open Source Project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors