bootloaders-embedded — Claude Code skill
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.
MIT 395 installs ★ 298 updated 2026-06-27
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a claude-codeWhat bootloaders-embedded 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.
What it helps with
- 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 for the agent
- Write a validator function for STM32F4 that checks if the app at
0x08010000is 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
How to install bootloaders-embedded
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a claude-code2Manually: put the files in place
~/.claude/skills/bootloaders-embedded/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/bootloaders-embedded/
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a codex2Manually: put the files in place
.agents/skills/bootloaders-embedded/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a cursor2Manually: put the files in place
.cursor/skills/bootloaders-embedded/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install mohitmishra786/low-level-dev-skills skills/baremetal/bootloaders-embedded2Manually: put the files in place
.github/skills/bootloaders-embedded/SKILL.md1Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a gemini-cli2Platform CLI
gemini skills install https://github.com/mohitmishra786/low-level-dev-skills --path skills/baremetal/bootloaders-embeddedManually: put the files in place
.devin/skills/bootloaders-embedded/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about bootloaders-embedded
How do I install bootloaders-embedded for Claude Code?
Run npx skills add mohitmishra786/low-level-dev-skills --skill bootloaders-embedded -a claude-code in your terminal, then open ~/.claude/skills/bootloaders-embedded/SKILL.md. The skill activates when you ask about bootloader jumps, VTOR relocation, or USB DFU on Cortex-M.
What does bootloaders-embedded do?
It guides you through embedded bootloader design: image validation, safe handoff from bootloader to application, vector table relocation, and firmware-update patterns (UART, USB DFU, or custom protocol) on STM32 and similar MCUs.
Why does my app work when I flash it directly but fail when loaded by the bootloader?
Most often, the app linker script still points to 0x08000000 instead of your app base like 0x08010000. Rebuild the app with the correct ORIGIN, and make sure the startup code sets SCB->VTOR to the app base before enabling interrupts.
Source text
SKILL.md · MIT
---
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);
/* Disable interrupts and de-init peripherals/boot-owned hardware */
__disable_irq();
SysTick->CTRL = 0;
for (int i = 0; i < 8; i++) {
NVIC->ICER[i] = 0xFFFFFFFFU;
NVIC->ICPR[i] = 0xFFFFFFFFU;
}
SCB->VTOR = app_base;
__set_MSP(sp);
__DSB();
__ISB();
app_entry_t entry = (app_entry_t)reset;
entry(); /* does not return */
}
```
Application must set `SCB->VTOR = APP_BASE` early in `Reset_Handler` if startup assumes relocatable vector table.
### 4. Bootloader responsibilities
```
Power-on
├── Init minimal clock + UART/USB for update
├── Check update flag in RTC backup / GPIO strap
├── If update requested → receive image, verify, program flash
└── Else if valid app → jump_to_app()
└── Else stay in bootloader shell
```
### 5. STM32 system memory DFU (factory ROM)
STM32 chips expose USB DFU in system memory when BOOT0=1. Custom bootloaders are separate — do not confuse ROM DFU with user flash BL.
### 6. Update safety
- Write to scratch sector, verify CRC, then swap metadata pointer (A/B)
- Never erase the only valid image without recovery path
- Reset watchdog only after verified commit
### 7. Agent usage
```
/bootloaders-embedded Write STM32F4 jump-to-app at 0x08010000 with VTOR setup
```
## Common Problems
| Symptom | Cause | Fix |
|---------|-------|-----|
| HardFault after jump | SP invalid or Thumb bit missing | Validate vectors; ensure `reset \| 1` |
| IRQs hit bootloader handlers | VTOR not relocated | Set `SCB->VTOR` before enabling IRQs |
| App OK standalone, fails via BL | Linker still at `0x08000000` | Relink app with correct ORIGIN |
| UART garbage after jump | BL left UART running | De-init or reset peripherals |
| Brick after OTA | Power loss mid-erase | Dual-bank or metadata rollback |
## Related Skills
- `skills/baremetal/baremetal-startup` — vector table and Reset_Handler
- `skills/baremetal/stm32-baremetal` — flash map and CMSIS
- `skills/baremetal/interrupts-and-exceptions-baremetal` — NVIC disable pattern
- `skills/embedded/linker-scripts` — VMA/LMA for split images
- `skills/embedded/openocd-jtag` — recover bricked flash
© mohitmishra786 · MIT · mohitmishra786/low-level-dev-skills