xinu-avr: the Xinu OS for AVR atmega328p devices (e.g. Arduino)

[What is Xinu?] [code for download] [authors] [Douglas Comer] [getting started] [notes] [contact us]


Getting started

Dependences

For building the source code you need the below listed toolchain components in your system:

gcc-avr version 2 (it is needed for time.h and date)

Other Dependences:

make, gcc-avr, avr-libc, avrdude (for flashing), flex, bison, make

Basic examples

There are several short and quick examples applications for getting started with multi-tasking embedded system programming using Xinu OS (some of them come from the Comer's Book). These are easy to understand, just follow the few steps in the README file of each one. Check them here: Xinu examples apps source code.

Note: the only requirement for proper concurrent programming is to understand basic OS topics, like multi-task programming (priorities, processes states, etc), syncronization between processes, semaphores and mutexes. If you not, don't worry, you can play with the examples for a while while reading about those topics in some OS book.

Getting started with the Xinu OS and the Xinu shell

# 1. get the repositoy

git clone http://github.com/zrfa/xinu-avr
cd xinu-avr/

# 2. build

cd compile/
make clean
make

# 3. flash and test

make flash 
screen /dev/ttyUSB0  # it could be /dev/ttyACM0 or whatever. Check dmesg

Using the Xinu shell

If everything was okey then you will see the Xinu shell prompt, ready for using your mini AVR microcontroller like a retro Xinu/UNIX-like computer.

The output below is an example of a Xinu shell session:

Welcome to Xinu!

        Xinu OS Copyright (c) 2012, 2015
        Douglas E. Comer and CRC Press, Inc.

        Xinu OS for AVR atmega328p v0.1 (c) 2020
        Rafael Ignacio Zurita 

naminit (devices):
  /dev/console
  /dev/nulldev
  /dev/namespace

FreeMEM:1050 (bytes)

xsh $ help

Commands:

 memdump : display SRAM memory contents
 editor : text editor
 basic : BASIC language interpreter
 help : this help
 sleep n : sleep n seconds
 forever : for (;;);
 uptime : tell how long the Xinu system has been running
 reboot : reset the Xinu system sw. THIS IS NOT a hw reset
 kill n : kill (terminates) the n (ID) process
 free : display amount of free and used memory
 clear : clear the terminal screen
 ps : display current processes table
 echo [arg ...] : write arguments to standard output
 date [MM/DD/YY HH:MM:SS] : set or get the date and time
 cal [mon] year : calendar

xsh $ sleep 3
xsh $ date

Sat Jan 01 00:00:10 2000

xsh $ uptime
 0 day(s) & 0h:0m:12s
xsh $ 
xsh $ 
xsh $ date 07/20/20 19:59:03
xsh $ 
xsh $ date

Mon Jul 20 19:59:04 2020

xsh $ uptime
 0 day(s) & 0h:13m:0s
xsh $ 
xsh $ sleep 10
xsh $ 
xsh $ forever &			# <- background process
xsh $ ps

table of current processes

name    id      parent  prio    state   stklen  sem waits
--
nullp   0       0       10      2       64      -1
shell   1       0       20      1       440     0
forever 3       1       20      2       128     -1
xsh $ 
xsh $ kill 3
xsh $ 
xsh $ ps

table of current processes

name    id      parent  prio    state   stklen  sem waits
--
nullp   0       0       10      2       64      -1
shell   1       0       20      1       440     0
xsh $ 
xsh $ free
addr            len
0x000004e5      418

                total   used    free
SRAM Mem        2303    1885    418
xsh $ 
xsh $ basic			# <- tiny basic interpreter under the Xinu shell

Welcome to TinyBasic Plus interpreter v0.15
210 bytes free.
available VARS: A - J
OK
> 
> 10 print "hi"
> 10 ro 
> 20 for i = 1 to 20 step 2
> 10 print "hi"
> 30 print "i",i
> 40 next i
> l
What? 
> 
> list
10 PRINT "hi"
20 FOR I = 1 TO 20 STEP 2
30 PRINT "i",I
40 NEXT I
OK
> 
> run
hi
i1
i3
i5
i7
i9
i11
i13
i15
i17
i19
OK
> buy
What? 
> bye
xsh $ 




last edit: Wed Jul 22 19:42:10 -03 2020 - Rafael Ignacio Zurita (rafa at fi.uncoma.edu.ar)