A mini OS kernel for Raspberry PI 3 and 4
  • C 76.3%
  • C++ 22.1%
  • TeX 0.7%
  • CMake 0.5%
  • Python 0.2%
  • Other 0.1%
Find a file
2025-02-24 15:29:39 +01:00
.github/workflows Tidy Up for Presentatoin & FAT RamFs (#64) 2024-05-23 12:37:02 +02:00
binuser Final dump after next-year presentation 2025-02-24 15:29:39 +01:00
cmake Initial MMU Implementation & MMIO Death (#45) 2024-05-11 14:16:57 +02:00
doc Create OS image (#72) 2024-05-26 18:12:04 +02:00
fonts Add support for mailbox, GPIO, MiniUART, framebuffer and GRAPHICS (#32) 2024-03-28 14:55:17 +01:00
fs Final dump after next-year presentation 2025-02-24 15:29:39 +01:00
kernel Final dump after next-year presentation 2025-02-24 15:29:39 +01:00
lib Final dump after next-year presentation 2025-02-24 15:29:39 +01:00
rapport Rapport Done. (#73) 2024-05-27 23:25:37 +02:00
tools Final dump after next-year presentation 2025-02-24 15:29:39 +01:00
.clang-format [feat] Add CMake support (#14) 2024-02-29 13:56:42 +01:00
.clang-tidy Final dump after next-year presentation 2025-02-24 15:29:39 +01:00
.editorconfig Add a UART keyboard and mouse driver (#74) 2024-11-26 14:50:24 +01:00
.gitignore Tidy Up for Presentatoin & FAT RamFs (#64) 2024-05-23 12:37:02 +02:00
.gitmodules Add a UART keyboard and mouse driver (#74) 2024-11-26 14:50:24 +01:00
CMakeLists.txt Final dump after next-year presentation 2025-02-24 15:29:39 +01:00
CONTRIBUTING.md Initial draft for CONTRIBUTING.md 2024-02-17 23:00:32 +01:00
LICENCE Initial commit 2024-02-17 14:56:14 +01:00
README.md Add a UART keyboard and mouse driver (#74) 2024-11-26 14:50:24 +01:00

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:
    sudo apt install gcc-aarch64-linux-gnu make cmake mtools
    
    Try to install the latest available version of GCC.
  • On macOS,
    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:

# 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):

# 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,
    sudo apt install qemu-system-arm
    
  • On macOS,
    brew install qemu
    

Then to run the kernel, just type:

# 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):

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.