KernelUNO: A Lightweight OS Featuring a Linux-like Shell for Arduino UNO

KernelUNO: A Lightweight OS Featuring a Linux-like Shell for Arduino UNO

2 Min Read

KernelUNO is an Arduino sketch with 546 lines of code that acts as a lightweight OS for the Arduino UNO. It features a Linux-like shell with commands such as ls, df, and uname.

To use it, you’ll need an Arduino UNO R3 or a compatible board with a Microchip ATmega328P microcontroller, a USB cable for programming, and optionally a few LEDs and resistors to test the gpio command.

KernelUNO includes various features:

  • Virtual Filesystem: Create files and directories in RAM (/dev, /home)
  • Hardware Control: GPIO management with pin mode configuration
  • System Monitoring: Memory usage, uptime, kernel messages (dmesg)
  • Interactive Shell: Real-time command execution with input buffering
  • 23 built-in commands:
    • File system commands: ls, cd, pwd, mkdir, touch, cat, echo [text] > [file], rm, info [name]
    • Hardware commands:
      • pinmode [pin] [in/out]: Set pin mode
      • write [pin] [high/low]: Write to pin
      • read [pin]: Read pin value
      • gpio [pin] [on/off/toggle]: GPIO control
      • gpio vixa [count]: LED disco mode (easter egg)
    • System commands: uptime, uname, dmesg, df, free, whoami (hardcoded to root), clear, reboot, help, sh

The code is available on GitHub (BSD 3-Clause license), and being a single Arduino sketch, it can be easily flashed to your board. It offers commands similar to a Linux host and additional hardware commands for GPIO control.

However, as noted by Hackaday, there’s no permanent storage; everything runs in RAM, meaning it’s somewhat limited. The ATmega328 AVR MCU has 2KB of RAM, 1KB of EEPROM, and 32KB of flash storage, with the current memory usage as follows:

  • Program: ~38% of 32KB flash
  • RAM: ~85% of 2KB SRAM (optimized)
  • Filesystem: 10 files/directories max
  • DMESG buffer: 6 messages

Future plans include EEPROM persistence and PWM/analog control. While the code was written manually, Claude AI was used for documentation.

You might also like