{"id":13779276,"url":"https://github.com/ckormanyos/real-time-cpp","last_synced_at":"2025-10-08T02:21:19.221Z","repository":{"id":4771017,"uuid":"5922310","full_name":"ckormanyos/real-time-cpp","owner":"ckormanyos","description":"Source code for the book Real-Time C++, by Christopher Kormanyos","archived":false,"fork":false,"pushed_at":"2025-10-03T19:33:07.000Z","size":270899,"stargazers_count":732,"open_issues_count":11,"forks_count":184,"subscribers_count":44,"default_branch":"master","last_synced_at":"2025-10-03T21:18:50.499Z","etag":null,"topics":["arduino","arm","avr","avr-microcontroller","bare-metal","cortex-m","cpp","cpp11","cpp14","cpp17","cpp20","cpp23","embedded","embedded-systems","high-performance","microcontroller","realtime","stm32"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ckormanyos.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING3","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2012-09-23T13:31:08.000Z","updated_at":"2025-10-03T19:33:09.000Z","dependencies_parsed_at":"2023-07-11T03:17:00.509Z","dependency_job_id":"162be2ee-5fc7-4f9a-943a-ce35c27c8ae9","html_url":"https://github.com/ckormanyos/real-time-cpp","commit_stats":{"total_commits":2371,"total_committers":10,"mean_commits":237.1,"dds":"0.059468578658793736","last_synced_commit":"d91b9ef3c014d0836d41b24f4a55ca7d5f2c664a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ckormanyos/real-time-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Freal-time-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Freal-time-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Freal-time-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Freal-time-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ckormanyos","download_url":"https://codeload.github.com/ckormanyos/real-time-cpp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ckormanyos%2Freal-time-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278877100,"owners_count":26061382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["arduino","arm","avr","avr-microcontroller","bare-metal","cortex-m","cpp","cpp11","cpp14","cpp17","cpp20","cpp23","embedded","embedded-systems","high-performance","microcontroller","realtime","stm32"],"created_at":"2024-08-03T18:01:03.379Z","updated_at":"2025-10-08T02:21:19.215Z","avatar_url":"https://github.com/ckormanyos.png","language":"C++","readme":"﻿Real-Time-C++\r\n==================\r\n\r\n\u003cp align=\"center\"\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp.yml/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp-examples.yml/badge.svg\" alt=\"Build Examples\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp-snippets.yml/badge.svg\" alt=\"Build Snippets\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp-benchmarks.yml/badge.svg\" alt=\"Build Benchmarks\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc\"\u003e\r\n        \u003cimg src=\"https://custom-icon-badges.herokuapp.com/github/issues-raw/ckormanyos/real-time-cpp?logo=github\" alt=\"Issues\" /\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/codeql.yml\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/codeql.yml/badge.svg\" alt=\"CodeQL\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://scan.coverity.com/projects/ckormanyos-real-time-cpp\"\u003e\r\n        \u003cimg src=\"https://scan.coverity.com/projects/24862/badge.svg\" alt=\"Coverity Scan\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://sonarcloud.io/summary/new_code?id=ckormanyos_real-time-cpp\"\u003e\r\n        \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=ckormanyos_real-time-cpp\u0026metric=alert_status\" alt=\"Quality Gate Status\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/blob/master/LICENSE_1_0.txt\"\u003e\r\n        \u003cimg src=\"https://img.shields.io/badge/license-BSL%201.0-blue.svg\" alt=\"Boost Software License 1.0\"\u003e\u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\nThis is the companion code\r\nfor the book C.M. Kormanyos,\r\n[Real-Time C++](https://www.springer.com/de/book/9783662629956):\r\nEfficient Object-Oriented\r\nand Template Microcontroller Programming, Fourth Edition\r\n(Springer, Heidelberg, 2021) ISBN 9783662629956.\r\n\r\nThis repository has several main parts.\r\n  - Reference Application `ref_app` located in [ref_app](./ref_app). This also includes the [benchmarks](./ref_app/src/app/benchmark).\r\n  - [Examples](./examples) from the book\r\n  - [Code Snippets](./code_snippets) from the book\r\n\r\nGNU/GCC cross compilers and various additional tools\r\nrunning on `Win*`, optionally needed for certain builds\r\nas described below, can be found in the related\r\n[ckormanyos/real-time-cpp-toolchains](https://github.com/ckormanyos/real-time-cpp-toolchains)\r\nrepository.\r\n\r\n## Details on the Reference Application\r\n\r\nThe reference application boots with a small startup code and subsequently\r\ninitializes a skinny microcontroller abstraction layer (MCAL). Control is\r\nthen passed to a simple multitasking scheduler that manages the\r\nLED application, calls a cyclic benchmark task and services the watchdog.\r\n\r\nThe LED application toggles a user-LED with a frequency of $\\frac{1}{2}~\\text{Hz}$\r\nThe result is LED on for one second, LED off for one second.\r\nThe LED application runs cyclically and perpetually\r\nwithout break or pause.\r\n\r\nThe reference application is compatible with C++14, 17, 20, 23 and beyond.\r\n\r\n## Portability\r\n\r\nThe application software is implemented once and used uniformly\r\non each supported target in the [ref_app](./ref_app).\r\nDifferences among the individual targets arise only\r\nin the lower software layers pertaining\r\nto chip-specific and board-specific startup/MCAL details.\r\n\r\nIn this way the project exhibits a high level of portability.\r\n\r\n## Supported Targets in the Reference Application\r\n\r\nThe reference application supports the following targets (in alpha-numeric order):\r\n\r\n| Target name (as used in build command) | Target Description                                          | *(breadboard) |\r\n| -------------------------------------- | ----------------------------------------------------------- | ------------- |\r\n| `am335x`                               | BeagleBone with Texas Instruments(R) AM335x ARM(R) A8       |               |\r\n| `am6254_soc_`                          | PocketBeagle2 with multicore Texas Instruments(R) AM6254    |               |\r\n| `atmega2560`                           | MICROCHIP(R) [former ATMEL(R)] AVR(R) ATmega2560            |               |\r\n| `atmega4809`                           | MICROCHIP(R) [former ATMEL(R)] AVR(R) ATmegax4809           | X             |\r\n| `avr` (as used in the book)            | MICROCHIP(R) [former ATMEL(R)] AVR(R) ATmega328P            | X             |\r\n| `bcm2835_raspi_b`                      | RaspberryPi(R) Zero with ARM1176-JZFS(TM)                   | X             |\r\n| `Debug`/`Release`                      | PC on `Win*` via MSVC x64 compiler `Debug`/`Release`        |               |\r\n| `host`                                 | PC/Workstation on `Win*`/`mingw64`/`*nix` via host compiler |               |\r\n| `lpc11c24`                             | NXP(R) OM13093 LPC11C24 board ARM(R) Cortex(R)-M0+          |               |\r\n| `nxp_imxrt1062`                        | Teensy 4.0 Board / NXP(R) iMXRT1062 ARM(R) Cortex(R)-M7     | X             |\r\n| `riscvfe310`                           | SiFive RISC-V FE310 SoC                                     |               |\r\n| `rl78`                                 | Renesas(R) RL78/G13                                         |               |\r\n| `rpi_pico_rp2040`                      | RaspberryPi(R) Pico RP2040 with dual ARM(R) Cortex(R)-M0+   | X             |\r\n| `rpi_pico2_rp2350`                     | RaspberryPi(R) Pico2 RP2350 with dual ARM(R) Cortex(R)-M33  | X             |\r\n| `rx63n`                                | Renesas(R) RX630/RX631                                      |               |\r\n| `stm32f100`                            | STMicroelectronics(R) STM32F100 ARM(R) Cortex(R)-M3         | X             |\r\n| `stm32f407`                            | STMicroelectronics(R) STM32F407 ARM(R) Cortex(R)-M4F        |               |\r\n| `stm32f429`                            | STMicroelectronics(R) STM32F429 ARM(R) Cortex(R)-M4F        |               |\r\n| `stm32f446`                            | STMicroelectronics(R) STM32F446 ARM(R) Cortex(R)-M4F        |               |\r\n| `stm32h7a3`                            | STMicroelectronics(R) STM32H7A3 ARM(R) Cortex(R)-M7         |               |\r\n| `stm32l100c`                           | STMicroelectronics(R) STM32L100 ARM(R) Cortex(R)-M3         | X             |\r\n| `stm32l152`                            | STMicroelectronics(R) STM32L152 ARM(R) Cortex(R)-M3         |               |\r\n| `stm32l432`                            | STMicroelectronics(R) STM32L432 ARM(R) Cortex(R)-M4F        | X             |\r\n| `v850es_fx2`                           | Renesas(R) Electronics V850es/Fx2 upd703231                 |               |\r\n| `wch_ch32v307`                         | WCH CH32v307 RISC-V board                                   |               |\r\n| `wch_ch32v307_llvm`                    | WCH CH32v307 RISC-V board (but using an LLVM toolchain)     |               |\r\n| `x86_64-w64-mingw32`                   | PC on `Win*`/`mingw64` via GNU/GCC x86_x64 compiler         |               |\r\n| `xtensa_esp32_s3`                      | Espressif (XTENSA) NodeMCU ESP32-S3                         | X             |\r\n| `xtensa32`                             | Espressif (XTENSA) NodeMCU ESP32                            | X             |\r\n\r\nIn this table, *(breadboard) means the board (or certain versions of it) can be readily\r\nused with a common breadboard. This may possibly need some very straightforward\r\nmanual soldering/mounting of header-pins.\r\n\r\n## Getting Started with the Reference Application\r\n\r\nIt is easiest to get started with the reference application using one of the\r\nsupported boards, such as `avr` (ARDUINO) or `bcm2835_raspi_b`\r\n(RaspberryPi ZERO) or `am335x` (BeagleBoneBlack), etc.\r\nThe reference application can be found\r\nin the directory [ref_app](./ref_app) and its\r\nsubdirectories.\r\n\r\nThe reference application uses cross-development and\r\nbuild systems are supported on:\r\n  - `*nix` make tools in combination with Bash/GNUmake (bash script) on LINUX/MacOS,\r\n  - ported `*nix`-like make tools on `Win*` in combination with batch script or Microsoft(R) Visual Studio(R) via _External Makefile_,\r\n  - MICROCHIP(R) [former ATMEL(R)] Studio on `Win*`,\r\n  - or platform-independent CMake.\r\n\r\nUpon successful completion of the build,\r\nthe resulting artifacts including HEX-files\r\n(such as `ref_app.hex`), map files, size reports, etc.,\r\nare available in the `bin` directory.\r\n\r\n### Build with Bash Shell Script and GNU make\r\n\r\nTo get started with the reference application on `*nix`\r\n  - Open a terminal in the directory  [ref_app](./ref_app).\r\n  - The terminal should be located directly in [ref_app](./ref_app) for the paths to work out (be found by the upcoming build).\r\n  - Identify the Bash shell script [ref_app/target/build/build.sh](./ref_app/target/build/build.sh).\r\n  - Consider which configuration (such as `target avr`) you would like to build.\r\n  - Execute `build.sh` with the command: `./target/build/build.sh avr rebuild`.\r\n  - This shell script calls GNU make with parameters `avr rebuild` which subsequently rebuilds the entire solution for `target avr`.\r\n  - If you're missing AVR GCC tools and need to get them on `*nix`, run `sudo apt install gcc-avr avr-libc`.\r\n\r\n### Example Build on `*nix` for `target avr`\r\n\r\nWe will now exemplify how to build the reference application on a command shell\r\nin `*nix` for `target avr`. This target system includes essentially\r\n_any_ ARDUINO(R)-compatible board. This is also the board compatibility\r\nactually used with the homemade boards in the book.\r\n\r\nInstall `gcc-avr` if needed.\r\n\r\n```sh\r\nsudo apt install gcc-avr avr-libc\r\n```\r\n\r\nClone or get the [ckormanyos/real-time-cpp](https://github.com/ckormanyos/real-time-cpp)\r\nrepository. Then build with:\r\n\r\n```sh\r\ncd real-time-cpp\r\ncd ref_app\r\n./target/build/build.sh avr rebuild\r\n```\r\n\r\n### Example Build on `*nix` for `target stm32f446`\r\n\r\nWe will now exemplify how to build the reference application on a command shell\r\nin `*nix` for an ARM(R) target. Consider, for example, the build variant\r\n`target stm32f446`. The NUCLEO-F446RE board from STMicroelectronics(R)\r\ncan conveniently be used for this.\r\n\r\nInstall `gcc-arm-none-eabi` if needed.\r\n\r\n```sh\r\nsudo apt install gcc-arm-none-eabi\r\n```\r\n\r\nClone or get the [ckormanyos/real-time-cpp](https://github.com/ckormanyos/real-time-cpp)\r\nrepository. Then build with:\r\n\r\n```sh\r\ncd real-time-cpp\r\ncd ref_app\r\n./target/build/build.sh stm32f446 rebuild\r\n```\r\n\r\n### Example Build on MacOS for `target stm32f446`\r\n\r\nWe will now exemplify how to build the reference application in a command shell\r\nin MacOS for an ARM(R) target. Consider, for example, the build variant\r\n`target stm32f446`. The NUCLEO-F446RE board from STMicroelectronics(R)\r\ncan conveniently be used for this.\r\n\r\nClone or get the [ckormanyos/real-time-cpp](https://github.com/ckormanyos/real-time-cpp)\r\nrepository.\r\n\r\nThe default version 3.81 of GNUmake on MacOS can (now) be used.\r\nThe make files used in this repository have been made\r\ncompatible with it. For background information, see also\r\n[issue 273](https://github.com/ckormanyos/real-time-cpp/issues/273).\r\n\r\nBuild the target with a direct manual call to `make`.\r\n\r\n```sh\r\ncd real-time-cpp\r\ncd ref_app\r\nmake -f target/app/make/app_make.gmk rebuild TGT=stm32f446\r\n```\r\n\r\nIf the toolchain is needed then it must be installed or retrieved\r\nprior to building the target of the reference application.\r\n\r\nYou can obtain via `wget` (or optionally install)\r\nthe `gcc-arm-none-eabi` toolchain if needed.\r\nIn this case, I have found it convenient to use\r\na modern `gcc-arm-none-eabi` for MacOS which can be found at\r\n[Arm GNU Toolchain Downloads](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads).\r\n\r\nThe `arm-non-eabi` toolchain can be fetched via `wget`\r\nand successfully used locally in the shell. If this is desired,\r\nfollow the step-by-step procedure below.\r\n\r\nStep 1: Make a local directory (such as `macos-gnu-arm-toolchain`) and `cd` into it.\r\n\r\n```sh\r\ncd real-time-cpp\r\nmkdir -p macos-gnu-arm-toolchain\r\ncd macos-gnu-arm-toolchain\r\n```\r\n\r\nStep 2: Fetch the toolchain's tarball with `wget`, unpack it\r\nand add the compiler's `bin`-directory to the shell's executable path.\r\n\r\n```sh\r\nwget --no-check-certificate https://developer.arm.com/-/media/Files/downloads/gnu/12.2.rel1/binrel/arm-gnu-toolchain-12.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz\r\ntar -xvf arm-gnu-toolchain-12.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz\r\nPATH=$(pwd)/arm-gnu-toolchain-12.2.rel1-darwin-x86_64-arm-none-eabi/bin:$PATH\r\n```\r\n\r\nStep 3: Optionally `echo` the `PATH` for a quick path-check.\r\nIt can also be helpful to query `arm-non-eabi-g++`'s version.\r\nThis is expected to verify that the toolchain is correctly added\r\nto this shell's local `PATH`.\r\n\r\n```sh\r\necho $PATH\r\narm-none-eabi-g++ -v\r\n```\r\n\r\nNow simply use the commands to build the target\r\nwith a direct call to `make` (which is the same\r\nas shown above for the `*nix` case).\r\n\r\n```sh\r\ncd real-time-cpp\r\ncd ref_app\r\nmake -f target/app/make/app_make.gmk rebuild TGT=stm32f446\r\n```\r\n\r\n### Build with VisualStudio(R) Project and CMD Batch\r\n\r\nTo get started with the reference application on `Win*`\r\n  - Clone or get the [ckormanyos/real-time-cpp](https://github.com/ckormanyos/real-time-cpp) repository.\r\n  - Get and setup (from the [ckormanyos/real-time-cpp-toolchains](https://github.com/ckormanyos/real-time-cpp-toolchains) repository) any needed GNU/GCC cross compilers running on `Win*`, as described in detail a few paragraphs below.\r\n  - Start Visual Studio(R) 2019 (or later, Community Edition is OK)\r\n  - Open the solution `ref_app.sln` in the [ref_app](./ref_app) directory.\r\n  - Select the desired configuration.\r\n  - Then rebuild the entire solution.\r\n\r\nThe `ref_app` build in Microsoft(R) VisualStudio(R)\r\nmakes heavy use of cross development using a project\r\nworkspace of type _External_ _Makefile_.\r\nGNUmake is invoked via batch file in the build process.\r\nIt subsequently runs in combination with several Makefiles.\r\n\r\nTo build any `ref_app` target other than `Debug` or `Release` for Win32, a cross-compiler\r\n(GNU/GCC cross compiler) is required. See the text below for additional details.\r\n\r\nGNU/GCC cross compilers running on `Win*` intended\r\nfor the reference application on VisualStudio(R)\r\ncan be found in the _toolchains_ repository,\r\n[ckormanyos/real-time-cpp-toolchains](https://github.com/ckormanyos/real-time-cpp-toolchains).\r\nThe _toolchains_ repository contains detailed instructions on\r\ninstalling, moving and using these ported GNU/GCC compilers.\r\n\r\nNote on GNUmake for `Win*`: A GNUmake capable of being used on `Win*`\r\ncan be found in the\r\n[ckormanyos/make-4.2.1-msvc-build](https://github.com/ckormanyos/make-4.2.1-msvc-build)\r\nrepository.\r\nIf desired, clone or get the code of this repository.\r\nBuild `make-4.2.1` in its `x64` `Release` configuration\r\nwith MSVC (i.e., VC 14.2 or later, Community Edition is OK).\r\n\r\n### Build with Cross-Environment CMake\r\n\r\nCross-Environment CMake can build the reference application.\r\nFor this purpose, CMake files have also been created for each supported target.\r\n\r\nConsider, for instance, building the reference application for the\r\n`avr` target with CMake. The pattern is shown below.\r\n\r\n```sh\r\ncd real-time-cpp\r\nmkdir build\r\ncd build\r\ncmake ../ref_app -DTRIPLE=avr -DTARGET=avr -DCMAKE_TOOLCHAIN_FILE=../ref_app/cmake/gcc-toolchain.cmake\r\nmake -j ref_app\r\n```\r\n\r\nWe will now consider, for instance, building the reference application for\r\none of the supported ARM(R) targets with CMake. The pattern is shown below.\r\nIn this case, we need to identify the following make options:\r\n\r\n```sh\r\n-DTRIPLE=avr -DTARGET=avr\r\n```\r\n\r\nSwitch these options to the ones intended for the `stm32f446` ARM(R)-based target being built.\r\n\r\n```sh\r\n-DTRIPLE=arm-none-eabi -DTARGET=stm32f446\r\n```\r\n\r\nLet's clarify the commands in their entirety in order to run a CMake build for `stm32f446`\r\n(i.e., ST Microelectronics(R) STM32F446 ARM(R) featuring Cortex(R)-M4F).\r\n\r\n```sh\r\ncd real-time-cpp\r\nmkdir build\r\ncd build\r\ncmake ../ref_app -DTRIPLE=arm-none-eabi -DTARGET=stm32f446 -DCMAKE_TOOLCHAIN_FILE=../ref_app/cmake/gcc-toolchain.cmake\r\nmake -j ref_app\r\n```\r\n\r\nWhen building with CMake for other targets,\r\nfollow the standard `*nix` pattern to build.\r\nAlso building with CMake for `x86_64-w64-mingw32`\r\nor `host` from MSYS, Cygwin or any similar `*nix`-like\r\nshell or console should work too.\r\n\r\nThe following command sequence will build for the\r\nnative `host` on a `*nix`-like shell or console.\r\n\r\n```sh\r\ncd real-time-cpp\r\nmkdir build\r\ncd build\r\ncmake ../ref_app -DTARGET=host -DCMAKE_TOOLCHAIN_FILE=../ref_app/cmake/gcc-toolchain.cmake\r\nmake -j ref_app\r\n```\r\n\r\n### Build with MICROCHIP's ATMEL Studio\r\n\r\nThere is also a workspace solution for ATMEL(R) AtmelStudio(R) 7.\r\nIt is called `ref_app.atsln` and is also located\r\nin the [ref_app](./ref_app) directory.\r\nThere are ATMEL Studio projects for\r\nboth the reference application as well as for each of the examples.\r\nATMEL Studio projects in this repository support\r\nthe AVR target only.\r\n\r\nIf you decide to use ATMEL Studio, you do not need to use or include\r\nany additional libraries for these projects\r\n(other than those that are ordinarily installed\r\nduring the standard installation of ATMEL Studio).\r\n\r\n## Details on Selected Targets\r\n\r\nTarget details including startup code and linker definition files can\r\nbe found in the [ref_app/target](./ref_app/target) directory\r\nand its subdirectories. There are individual subdirectories for\r\neach supported target microcontroller system.\r\n\r\nThe ARM(R) A8 configuration (called `target am335x`) runs on the BeagleBone\r\nboard (black edition). For the white edition, the CPU clock needs to be reduced\r\nfrom $900~\\text{MHz}$ to something like $600~\\text{MHz}$. This project creates a bare-metal program\r\nfor the BeagleBone that runs independently from any kind of `*nix` distro on\r\nthe board. Our program is designed to boot the BeagleBone from a raw binary file\r\ncalled _MLO_ stored on a FAT32 SDHC microcard. The binary file includes a\r\nspecial boot header comprised of two 32-bit integers. The program is loaded\r\nfrom SD-card into RAM memory and subsequently executed. When switching on\r\nthe BeagleBone black, the boot button (S2) must be pressed while powering\r\nup the board. The program toggles the first user LED (LED1 on `port1.21`).\r\n\r\nThe 64-bit multi-core ARM(R) `target am6254_soc` runs on the PocketBeagle2.\r\nThis exciting development launches the `ref_app` into the 64-bit microcontroller world.\r\nThe inspiration for this project, again, comes from the unbelievably\r\ncreative workspaces of\r\n[`github.com/Chalandi`](https://github.com/Chalandi)\r\nwith the repo\r\n[`Chalandi/Baremetal_TI_AM6254_multicore_nosdk`](https://github.com/Chalandi/Baremetal_TI_AM6254_multicore_nosdk).\r\nIn his work, he has modified the SBL and also undertaken several non-trivial adaptions to the core startups\r\nin order to take this chip down the path of full bare-metal\r\ncontrol - with no use of the SDK.\r\nThe modified SBL and its links and copyright info can be found\r\nat the [`pocketbeagle2_baremetal_sbl`](https://github.com/Chalandi/pocketbeagle2_baremetal_sbl)\r\nrepository.\r\n\r\nThe MICROCHIP(R) [former ATMEL(R)] AVR(R) configuration\r\ncalled `target atmega2560` runs\r\non the ARDUINO(R) MEGA compatible board.\r\nThe program toggles the orange LED on `portb.7`.\r\nAt the moment, the environment and build for this\r\ntarget are set up for $64~\\text{kByte}$ program code.\r\nIf the fully available $128~\\text{kByte}$ code space\r\nneeds to be used, then adaptions to the compiler switches,\r\nlinker file, startup-code and interrupt-vector table\r\nwill likely be necessary. For this potential adaption, see also\r\n[issue 593](https://github.com/ckormanyos/real-time-cpp/issues/593).\r\n\r\nThe MICROCHIP(R) [former ATMEL(R)] ATmega4809 configuration\r\ncalled `target atmega4809` runs\r\non an ARDUINO(R) EVERY compatible board clocked\r\nwith the internal resonator at $20~\\text{MHz}$.\r\nThe program toggles the yellow LED on `porte.2` (i.e., `D5`).\r\n\r\nThe MICROCHIP(R) [former ATMEL(R)] AVR(R) configuration\r\ncalled `target avr` (as used in the book) runs\r\non a classic ARDUINO(R) compatible board.\r\nThe program toggles the yellow LED on `portb.5`.\r\n\r\nThe ARM(R) 1176-JZF-S configuration (called `target bcm2835_raspi_b`) runs on the\r\nRaspberryPi(R) Zero (PiZero) single core controller.\r\nThis project creates a bare-metal program for the PiZero.\r\nThis program runs independently from any kind of `*nix` distro on the board.\r\nOur program is designed to boot the PiZero from a raw binary file.\r\nThe raw binary file is called _kernel.img_ and it is stored on a FAT32 SDHC\r\nmicrocard. The program _objcopy_ can be used to extract raw binary\r\nfrom a ELF-file using the output flags `-O binary`.\r\nThe kernel.img file is stored on the SD card together with\r\nthree other files: bootcode.bin, start.elf and (an optional)\r\nconfig.txt, all described on internet. A complete set of\r\n[PiZero boot contents for an SD card](./ref_app/target/micros/bcm2835_raspi_b/startup/SD_CARD/PiZero)\r\nrunning the bare-metal reference application are included in this repo.\r\nThe program toggles the GPIO status LED  at GPIO index `0x47`.\r\n\r\nThe NXP(R) OM13093 LPC11C24 board ARM(R) Cortex(R)-M0+ configuration\r\ncalled `target lpc11c24` toggles the LED on `port0.8`.\r\n\r\nTarget `nxp_imxrt1062` runs on the Teensy 4.0 board from Spark Fun.\r\nThe orange user-LED is toggled.\r\n\r\nThe `riscvfe310` target utilizes the SiFive RISC-V FE310 SoC\r\non Spark Fun's commercially available _Red_ _Thing_ _Plus_ Board.\r\nThe blue LED on port `GPIO0.5` is toggled.\r\n\r\nThe `rpi_pico_rp2040` target configuration employs the\r\nRaspberryPi(R) Pico RP2040 with dual-core ARM(R) Cortex(R)-M0+\r\nclocked at $133~\\text{MHz}$. The low-level startup boots through\r\ncore0 which then starts up core1 via specific protocol.\r\nCore1 carries out the blinky application while core0 enters an endless,\r\nidle loop. Ozone debug files are supplied for this system\r\nfor those interested. Reverse engineering of the complicated\r\nand scantly documented dual-core startup originated in\r\nand have been taken (with many thanks) from the\r\n[`Chalandi/Blinky_Pico_dual_core_nosdk`](https://github.com/Chalandi/Blinky_Pico_dual_core_nosdk).\r\nrepository.\r\n\r\nThe `rpi_pico2_rp2350` target configuration employs the\r\nRaspberryPi(R) Pico2 RP2350 with dual-core ARM(R) Cortex(R)-M33\r\nclocked at $150~\\text{MHz}$. It has essentially the same boot\r\nstructure as the `2040`. Similarly the dual-core startup was\r\npioneered by the efforts revealed in the modernized\r\n[`Chalandi/Blinky_Pico2_dual_core_nosdk`](https://github.com/Chalandi/Blinky_Pico2_dual_core_nosdk).\r\nrepository.\r\n\r\nThe ARM(R) Cortex(R)-M3 configuration (called `target stm32f100`) runs on\r\nthe STM32VL-DISCOVERY board commercially available from ST Microelectronics(R).\r\nThe program toggles the blue LED on `portc.8`.\r\n\r\nThe first ARM(R) Cortex(R)-M4F configuration (called `target stm32f407`) runs on\r\nthe STM32F4-DISCOVERY board commercially available from ST Microelectronics(R).\r\nThe program toggles the blue LED on `portd.15`.\r\n\r\nAnother ARM(R) Cortex(R)-M4F configuration (called `target stm32f446`) runs on\r\nthe STM32F446-NUCLEO-64 board commercially available from ST Microelectronics(R).\r\nThe program toggles the green LED on `porta.5`.\r\nAn Ozone debug file is supplied for this system for those interested.\r\n\r\nThe first ARM(R) Cortex(R)-M7 configuration (called `target stm32h7a3`) runs on\r\nthe STM32H7A3-NUCLEO-144 board commercially available from ST Microelectronics(R).\r\nThe program toggles the green LED on `portb.0`.\r\n\r\nThe second ARM(R) Cortex(R)-M3 configuration (called `target stm32l100c`)\r\nruns on the STM32L100-DISCOVERY board commercially available from\r\nST Microelectronics(R). The program toggles the blue LED on `portc.8`.\r\n\r\nThe third ARM(R) Cortex(R)-M3 configuration (called `target stm32l152`)\r\nruns on the STM32L152C-DISCOVERY board commercially available from\r\nST Microelectronics(R). The program toggles the blue LED on `portb.6`.\r\n\r\nThe `target v850es_fx2` implementation uses a classic Renesas(R) V850es/Fx2 core.\r\nThe upd703231 microcontroller derivative on an F-Line _Drive_ _It_\r\nstarter kit is used.\r\n\r\nThe adaption for `wch_ch32v307` runs on the WCH CH32v307 board.\r\nIt uses the RISC-V CH32v307 microcontroller from\r\nNanjing Qinheng Microelectronics Co., Ltd.\r\nThe blue LED1 manually connected to port `GPIOC.0`\r\nvia wire-connection provides the blinky toggle.\r\nThe similar adaption `wch_ch32v307_llvm` is essentially\r\nthe same except it uses an LLVM RISC-V toolchain\r\ninstead of GCC RISC-V.\r\n\r\nThe Espressif (`target xtensa_esp32_s3`) port for NodeMCU ESP32-S3\r\nfeatures a bare-metal startup _without_ using any of the SDK.\r\nThe bare-metal startup was taken from the work of\r\n[Chalandi/Baremetal_esp32s3_nosdk](https://github.com/Chalandi/Baremetal_esp32s3_nosdk).\r\nThe multicore system first boots core0 which subsequently\r\nstarts up core1 and also starts up the RISC-V-ULP coprocessor core.\r\nBlinky runs in the standard `ref_app`\r\non core0 toggling `port7` while an endless timer loop on core1\r\ntoggles `port6`. These LED ports togle in near unison\r\nat the normal blinky feequency of $\\frac{1}{2}~\\text{Hz}$.\r\nThe RISC-V-ULP coprocessor performs an LED dimming\r\nshow on `port17` at a randomly chosen frequency\r\nthat is asynchronous to the regular blinky show.\r\nSelf-procured LEDs and resistors need to be fitted externally\r\non the port pins in order to observe blinking and dimming\r\non this particular board.\r\n\r\nThe Espressif (`target xtensa32`) port for NodeMCU ESP32\r\nuses a subset of the\r\n[Espressif SDK](https://github.com/espressif/esp-idf)\r\nto run the reference application.\r\nThis somewhat unconventional implementation configures\r\n$1$ single OS task running exclusively on $1$ CPU core only.\r\nAdditional reductions in code/memory size(s) have been accomplished\r\nvia selective stubbing of library functions.\r\n\r\nFor other compatible boards, feel free contact me directly or submit\r\nan issue requesting support for your desired target system.\r\n\r\n## Benchmarks\r\n\r\n[Benchmarks](./ref_app/src/app/benchmark)\r\nprovide scalable, portable means for identifying\r\nthe performance and the performance class of the microcontroller.\r\nFor more information, see the detailed information\r\non the [benchmarks](./ref_app/src/app/benchmark) pages.\r\n\r\n## All-Bare-Metal\r\n\r\nProjects in this repo are programmed _OS-less_ in pure\r\nall-bare-metal mode making use of self-written startup code.\r\nNo external libraries other than native C++ and its own\r\nstandard libraries are used.\r\n\r\nConsider, for instance, the BeagleBone Black Edition\r\n(BBB, also known as `target am335x`) which is one\r\nof several popular\r\ntarget systems supported in this repository.\r\nThe projects on this board boot from the binary image file\r\n_MLO_ on the SD card. Like all other projects in this repository,\r\nthe BBB projects perform their own\r\n[static initialization](./ref_app/target/micros/am335x/startup)\r\nand\r\n[chip initialization](./ref_app/src/mcal/am335x/mcal_cpu_detail_secure.cpp)\r\n(i.e., in this particular case chip initialization\r\nof the ARM(R) 8 AM335x processor).\r\nThe BBB projects, following initialization,\r\nsubsequently jump to `main()` which\r\ninitializes the\r\n[`am335x` MCAL](./ref_app/src/mcal/am335x)\r\nand starts our self-written\r\n[multitasking scheduler](./ref_app/src/os).\r\n\r\nThe image below\r\ndepicts the bare-metal BeagleBone Black Edition\r\nin action. In this bare-metal operation mode, there is\r\nno running `*nix` OS on the BBB, no keyboard,\r\nno mouse, no monitor, no debug interface and no emulator.\r\n\r\nThe microcontroller on the board is cyclically performing\r\none of the [benchmarks](./ref_app/src/app/benchmark)\r\nmentioned above. The first\r\nuser LED is toggled on `port1.21` in multitasking operation\r\nand the oscilloscope captures\r\na real-time measurement of the benchmark's time signal\r\non digital I/O `port1.15`, header pin `P8.15` of the BBB.\r\n\r\n![](./images/bare_metal_bbb.jpg)\r\n\r\n## Continuous Integration (CI)\r\n\r\nContinuous integration uses GitHub Actions programmed in YAML.\r\nThe [CI script](.github/workflows/real-time-cpp.yml)\r\nexercises various target builds, example builds\r\nand benchmark builds/runs on GitHub Actions' instances\r\nof `ubuntu-latest`, `windows-latest` and `macos-latest`\r\nusing GNUmake, CMake or MSBuild\r\ndepending on the particular OS/build/target-configuration.\r\n\r\n### Build Status\r\n\r\nAt the moment, there are distinct and separate, major individual builds.\r\nEach build emphasizes different capabilities of the companion code.\r\n\r\n  - Build `ref_app` and benchmarks for various targets and hosts on  both `*nix` as well as `Win*`.\r\n  - Build the examples for selected hosts on `*nix`.\r\n  - Build the code snippets for selected hosts on `*nix`.\r\n  - Build the benchmarks for selected embedded targets and for selected hosts on `*nix`.\r\n\r\nHere are the build status badges.\r\n\r\n\u003cp align=\"center\"\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp.yml/badge.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp-examples.yml/badge.svg\" alt=\"Build Examples\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp-snippets.yml/badge.svg\" alt=\"Build Snippets\"\u003e\u003c/a\u003e\r\n    \u003ca href=\"https://github.com/ckormanyos/real-time-cpp/actions\"\u003e\r\n        \u003cimg src=\"https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp-benchmarks.yml/badge.svg\" alt=\"Build Benchmarks\"\u003e\u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\nThe build status badges represent the state of the nightly CI builds and tests.\r\n\r\n## Modern `avr-gcc` Toolchain\r\n\r\nThe repo [ckormanyos/avr-gcc-build](https://github.com/ckormanyos/avr-gcc-build)\r\nbuilds up-to-date `avr-gcc` toolchains for `x86_64-linux-gnu` and `x86_64-w64-mingw32`.\r\nShell and YAML scripts build `avr-gcc` directly from source on GHA runner(s).\r\nIn addition, occasional GitHub-releases provide pre-built\r\n`avr-gcc` toolchains for `x86_64-linux-gnu` and `x86_64-w64-mingw32`.\r\n\r\nThis repo is a great place to learn how to build your own `avr-gcc` toolchain\r\nfrom source. The straightforward, well-described shell and YAML scripts\r\nare easy to understand, use or adapt.\r\n\r\nAs mentioned above, a much more detailed and wider scope\r\nof embedded toolchains are described in\r\n[ckormanyos/real-time-cpp-toolchains](https://github.com/ckormanyos/real-time-cpp-toolchains).\r\nThese include the afore-mentioned `avr-gcc` toolchain as well as others\r\n(some hard-to-find elsewhere).\r\n\r\n## GNU/GCC Compilers\r\n\r\nThe reference application and the examples (also the code snippets)\r\ncan be built with GNU/GCC compilers and GNUmake on `*nix`.\r\nGNU/GCC cross compilers and GNUmake on `*nix` are assumed to\r\nbe available in the standard executable path,\r\nsuch as after standard get-install practices.\r\n\r\nSome ported GNU/GCC cross compilers for `Win*` are available in the\r\n_toolchains_ repository,\r\n[real-time-cpp-toolchains](https://github.com/ckormanyos/real-time-cpp-toolchains).\r\nThese can be used with the microcontroller solution configurations\r\nin the reference application when developing/building\r\nwithin Microsoft(R) VisualStudio(R). Various other GNU\r\ntools such as GNUmake, SED, etc. have been ported\r\nand can be found there. These are used in the Makefiles\r\nWhen building cross embedded projects such as `ref_app`\r\non `Win*`.\r\n\r\nIn the reference application on `Win*`,\r\nthe Makefiles use a self-defined, default location\r\nfor the respective tools and GNU/GCC toolchains.\r\nThe toolchain default location on `Win*` is\r\n`./ref_app/tools/Util/msys64/usr/local`.\r\nThis particular toolchain location is inspired by the\r\n[`msys2`/`mingw64`](https://www.msys2.org)\r\nsystem.\r\n\r\nToolchains intended for cross MSVC/GCC builds on `Win*`\r\nshould be located there.\r\nThese toolchains are not part of this repository\r\nand it is necessary to get these toolchains separately\r\nwhen using the supported `Win*` builds when optionally using\r\nVisualStudio(R) Projects with CMD Batch.\r\n\r\nDetailed instructions on getting and using the\r\ntoolchains for cross MSVC/GCC builds on `Win*`\r\nare available in the\r\n[real-time-cpp-toolchains](https://github.com/ckormanyos/real-time-cpp-toolchains)\r\nrepository. These instructions provide guidance on using these toolchains\r\nwhen selecting the Microsoft(R) VisualStudio(R) project\r\n(via the usual, above-described MSVC/`Win*`-way) to build the reference application.\r\n\r\n## C++ Language Adherence\r\n\r\nA GNU/GCC port (or other compiler)\r\nwith a high level of C++14 (or higher) awareness and adherence\r\nsuch as GCC 5 through 13 (higher generally being more advantageous)\r\nor MSVC 14.2 or higher is required for building the reference application\r\n(and the examples and code snippets).\r\n\r\nSome of the code snippets demonstrate language elements not only from C++14,\r\nbut also from C++17, 20, 23 and beyond. A compiler with C++17 support\r\nor even C++20, 23 support (such as GCC 13, clang 15, MSVC 14.3, or higher) can,\r\ntherefore, be beneficial for success with *all* of the code snippets.\r\n\r\n### Licensing\r\n\r\n  - The source code written for this repo is primarily licensed under [Boost Software License 1.0](./LICENSE_1_0.txt).\r\n  - Small parts of the self-written [STL](https://github.com/ckormanyos/real-time-cpp/tree/master/ref_app/src/util/STL) such as `\u003cchrono\u003e`, `\u003cratio\u003e` and some internal traits-headers are licensed under the [GNU General Public License Version 3](./COPYING3) or higher.\r\n","funding_links":[],"categories":["MCU programming"],"sub_categories":["Bare-metal programming (Don't need MCU)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckormanyos%2Freal-time-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fckormanyos%2Freal-time-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fckormanyos%2Freal-time-cpp/lists"}