{"id":16241712,"url":"https://github.com/i-ilak/pios","last_synced_at":"2026-04-29T01:33:52.814Z","repository":{"id":217550755,"uuid":"740160793","full_name":"i-ilak/pios","owner":"i-ilak","description":"Baremetal playground for Raspberry Pi","archived":false,"fork":false,"pushed_at":"2024-02-04T17:38:01.000Z","size":154,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T09:59:26.738Z","etag":null,"topics":["baremetal","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/i-ilak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-07T17:45:50.000Z","updated_at":"2024-01-20T13:09:36.000Z","dependencies_parsed_at":"2024-01-19T22:48:47.977Z","dependency_job_id":"185e8603-8c82-491a-86db-2da0ea40d30c","html_url":"https://github.com/i-ilak/pios","commit_stats":null,"previous_names":["i-ilak/pios"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/i-ilak/pios","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-ilak%2Fpios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-ilak%2Fpios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-ilak%2Fpios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-ilak%2Fpios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/i-ilak","download_url":"https://codeload.github.com/i-ilak/pios/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/i-ilak%2Fpios/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32407164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["baremetal","raspberry-pi"],"created_at":"2024-10-10T14:08:23.795Z","updated_at":"2026-04-29T01:33:52.799Z","avatar_url":"https://github.com/i-ilak.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# piOS: Tipping my toes into baremetal programming\n[![Build](https://github.com/i-ilak/pios/actions/workflows/Build.yml/badge.svg)](https://github.com/i-ilak/pios/actions/workflows/Build.yml)\n\n`piOS` is the still ongoing result of me going through various online tutorials\nabout baremetal coding on the Pi, which you can check out in the list below [(see here)](#Notes). \nI'm stepping into the world of embedded software development with almost zero prior experience, and unfortunately, \nmy university days didn't touch on this domain. This project is purely a hobby, sparked by a desire to dip my toes \ninto the world of embedded systems.\n\nWhat is the end goal? To be honest, I don't know yet. The things that I would like to get working but are not yet:\n* **Filesystem**: I don't want to continue to compile everything I need into the kernel. There is a SD card so let's use it.\n* **Bluethooth**: Would be nice to connect an external keyboard or something like this? I have no idea how hard this is.\n* **TCP/IP stack**: Would be fun to try to get it connected to the internet. \n\n## Notes\nHonestly, if you are interested in baremetal programming, you can probably use any of the below projects as a \nstarting point. Since I don't believe there is one perfect source for the relevant topics, here is a short summary of\nwhat I have been following, reading, and using as template along the way. I'd like to make clear that a good chunk of \nthe code in this repository is almost 1-to-1 from the below projects. The goal here was not to create something new\n(at least not yet), but rather use the code from these projects to explore how things work, what you can do with it, \nand of course also what potential pitfalls are. I changed some things were I found it appropriate \n(building the project, structure of the code, documentation, etc.).\n* [armOS (*Thanos Koutroubas*)](https://github.com/thanoskoutr/armOS): This was the first source I followed and you\nwill see a large overlap between this project and mine. But this project goes much more into the direction of creating\nan OS that I plan. Nevertheless, it was a good source to start and gave me some nice idea of how to structure my\nproject.\n* [Bare metal Raspberry Pi 3 tutorials (*Zoltan Baldaszti*)](https://github.com/bztsrc/raspi3-tutorial/): Really nice \ntutorial that introduces the basic ways of how HW and SW should interact with each other. The individual lessons are\nnot really connected, so it's quite easy to just pick out what you need.\n* [Building an Operating System for the RaspberryPi (*Jake Sandler*)](https://jsandler18.github.io) Has a nice\nintroduction to setting up dynamic memory allocation for 32-bit systems, but seems a little bit light on some details.\n* [Raspberry Pi bare metal experiments (*Brian Widdas*)](https://github.com/brianwiddas/pi-baremetal)\n* [Learning operating system development using Linux kernel and Raspberry Pi (*Sergey Matyukevich*)](https://github.com/s-matyukevich/raspberry-pi-os)\nLots of explanations about concepts related to OS development using the Linux kernel and Pi OS as an example.\nHelps to understand some of the code out there doing things/solving things and seeing the bigger picture!\n\nOne thing that I haven't mentioned so far, but was basically open the whole time, is the documentation of the SoC, \nBroadcom 2835/2837. \n\n## How to build the project?\nThe tricky part for this project is the compiler. Since we are writing code that is supposed to run on an ARM \nprocessor, you will need the corresponding compiler. All compilers to build for ARM CPU's can be found on\n[ARM's website](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads). \nYou will most probably have to cross-compile (`x86`-\u003e`arm`) and you will need to be careful if you are compiling the \nkernel for a `32-bit` or a `64-bit` CPU (`arm-none-eabi` vs `aarch64-none-elf`). \nThe `CMakeLists.txt` file has all the logic needed to handle which compiler to pick depending on the Raspberry Pi \nModel you want to compile this code for (just make sure they are installed and in the `$PATH`). \nYou will find in the top-level `CMakeLists.txt` file a variable that's called `MODEL_X`, where `X` can be `[0,1,2,3,4]`. \n`MODEL_3` and `MODEL_4` have a `64bit` CPU and thus need the `aarch64` compiler.\n\n*Note*: This project was started with a `32bit` board (Pi 0) and thus most of the code was initially written with the \nARMv6 architecture in mind. For example, the entire memory management code was written with ATAGS (ARM Tags) in mind, \nwhich where replaced by DTB's (device tree blob's) in ARMv8-a and would thus need a refresh. \nI will do this at some point, but for now I will focus more on exploring some of the capabilities of the `32bit` \nversion of the board. \nIn short, the `64bit` boards have a lot less functionality compared to the `32bit` boards with this kernel as of now.   \n\nOnce you have all of this setup, you should be able to simply `cd` into the root of this repo and run\n(assuming you have `cmake` and `ninja-build` installed on your system)\n```bash\ncmake -G Ninja -B ./build -S .\ncmake --build ./build\n```\nor you can use Docker\n```bash\nDOCKER_BUILDKIT=1 docker build --progress=plain -f Dockerfile --rm -t pi_os:latest . --output ${PATH_TO_WHERE_YOU_WANT_THE_ELF_AND_IMG}\n```\n\n## How to run the kernel?\nWhile the ultimate goal of course is to run the kernel on a Pi, for development it is useful to also run it in `qemu`.\nFor the `32-bit` version you can use\n```bash\n# ARMv6 / 32 bit\nqemu-system-arm -M raspi0 -serial null -serial stdio -kernel $PATH_TO_ELF/kernel.elf\n# ARMv8-a / 64 bit\nqemu-system-aarch64 -M raspi3b -serial null -serial stdio -kernel $PATH_TO_ELF/kernel7.elf\n```\n\n*Note:* To run the code with `qemu` you use the `.elf`, i.e. the full executable. If you want to test the kernel out \non a real Raspberry Pi, then you need to move the `.img` file onto the SD card. \n\n## How to generate documentation?\nTo generate the documentation you can run\n```bash\ndoxygen .doxyfile\n```\nPlease make sure to install `doxygen` and `graphviz`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-ilak%2Fpios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fi-ilak%2Fpios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fi-ilak%2Fpios/lists"}