renebarto / baremetal

A project to develop baremetal applications for Raspberry Pi and Odroid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

baremetal {#BAREMETAL}

A project to develop baremetal applications for Raspberry Pi and Odroid

This project is based on / inspired by the work of many others:

  • Circle by Rene Stange, a great piece of work covering almost all peripherals and devices on Raspberry Pi (link), with help of circle stdlib (link) and newlib (link) by Stephan Muehlstrasser.
  • Documentation from the Raspberry Pi foundation (link)
  • Tutorials by:
    • Raspberry Pi foundation (link)
    • Zoltan Baldaszti (link),
    • Low Level Devel (link),
    • David Welch (link)
    • Sergey Matyukevich (link)
  • The community on the Raspberry Pi forum on Baremetal development (link)

I decided to give it my own turn, for a number of reasons:

  • Some tutorials are OLD, covering only Raspberry Pi 2, sometimes 3
  • Most code is in C, not C++
  • Most code is not very well documented, and is missing pointers to the correct information sources
  • If the source is written in C++, the code is mostly C-ish
  • Most of the projects use Make scripts, or even worse automake, which to me seem archaic, as there are more recent tools available such as CMake for build configuration
  • The information is spread into bits and pieces
  • Circle is pretty complete, but is covering only Raspberry Pi, and includes all models (starting from RPI1), and also running 32 bit code. I prefer to focus on RPI3B and later, including Odroid boards, and only on 64 bit application development
  • There is quite some assembly code needed to run certain functions, or run them efficiently. This code is not well documented
  • I prefer my code to be readable. Therefore I strive to use clear class, method and variable names, and lay the code out such that it can be easily understood.

In other words, I'll try to slowly build up a framework, much like Circle, while adding explanation and pointer to information, and do it in a proper C++ way.

The projects will be set up using CMake, and with that will allow working from within IDE's such as Visual Studio.

Code will be C++, but will for now not be using any STL classes, as using the STL library implies using the standard C library, which needs to be ported over, much like what Stephan Muehlstrasser did. This is not trivial, so will have to wait a bit. I hope I'll get around to it eventually, as the being able to use the full power of C++ on a baremetal board is something I'm striving for.

Next to the code and documentation, I'll be adding tooling to ease development and retrieve feedback on code quality. For example:

  • Development should be possible, as in coding, building and debugging, from Visual Studio on Windows, or Visual Studio Code on its supported platforms. This is not very common for baremetal development and linux related development, but many developers, including myself, prefer Visual Studio as an IDE.
  • Builds should be CMake based, not using the old and for many illegible make / auto tools based builds
  • Code checking using cppcheck
  • Doxygen integration, including the documentation provided here
  • Pre-commit hooks using clang-format for uniform code formatting
  • Unit testing, even at baremetal level, using stubs and mocks. This will use an alternative to gtest / gmock, as this relies on the standard C++ library
  • Debugging on platform (with the addition of HW), as well as in QEMU, even directly from Visual Studio

License {#BAREMETAL_LICENSE}

Code included in this repository, as well as code in the tutorials, is shared under the Creative Commons 1.0 license (see here). This means that code will contain a copyright, but you are free to use it in whichever way you see fit. I would appreciate at least a reference to this GitHub project though.

For now, we will focus on Raspberry Pi, as the information is more readily available than for Odroid.

Contents {#BAREMETAL_CONTENTS}

  • @subpage TUTORIALS
  • @subpage INFORMATION

@todo

  • Check if bug in Visual Studio 2022 is fixed
  • Build demo for RPI 4
  • Try out Raspberry Pi 4 emulation in QEMU
  • Find and add Raspberry Pi 5 information, extend samples for this platform as soon as possible (look at circle)
  • Add boot process for Odroid system
  • Add description of Odroid platform support in QEMU
  • Add description of how to use JTAG device with Raspberry Pi and possibly Odroid, using e.g. Macoy Madson's page
  • Explain setting up development environment on Windows for Windows build : "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
  • Add logger, inject character device
  • Add retrieval of system information
  • Add clang format and git hook for commit

About

A project to develop baremetal applications for Raspberry Pi and Odroid

License:Creative Commons Zero v1.0 Universal


Languages

Language:C++ 77.2%Language:C 14.0%Language:CMake 5.2%Language:Assembly 1.9%Language:CSS 1.4%Language:Python 0.2%Language:HTML 0.1%Language:Shell 0.0%Language:Batchfile 0.0%