Skip to content

po4yka/rust-skills / skills/rust-embedded-no-std

rust-embedded-no-std

Verified

Use when writing, porting, or debugging bare-metal Rust firmware or no_std libraries, such as embedded-hal drivers, Embassy or RTIC tasks, flashing and logging with probe-rs and defmt, memory.x and linker scripts, panic and allocator policy, interrupt-shared state, and atomics on cores without compare-and-swap. Triggers on embedded Rust, cortex-m-rt, thumbv6m, critical-section, portable-atomic, panic_handler, or HardFault.

references/dma.md

View on GitHub
# DMA ownership, ordering, and cancellation

Use these rules when firmware starts, completes, or cancels a DMA transfer, and
when you review a DMA driver.

## Ownership

Treat DMA as concurrent access by hardware. Keep its buffer alive and at a
stable address until completion. Transfer ownership to the driver when its API
supports that model. Apply the chip's cache clean and invalidate rules. The
`rust-unsafe` skill, when it is installed, has the raw-pointer and
SAFETY-comment rules for a raw DMA buffer API. Without it, put a `// SAFETY:`
comment above every `unsafe` block that names the invariant the transfer needs.

## Ordering

Order buffer access against the transfer
([embedonomicon](https://docs.rust-embedded.org/embedonomicon/dma.html)):

- Put `fence(Ordering::Release)` after the last buffer write and before the
  register write that starts DMA.
- Put `fence(Ordering::Acquire)` after the completion check and before the first
  buffer read.

On a single-core Cortex-M0 to M4F with no data cache, which does not reorder
memory transactions, `compiler_fence` with the same orderings is enough. On
every other target, use `fence`, which emits a hardware barrier. This includes a
Cortex-M7, a core with a data cache, a multi-core chip such as the RP2040, and
RISC-V. Apply the chip's cache maintenance together with the fence.

## Cancellation

Treat DMA cancellation as a separate state transition. A timeout, a `select`
branch, or a dropped future does not prove that the transfer stopped. Do not
reuse or drop the buffer until the driver confirms that DMA stopped, clears the
pending interrupt, and completes the required cache maintenance. If the driver
cannot prove that state, keep ownership quarantined and reset the peripheral
through its documented recovery path.
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall