Skip to content
Back to skills

Cortex M Knowledge Patch

ASecurity

Cortex-M

  • 25 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
developmentrustgo

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill cortex-m-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cortex M Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cortex M Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-cortex-m-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-cortex-m-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cortex-m-knowledge-patch
description: Cortex-M
version: "0.7.7"
license: MIT
metadata:
  author: Nevaberry
---


# Cortex-M compatibility guidance

Use this skill when upgrading Cortex-M crates or working with critical
sections, semihosting I/O, core operations, interrupt handlers, runtime
startup, or linker placement.

## Reference index

| Reference | Topics |
| --- | --- |
| [Migration and critical sections](references/migration-and-critical-sections.md) | Rust requirements, assembly feature changes, startup-hook deprecation, critical-section implementations |
| [Semihosting I/O](references/semihosting-io.md) | Printing results, stream types, disabling calls, debug output |
| [Core operations and interrupts](references/core-and-interrupts.md) | Unprivileged execution, interrupt target states, delays, active exception reads |
| [Runtime startup and linking](references/runtime-startup-and-linking.md) | Stack limits, memory initialization, stack painting, handlers, interrupt limits, linker alignment |

## Breaking changes and deprecations

### Rust toolchain requirements

`cortex-m` and `cortex-m-rt` use the Rust 2024 edition and require Rust
1.85 or newer. `cortex-m-semihosting` requires Rust 1.85.

See [Migration and critical sections](references/migration-and-critical-sections.md)
for the crate-specific version attributions.

### Remove the assembly feature

Remove `inline-asm` from Cargo feature lists for both `cortex-m` and
`cortex-m-semihosting`.

- In `cortex-m` 0.7.8, it has no effect and is slated for removal in a
  future major release.
- Since `cortex-m-semihosting` 0.5.0, the crate always uses inline assembly.

### Deprecated startup hook

`#[pre_init]` is deprecated in `cortex-m-rt` 0.7.6. Existing uses produce
deprecation warnings.

### Printing no longer returns an I/O result

From `cortex-m-semihosting` 0.4.0 onward, printing macros discard I/O
errors and return `()`. When upgrading from 0.3.7, where they return
`Result`, remove `?` and `.unwrap()` from their calls.

```rust
cortex_m_semihosting::hprintln!("value: {}", 42);
```

### Shared host stream type

`cortex-m-semihosting` 0.4.0 merged `HStdout` and `HStderr` into
`cortex_m_semihosting::hio::HostStream`. Use `HostStream` in type
annotations and function signatures for either host stream.

## Supply a critical-section implementation

### Linking `singleton!`

The final binary must supply a `critical-section` implementation for
`singleton!` to link. A missing implementation can produce an undefined
`_critical_section_1_0_acquire` symbol.

Enable `critical-section-single-core` on privileged single-core targets,
or choose a suitable implementation for the target, typically from its
HAL, with cross-core locking on multicore chips.

```toml
[dependencies]
cortex-m = { version = "0.7.8", features = ["critical-section-single-core"] }
```

### Synchronizing semihosting I/O

`cortex-m-semihosting` 0.6.0 uses `critical_section::Mutex` to
synchronize I/O. Firmware using this I/O must provide a
`critical-section` implementation for its target.

## Runtime startup controls

### Initialize the stack limit

Enable `set_msplim` to initialize the Main Stack Pointer Limit register
(MSPLIM) at reset. The linker exposes `_stack_end` since 0.7.5 for custom
stack-limit setup.

```toml
[dependencies]
cortex-m-rt = { version = "0.7.6", features = ["set_msplim"] }
```

### Preserve bootloader-initialized data

Enable `skip-data-copy` when the bootloader has already copied `.data`
to its runtime address and the original load address may be inaccessible
after handoff. The runtime skips that copy during reset.

```toml
[dependencies]
cortex-m-rt = { version = "0.7.6", features = ["skip-data-copy"] }
```

### Inspect stack use

Since `cortex-m-rt` 0.7.5, `paint-stack` fills the entire stack with a
fixed value at startup so you can inspect how much stack has been used.

```toml
[dependencies]
cortex-m-rt = { version = "0.7.6", features = ["paint-stack"] }
```

### Initialize RAM for hardware error detection

Enable `zero-init-ram`, introduced in `cortex-m-rt` 0.7.4, when hardware
error detection requires RAM to be initialized at startup.

```toml
[dependencies]
cortex-m-rt = { version = "0.7.6", features = ["zero-init-ram"] }
```

## Core operations and interrupt handling

### Delay behavior

`cortex-m` provides delays for drivers using `embedded-hal` 1.0.

`asm::delay(n)` now consumes at least `n` CPU cycles, including on
dual-issue Cortex-M7 cores. On other cores, the same argument will likely
take about twice as many cycles as before.

### Privilege and interrupt state

`enter_unprivileged` switches execution to unprivileged mode using the
Process Stack Pointer (`PSP`). `NVIC` exposes the `ITNS` interrupt target
state registers.

`SCB::vect_active()` now avoids the byte read that could fault on models
that require ICSR to be read as a word.

### Handler and linker details

See [Runtime startup and linking](references/runtime-startup-and-linking.md)
for handler lint expectations, the Armv8-M interrupt limit, direct
HardFault handlers, and the `.HardFault.user` input section.

In `cortex-m-rt` 0.7.7, the default `_stext` meets the `.text` section's
alignment requirement. If you explicitly override `_stext`, choose an
address meeting that requirement to avoid lld's section-alignment warning.

## Semihosting controls

### Disable semihosting calls

Enable `no-semihosting` to disable all semihosting calls.

```toml
[dependencies]
cortex-m-semihosting = { version = "0.6.0", features = ["no-semihosting"] }
```

### Send debug output to host stderr

The crate's `dbg!` macro sends output to host stderr through `heprintln!`.

```rust
cortex_m_semihosting::dbg!(2 + 2);
```

Files in this skill

  • SKILL.md5.6 KB
  • coverage.json813 B
  • references/core-and-interrupts.md889 B
  • references/migration-and-critical-sections.md1.7 KB
  • references/runtime-startup-and-linking.md2.4 KB
  • references/semihosting-io.md972 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.