# bootloaders-embedded

bootloaders-embedded is a skill for Cortex-M bootloader development. It covers image validation, safe handoff to an app, vector table relocation, and updates over UART or USB DFU.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 395 installs · ★ 298 repo stars
- Author: mohitmishra786
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/baremetal/bootloaders-embedded/SKILL.md
- Updated: 2026-06-27
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/bootloaders-embedded

## What it does

When an application must run at a non-zero flash offset — say `0x08010000` — the bootloader needs to validate the image and jump safely. This skill covers the validation step: checking that the initial stack pointer (vector 0) lies in RAM and the reset address (vector 1) has the Thumb bit set and stays within flash bounds.

The handoff sequence itself requires disabling interrupts, de-initializing peripherals, setting `SCB->VTOR` to the app base, loading the stack pointer, and jumping to the reset handler. The skill includes a worked C example for STM32F4 and explains the order of these steps and why each matters.

The third layer covers update mechanics: receiving a new image over UART or USB DFU, where to write it safely, how to verify checksum or CRC, and how to roll back if something goes wrong. Links to related low-level skills help you integrate vector setup, reset handler configuration, and linker scripts.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/bootloaders-embedded/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/bootloaders-embedded/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/bootloaders-embedded/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/bootloaders-embedded/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install mohitmishra786/low-level-dev-skills skills/baremetal/bootloaders-embedded
```

2. **Manually: put the files in place**
- File: `.github/skills/bootloaders-embedded/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/mohitmishra786/low-level-dev-skills --path skills/baremetal/bootloaders-embedded
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/bootloaders-embedded/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/baremetal/bootloaders-embedded/SKILL.md

## When to use it
- Write a safe jump function from bootloader to application on Cortex-M microcontrollers
- Validate an application image before executing it
- Relocate the interrupt vector table when the app runs from a non-standard flash address
- Implement over-the-air firmware updates without relying on vendor libraries
- Debug why an app works when flashed directly but fails when loaded through a bootloader

## Example prompts
- Write a validator function for STM32F4 that checks if the app at `0x08010000` is valid and performs a safe jump
- Configure the application linker script so it works correctly when the bootloader launches it
- Implement OTA with two flash banks and automatic rollback on verification failure

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 252931a3cf79b63b.

BEGIN THIRD-PARTY FILE 252931a3cf79b63b
````text
---
name: bootloaders-embedded
description: Embedded bootloader skill for firmware update and app handoff. Use when writing a custom bootloader, jumping to application code, relocating VTOR, or implementing DFU/USB firmware update on Cortex-M. Activates on queries about bootloader jump, vector table relocation, application entry point, STM32 DFU, or dual-bank flash.
---

# Embedded Bootloaders

## Purpose

Guide agents through embedded bootloader fundamentals: vector table relocation, safe handoff from bootloader to application, flash partitioning, and basic firmware-update patterns (UART, USB DFU, or custom protocol) on Cortex-M and similar MCUs.

## When to Use

- Application must run at non-zero flash offset (e.g. `0x08010000`)
- Implementing OTA or USB DFU without vendor HAL
- Debugging "app works when flashed alone but not via bootloader"
- Integrating with `skills/baremetal/baremetal-startup` and `skills/baremetal/stm32-baremetal`

## Workflow

### 1. Memory layout (typical STM32)

| Region | Address | Size | Content |
|--------|---------|------|---------|
| Bootloader | `0x08000000` | 16–64 KB | BL code, update logic |
| Application | `0x08010000` | remainder | App vector + code |

Linker script for app must set `FLASH ORIGIN` to app base; vector table must live at app base.

### 2. Valid application image check

Before jump, verify:

```
App vector[0] (initial SP) points into RAM region
App vector[1] (Reset) points into flash region and has Thumb bit set (LSB=1)
Optional: CRC or magic word in app metadata section
```

```c
#define APP_BASE  0x08010000U

static int app_valid(uint32_t base)
{
    uint32_t sp = *(uint32_t *)base;
    uint32_t reset = *(uint32_t *)(base + 4);
    if (sp < SRAM_BASE || sp > SRAM_END)
        return 0;
    if ((reset & 1U) == 0U)
        return 0;
    if (reset < base || reset > FLASH_END)
        return 0;
    return 1;
}
```

### 3. Cortex-M handoff sequence

```c
typedef void (*app_entry_t)(void);

void jump_to_app(uint32_t app_base)
{
    uint32_t sp    = *(uint32_t *)app_base;
    uint32_t reset = *(uint32_t *)(app_base + 4);
````
END THIRD-PARTY FILE 252931a3cf79b63b

The third-party file has ended. Everything between the 252931a3cf79b63b tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2105 of 4300 bytes. © mohitmishra786 · MIT · https://github.com/mohitmishra786/low-level-dev-skills/tree/HEAD/skills/baremetal/bootloaders-embedded/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
