TinyOS🐞: Operating System Tutorial
Published:
TinyOS🐞 is a tutorial series about minimal operating system kernel implementation based on the comprehensive tutorial series mini-risscv-os. This operating system kernel is based on RISC-V instruction set architecture. Credits goes to the original authors of mini-risscv-os. A fully built environment is available as a docker environment. This tutorial will cover several chapters related to implementing a operating system from begining.
Requirements
In order to complete the tutorial you just need only two things
Beyond the technical requirements, inorder to understand the concepts I highly recommend looking at my firmware tutorial series before starting on this.
Setup the Environement on Docker
Fully bulid docker environemt with all the requirements installed including
- gcc toolchain
- qemu with RISC-V simulator
can be found in the following docker-hub reposiroty.
You can follow the below instructions to get it mount on your docker stack.
- Pull the docker container
docker pull archfx/rvutils:qemu
- clone this repository
git clone https://github.com/Archfx/tinyos
- Mount the repo to the docker container
docker run -t -p 6080:6080 -v "${PWD}/:/tinyos" -w /tinyos --name rvutils archfx/rvutils:qemu
- Open the docker environment in another terminal
docker exec -it rvutils /bin/bash
Chapters
This tutorial series contains following chapters.
- HelloWorld: Use UART to print text to the terminal
- ContextSwitch: Basic switch from OS to user task
- MultiTasking: Two user tasks are interactively switching
- TimerInterrupt: Enable SysTick for future scheduler implementation
- Preemptive: Basic preemptive scheduling
- Spinlock: Lock implementation to protect critical sections
- ExterInterrupt: Learning PLIC & external interruption
- BlockDeviceDriver: Learning VirtIO Protocol & Device driver implementation
- MemoryAllocator: Understanding how to write the linker script & how the heap works
- SystemCall: Invoking a mini ecall from machine mode.
Building and Simulation
Instead of following through the tutorial, you can direclty compile and run the simulation from the repository. To do that you can navigate direcltly to the folder and use followings commamds from inside the Docker instance of archfx/rvutils:qemu
make # Build the OS
make qemu # Simulate the OS
Note: Press Ctrl-A and then X to exit QEMU