KernelUNO – A lightweight OS for Arduino UNO with a Linux-like shell

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

All you need is 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 for testing the gpio command in the terminal.

KernelUNO

KernelUNO offers the following 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

You can get the code on GitHub (BSD 3-Clause license), and since it’s a single Arduino sketch, you can just easily flash it to your board to get started. Most commands are the same as you’d find on a Linux host, somewhat closer to what busybox has to offer, plus hardware commands to control GPIOs.

As noted by Hackaday, there’s no permanent storage, so everything runs in the RAM, which makes it less useful than it could be. In theory, it might be possible to add an external flash or use the EEPROM, but in practise we have to bear in mind that the ATmega328  AVR MCU only comes with 2KB RAM, 1KB EEPROM, and 32KB flash storage, and the memory footprint/usage is currently as follows:

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

There’s still hope as two features are included in the TODO list: EEPROM persistence and PWM/analog control. The code was manually written, but Claude AI was still used for documentation.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress. We also use affiliate links in articles to earn commissions if you make a purchase after clicking on those links.

Radxa Orion O6 Armv9 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
3 Comments
oldest
newest
Boardcon MINI1126B-P AI vision system-on-module wit Rockchip RV1126B-P SoC