explaingit

cpq/bare-metal-programming-guide

4,647CAudience · developerComplexity · 4/5LicenseSetup · moderate

TLDR

A step-by-step guide for programming microcontrollers from scratch using only GCC and the chip's datasheet, without any framework like Arduino or Keil. Learn how embedded programming works at the register level.

Mindmap

mindmap
  root((bare-metal guide))
    What it does
      Programs microcontrollers
      Explains register control
      No frameworks needed
    Tech stack
      C language
      GCC compiler
      GNU Make
      ARM architecture
    Boards covered
      STM32 Cortex-M4
      Raspberry Pi RP2040
      ESP32-C3
      Texas Instruments
    Use cases
      LED blink and serial debug
      Serial CLI interface
      Flash file system
      Web server dashboard
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Set up an LED blink program with serial debug output on an STM32 or RP2040 board without any framework.

USE CASE 2

Build a command-line interface over a serial connection on a bare-metal microcontroller.

USE CASE 3

Implement a file system on a microcontroller's onboard flash memory from scratch.

USE CASE 4

Add a web server with a device dashboard to an embedded system without an operating system.

Tech stack

CGCCGNU MakeARMCortex-M4RP2040ESP32

Getting it running

Difficulty · moderate Time to first run · 1h+

Requires an ARM GCC compiler, GNU Make, a supported hardware dev board, and a chip-specific flashing tool.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

This repository is a written guide for developers who want to program microcontrollers from scratch, using only a GCC compiler and the chip's official datasheet, without relying on any framework like Arduino, Cube, or Keil. The author's goal is to explain the fundamentals of how embedded programming works at a low level, so readers understand what those higher-level frameworks are doing underneath. A microcontroller is a small self-contained computer, typically used to control physical hardware such as lights, motors, or sensors. Programming one from scratch means writing directly to the chip's memory registers, setting up interrupt handlers, and managing peripherals like general-purpose input/output pins yourself. This guide walks through all of that step by step. Each chapter comes with complete, buildable source code. The examples start very simply and grow in complexity across chapters. The final template projects cover four scenarios: a basic LED blink with debug output over a serial connection, a command-line interface over serial, a file system stored in the chip's onboard flash memory, and a working web server with a device dashboard interface. The guide covers several different development boards and chip families. These include boards from ST Microelectronics (with Cortex-M4 and Cortex-M33 chips), Microchip, Texas Instruments, the Raspberry Pi RP2040, and an Espressif ESP32-C3. Each board entry in the README links to its datasheet and a corresponding template project you can use as a starting point. Setup instructions are provided for macOS, Linux, and Windows. The required tools are an ARM GCC compiler, GNU Make, a flashing tool to transfer code to the board, and Git for downloading the repository. The project is licensed under MIT. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Write C code to toggle an LED on an STM32 Cortex-M4 board by writing directly to GPIO registers without using HAL or Arduino.
Prompt 2
Help me set up UART serial output on an RP2040 from scratch using bare-metal C and register configuration from the datasheet.
Prompt 3
I want to implement a simple command-line interface over UART on a microcontroller using no OS and no RTOS, just registers and interrupts.
Prompt 4
Guide me through setting up a bare-metal web server on an ESP32-C3 using direct register access in C.
Prompt 5
What are the minimum steps to flash a compiled bare-metal C binary onto an STM32 board using GCC and a flashing tool?
Open on GitHub → Explain another repo

← cpq on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.