본문으로 건너뛰기
cccskills
무료GitHub에 공개

bootloaders-embedded

Use when writing a custom bootloader, jumping to application code, relocating VTOR, or implementing DFU/USB firmware update on Cortex-M. Not for reset-to-main: use baremetal-startup.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md6.5 KB
  • agents/openai.yaml210 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Embedded bootloaders

Contract

FieldBound contract
TriggerAn application must run at a non-zero flash offset, a bootloader must validate and jump to it, a firmware update path (UART, USB DFU, custom protocol) is being written, or an application works when flashed alone but fails when launched by the bootloader.
AuthorityRead-only: emits the flash layout, validation checks, handoff sequence, and update-safety rules to chat; the user places them in the project. Rollback is not needed because no file is written. No remote mutation.
Side effectChat output only.
DoneThe flash partition table, the application validity check, the ordered handoff sequence, and the update commit rule are stated for the target part, and the application-side VTOR and linker changes are named.

Inputs

  • Target part and its flash map: base address, sector or page sizes, and whether it has two banks.
  • Bootloader size budget and the chosen application base address.
  • Update transport (UART, USB DFU, external flash, none).
  • Where the update request flag lives (RTC backup register, GPIO strap, magic word in RAM).
  • Whether the vendor part has a system-memory bootloader and which transports it lists in the vendor application note (AN2606 for STM32).

Procedure

  1. Fix the flash layout and relink both images to it. The bootloader starts at the flash base; the application starts at a sector boundary above it and its vector table sits at that base. Done when: the application linker script sets FLASH ORIGIN to the application base and the bootloader never writes below it.

    RegionAddress (STM32 example)Content
    Bootloader0x08000000Boot code and update logic, typically 16 KB to 64 KB
    Application0x08010000Application vector table then code
  2. Validate the application image before jumping. Vector 0 must point into RAM; vector 1 must point into the application's flash range and carry the Thumb bit (bit 0 set). Add a CRC or magic word in an application metadata section when the update path can leave a half-written image. Done when: the check rejects an erased sector (0xFFFFFFFF in both vectors) and accepts a good image.

    #define APP_BASE 0x08010000U
    
    static int app_valid(uint32_t base)
    {
        uint32_t sp    = *(volatile uint32_t *)base;
        uint32_t reset = *(volatile uint32_t *)(base + 4U);
        if (sp < SRAM_BASE || sp > SRAM_END)   return 0;
        if ((reset & 1U) == 0U)                return 0;   /* Thumb bit */
        if (reset < base || reset > FLASH_END) return 0;
        return 1;
    }
    
  3. Hand off to the application in this order: disable interrupts, stop SysTick, clear every NVIC enable and pending bit, de-initialize any peripheral the bootloader used (UART, USB, DMA), write SCB->VTOR to the application base, load the main stack pointer from vector 0, barrier, then branch to vector 1. Done when: the sequence runs with no interrupt enabled between the NVIC clear and the branch.

    typedef void (*app_entry_t)(void);
    
    void jump_to_app(uint32_t app_base)
    {
        uint32_t sp    = *(volatile uint32_t *)app_base;
        uint32_t reset = *(volatile uint32_t *)(app_base + 4U);
    
        __disable_irq();
        SysTick->CTRL = 0;
        for (unsigned i = 0; i < 8; i++) {
            NVIC->ICER[i] = 0xFFFFFFFFU;
            NVIC->ICPR[i] = 0xFFFFFFFFU;
        }
        /* de-init bootloader peripherals here, or reset them through RCC */
    
        SCB->VTOR = app_base;
        __set_MSP(sp);
        __DSB();
        __ISB();
        ((app_entry_t)reset)();   /* never returns */
    }
    
  4. Make the application own its vector table. Either the bootloader's VTOR write is trusted, or the application's Reset_Handler writes SCB->VTOR = APP_BASE itself before enabling any interrupt. Prefer the second: it also lets the application run when flashed alone. Done when: an interrupt raised in the application reaches the application's handler.

  5. Lay out the bootloader main loop. Initialize the minimum clock and the update transport, read the update request flag, and take one of three paths: receive and program an image, jump to a valid application, or stay in the bootloader shell. Done when: every path terminates in a jump or in the shell, and none falls through.

  6. Keep the update commit safe. Write the new image to a scratch region or the inactive bank, verify its CRC in place, then switch the active-image marker in one atomic write (metadata pointer or bank swap). Never erase the only valid image without a recovery path, and only service the watchdog after the verified commit. Done when: a power loss at any point leaves at least one valid, bootable image.

  7. Distinguish the vendor system-memory bootloader from yours. STM32 parts enter the ROM bootloader when BOOT0 selects system memory at reset; the transports it offers (USART, USB DFU, others) vary by part and are listed in AN2606. It is not your flash bootloader and does not replace it. Done when: the design states which bootloader handles which recovery case.

  8. Verify: flash both images, power-cycle, confirm the jump, then erase the application sector and confirm the bootloader stays in its shell instead of faulting. Done when: both outcomes are observed on the target.

Failure and recovery

SymptomCauseFix
HardFault right after the jumpStack pointer invalid or Thumb bit clear in vector 1Run app_valid first; relink the application if the vectors are wrong.
Interrupts land in bootloader handlersVTOR still points at the bootloader tableWrite SCB->VTOR before enabling interrupts, in the application's Reset_Handler.
Application works standalone, fails via bootloaderApplication still linked at the flash baseSet the application linker FLASH ORIGIN to the application base.
Serial garbage after the jumpBootloader left its UART or DMA runningDe-initialize or reset the peripherals before the branch.
Device bricked after an updatePower loss during erase of the only imageUse a scratch region or dual bank with an atomic active marker.

Output

For the target part: a flash partition table, the application validity check, the ordered handoff routine, the application-side VTOR and linker changes, the bootloader main-loop paths, and the update commit rule that keeps one bootable image at every instant.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when configuring ADC sampling time, DMA-driven ADC, calibration, or DAC channel setup on bare-metal MCUs. Not for the DMA stream itself: use dma-baremetal.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

af-xdp

무료

Use when creating AF_XDP sockets, configuring UMEM and XSK rings, writing an XDP redirect program, or choosing copy versus zero-copy mode. Not for full kernel bypass: use dpdk.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a completed session needs an agent-environment retrospective. Not for an engineering retrospective from telemetry: use engineering-retrospective.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

Use when a redacted, trimmed agent transcript must be appended to a GitHub PR or issue body, with human approval and preview. Not for automated or model-initiated insertion.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

agents-md

무료

Use when a repo needs agent setup, AGENTS.md added or made lean, CLAUDE.md audited, or agent instructions scored or pruned. Not for remote, credential, publish, deploy, or irreversible changes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

OutlineDriven/odin-claude-plugin372026년 9월 29일 업데이트

OutlineDriven의 스킬 모두 보기

이 스킬의 문제 신고