Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hgruniaux/pi-kachulm_os

A mini OS kernel for Raspberry PI 3 and 4
https://github.com/hgruniaux/pi-kachulm_os

baremetal kernel os rasberrypi raspberry-pi raspberry-pi-3 raspberry-pi-4

Last synced: 13 days ago
JSON representation

A mini OS kernel for Raspberry PI 3 and 4

Awesome Lists containing this project

README

        

# Pi-kachULM_OS

## Building the kernel

To build the kernel you will need to install a aarch64 GCC compiler, `cmake` and `mtools`:

- On Ubuntu, something like that:
```shell
sudo apt install gcc-aarch64-linux-gnu make cmake mtools
```
Try to install the latest available version of GCC.
- On macOS,
```shell
brew install gcc make cmake mtools
```
should suffice if you are on a M1/M2 CPU. [To be tested]
- On Windows, good luck. See MinGW or search internet.

Then, you just need you execute in the project directory:

```shell
# Change aarch64-linux-gnu- by whatever is named GCC for aarch64 on your system.
cmake -S . -Bbuild -DGCC_PREFIX=aarch64-linux-gnu- --toolchain=cmake/GCCToolchain.cmake
make -j -C build kernel-img
```

Or (for Clang):
```shell
# Change -17 by whatever version of Clang is installed on your system (or use nothing to call `clang` as is).
cmake -S . -Bbuild -DCLANG_SUFFIX=-17 --toolchain=cmake/ClangToolchain.cmake
make -j -C build kernel-img
```

You should specify `-DTARGET_QEMU=ON` when configuring CMake if you intend to build an image for QEMU.

## Testing the kernel

You can either run the kernel on real Raspberry PI (at least version 3 required) hardware.

Or use QEMU. First, you need to install it:

- On ubuntu,
```shell
sudo apt install qemu-system-arm
```
- On macOS,
```shell
brew install qemu
```

Then to run the kernel, just type:

```shell
# You may need to change qemu-system-aarch64 by whatever is QEMU for aarch64 is named on your computer.
qemu-system-aarch64 \
-M raspi3b \
-serial pipe:/tmp/uart-input \
-serial stdio \
-kernel build/kernel/kernel8.img \
-dtb doc/DeviceTree/pi3.dtb \
-device loader,file=build/binuser/fs.img,addr=0x18000000,force-raw=on
```
and launch `python tools/uart-input-server.py` (for the UART keyboard and mouse driver).

If you don't want to use the UART keyboard and mouse driver (you will probably need to modify kernel.cpp):
```shell
qemu-system-aarch64 \
-M raspi3b \
-serial stdio \
-kernel build/kernel/kernel8.img \
-dtb doc/DeviceTree/pi3.dtb \
-device loader,file=build/binuser/fs.img,addr=0x18000000,force-raw=on
```

## The userspace file structure

- `/`: The root
- `/bin`: all the executables of the user space
- `/bin/init`: ELF program for aarch, the first program started by the OS.
- `/bin/credits`: ELF program for aarch, displaying credits on screen
- `/bin/slides`: ELF program for aarch, used for the presentation
- `/bin/explorer`: ELF program for aarch, a file explorer
- `/wallpaper.jpg`: The window manager wallpaper.
- `/slides/`: The slides used by the `slides` user program.