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:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

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

4 Replies to “KernelUNO – A lightweight OS for Arduino UNO with a Linux-like shell”

  1. Those of us who have known the good old days of interactive BASIC interpreters running on machines with a few kB of RAM or even on microcontrollers like 8051 know how powerful it is to have such a command line during experimentation. No need to flash anything anymore, you just try until it works. I had also run an old BSD in a PDP emulator running on ESP32, which contained a working C compiler. That was pretty cool (but slow since emulated).

    1. I would think it probably can given that it is just a single arduino sketch, however if they used any direct register access or anything like that it might not be possible without changing the register addresses.

Leave a Reply

Your email address will not be published. Required fields are marked *

Boardcon MINI1126B-P AI vision system-on-module wit Rockchip RV1126B-P SoC
Boardcon MINI1126B-P AI vision system-on-module wit Rockchip RV1126B-P SoC