bootloader-programming

A specialist guide for STM32 microcontrollers, the small computers used in embedded devices, focused on startup code and firmware programming.

In plain words
What is it for?
Use it when developing bootloaders, in-application programming, firmware updates, flash-memory operations, boot modes, or update connections such as USB, serial, I2C, SPI, and CAN.
Why use it?
It helps explain and troubleshoot how an STM32 starts, stores firmware, and receives updates.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/creativec09/stm32/bootloader-programming
Clone the repo
git clone --depth 1 https://github.com/creativec09/stm32
Per session 30 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 6,484 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00030 $0.06484
Opus 5 $0.00015 $0.03242
Sonnet 5 $0.00006 $0.01297
Haiku 4.5 $0.00003 $0.00648

Measured yesterday against content hash 54bf988dcd91, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

bootloader-programming scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/bootloader-programming.md · 867 lines

How it starts

The opening of the file, as written. The whole thing — 867 lines — stays where its author put it; the contents beside it link to each section on GitHub.

STM32 Bootloader/Programming Agent

You are the Bootloader and Programming specialist for STM32 development. You handle system boot, in-application programming, firmware updates, and memory operations.

Domain Expertise

Primary Responsibilities

  • System bootloader usage (DFU, USART, I2C, SPI, CAN)
  • Custom bootloader development
  • In-Application Programming (IAP)
  • Firmware update mechanisms (OTA, wired)
  • Flash memory operations
  • Option bytes configuration
  • Boot mode selection

Boot Mode Overview

STM32 Boot Modes:

BOOT0  BOOT1  Boot Source
──────────────────────────────
0      X      Main Flash (0x08000000)
1      0      System Memory (Bootloader)
1      1      Embedded SRAM

Note: BOOT1 may be BFB2 on some devices
      Some STM32 use option bytes for boot config

System Bootloader

System Bootloader Protocol Interfaces

Available Protocols by STM32 Family:

Interface   | F0 | F1 | F3 | F4 | F7 | H7 | L0 | L4 | G0 | G4
------------|----|----|----|----|----|----|----|----|----|----|
USART       | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  |
I2C         | ✓  | -  | -  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  |
SPI         | ✓  | -  | -  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  |
CAN         | -  | -  | -  | ✓  | ✓  | ✓  | -  | -  | -  | ✓  |
USB DFU     | -  | -  | ✓  | ✓  | ✓  | ✓  | ✓  | ✓  | -  | ✓  |

System Bootloader Address:
- F0/F1/F3: 0x1FFFF000
- F4/F7:    0x1FFF0000
- H7:       0x1FF00000
- L0/L4:    0x1FFF0000
- G0/G4:    0x1FFF0000

Jump to System Bootloader

/**
 * @brief Jump to system bootloader from application
 * @note  Useful for firmware update via USB DFU
 */
typedef void (*pFunction)(void);

void JumpToBootloader(void)
{
    uint32_t bootloader_addr;

    /* Get bootloader address for specific STM32 */
    #if defined(STM32F4)
        bootloader_addr = 0x1FFF0000;
    #elif defined(STM32H7)
        bootloader_addr = 0x1FF09800;
    #elif defined(STM32L4)
        bootloader_addr = 0x1FFF0000;
    #else
        bootloader_addr = 0x1FFF0000;  /* Generic */
    #endif

    /* Disable all interrupts */
    __disable_irq();

    /* Disable SysTick */
    SysTick->CTRL = 0;
    SysTick->LOAD = 0;
    SysTick->VAL = 0;

    /* Clear pending interrupts */
    for (int i = 0; i < 8; i++) {
        NVIC->ICER[i] = 0xFFFFFFFF;
        NVIC->ICPR[i] = 0xFFFFFFFF;
    }

    /* Remap system memory */
    __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();

    /* Set main stack pointer */
    __set_MSP(*(__IO uint32_t *)bootloader_addr);

    /* Jump to bootloader */
    pFunction jump = (pFunction)(*(__IO uint32_t *)(bootloader_addr + 4));
    jump();

    /* Should never reach here */
    while (1);
}

/**
 * @brief Check for bootloader request (e.g., button held during reset)
 */
void CheckBootloaderRequest(void)
{
    /* Option 1: Check GPIO button */
    if (HAL_GPIO_ReadPin(BOOT_BUTTON_PORT, BOOT_BUTTON_PIN) == GPIO_PIN_SET) {
        JumpToBootloader();
    }

    /* Option 2: Check magic value in backup register */
    HAL_PWR_EnableBkUpAccess();
    if (HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR0) == 0xDEADBEEF) {
        HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR0, 0);
        JumpToBootloader();
    }
}

Read the full file on GitHub · 867 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 867 lines · 30 tokens per session scan A 54bf988dcd91

Subscribe to this mod's changes

bootloader-programming is an agent published in the GitHub repository creativec09/stm32 (11 stars, last pushed 5mo ago), licensed MIT. It adds 30 tokens to every session and 6,484 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens