Skip to content

neurapy/cubeOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CubeOS running Doom

CubeOS

A non-spherical Operating System. I did this to learn how operating systems work, convince people to hire me and have a sandbox to test low level concepts in the future.

Limitations

  • No Internet
  • I can't guarantee any USB device actually works. (It works for the cheapest keyboard & Mouse I was able to find)
  • Support for Superfloppy and Master Boot Record, No GPT.
  • Only FAT32 Support (and it might corrupt the partition. The SD. 2. FAT isn't even written to in my driver.)
  • To change partitions, just recompile your kernel :)
  • No use of DMA
  • Just one core (why would you need more than that)
  • A lot of things are not perfect. Some things are good some things are bad
  • A README that assumes everyone in the world uses Arch

Features

  • Its very easy to create Apps. The Kernel can Read ELFs and you don't even need a Linker Script.
  • Complete NEON support in User/Kernel Context
  • No Ads, Spinning Cubes, Gaming
  • Multithreading, preemptive Scheduler, all basic OS stuff

By common definition everything that cant run doom is no operating system. So this was a good place to stop. There also exists a Terminal, Explorer & Texteditor.

Setup

Build requirements

Those are required to build the kernel and the compiled-in compositor:

sudo pacman -Syu make curl arm-none-eabi-binutils arm-none-eabi-gcc 
make static_assets      # Downloads the RPI Firmware and .wad File for Doom

The Kernel and all normal Apps are compiled as freestanding. However to build doom you need to do:

make newlib             # Installs newlib to ./newlib/
git submodule update --init --recursive

QEMU

You need QEMU and the tools to create build/sd.img.

sudo pacman -Syu sudo uboot-tools qemu-system-arm dosfstools parted util-linux
make cc                 # Optional - Generates compile_commands.json
make qemu               # Starts the Emulator

QEMU control:

  1. RightCtrl+G: toggle input grab on/off (Let me out)
  2. RightCtrl+F: toggle Fullscreen

Hardware

You need a Raspberry Pi 2B (BCM2836).

Easiest would be to make sd flush it on the SD and hope it works. (Maybe it won't. I haven't tested this. The kernel should run but I expect it to fail because drivers may only work because UBOOT set them up correctly, like UART. config.txt and the firmware should handle UART but I don't know if any other Drivers might complain.

The other way is a TFTP server.

sudo pacman -Syu sudo uboot-tools tftp-hpa

Configure the host once:

sudo nvim /etc/systemd/network/10-raspi-tftp.network # And write this (Name should be your LAN)
[Match]
Name=enp3s0

[Network]
Address=192.168.10.1/24
sudo systemctl enable --now systemd-networkd
sudo systemctl restart systemd-networkd
sudo systemctl enable --now tftpd.socket

Also disable or configure your firewall.

Move Firmware and UBOOT to a fresh FAT32 partitioned SD card. Boot it and set the env once:

setenv ipaddr 192.168.10.2
setenv serverip 192.168.10.1
setenv bootcmd 'setenv kernel_addr_r 0x00008000; if tftp 0x02400000 boot.scr; then source 0x02400000; else if mmc dev 0; then if fatload mmc 0:1 ${kernel_addr_r} CUBE-OS.IMG; then echo [hardware] booting cached CUBE-OS.IMG; bootm ${kernel_addr_r}; else echo [hardware] missing cached CUBE-OS.IMG; fi; else echo [hardware] unable to access mmc 0; fi; fi'
saveenv

Connect a LAN cable to the Device and run

make hardware              # copies kernel.img, boot.scr, PROGRAMM/*ELF and doom WAD to TFTP root. 

Reboot the RPI. After one successful boot you don't need the LAN connection anymore. If connected over UART you can run (for example) sudo picocom -b 115200 --imap lfcrlf /dev/ttyUSB0

make clean cleans.

MISC

Doom on QEMU might not work so well if you have autorepeating keys. Also, QEMU is quite slow because it doesn't really benefit from all the Hardware specific stuff. On real Hardware the compositor can reach currently ~200 FPS with no load and ~70FPS with Doom 70 FPS was chosen as a CAP because its 2x the DOOM FPS. The USB driver is a very cannabalized CSUD. It wouldn't work for me so at some point I tried to just get it integrated with AI. The Result is a very bad driver. (No IRQ/FIQ driven polls, Topology Rebuilds instead of hotplugging)

In general the performace of everything is not so bad, but there would be some obvious improvements, like better usage of the page Buddy, DMA for Adress space creation, etc.

If I ever have time (probably never) I would like to

  • TCP/IP Stack + small webbrowser
  • Python Like Interpreter incl. Autograd engine
  • Use DMA
  • Improve thread, process abstraction & handling

// // // // // // // // // // // // // // // //

About

An almost usable Operating System for the Rasberry Pi 2B (BCM2836)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors