Metadata-Version: 2.4
Name: embflasher
Version: 0.1.0
Summary: Cross-platform CMSIS-DAP firmware programmer driven by CMSIS FLM flash algorithms
License-Expression: MIT
Project-URL: Homepage, https://github.com/your-org/embflasher
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Embedded Systems
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyocd<0.46,>=0.45
Dynamic: license-file

# embflasher

Cross-platform CMSIS-DAP firmware programmer driven by CMSIS FLM flash algorithms, built on [pyOCD](https://pyocd.io/).

```
CLI
 ↓
Python API (embflasher.flash)
 ↓
pyOCD
 ↓
DAPLink / CMSIS-DAP
 ↓
MCU
```

Supports macOS, Windows, and Linux (Ubuntu).

## Installation

```
pip install embflasher
```

Local development:

```
git clone <repo-url>
cd embflasher
pip install -e .
```

## Usage

```
embflasher --help
embflasher probe list
embflasher flash firmware.hex --flm chip.flm
```

Minimal usage — only `firmware` and `--flm` are required, everything else uses a sensible default (sector erase, verify on, reset on, 100k SWD frequency, `cortex_m` target):

```
embflasher flash firmware.bin --flm NS800RT50x9.FLM
```

If more than one DAPLink/CMSIS-DAP probe is connected, select one explicitly:

```
embflasher probe list
embflasher flash firmware.hex --flm chip.flm --probe <unique-id>
```

Full option list:

```
embflasher flash firmware.{bin,hex,elf} --flm chip.flm
  [--probe <unique-id>]
  [--erase auto|sector|chip]      (default: sector)
  [--no-verify]
  [--no-reset]
  [--bin-address 0x...]           (.bin only; default: FLM's Flash start)
  [--frequency 100k]              (default: 100k)
  [--connect halt|pre-reset|under-reset|attach]  (default: under-reset)
  [--target cortex_m]             (default: cortex_m)
  [--ram-start 0x20000000]        (default: 0x20000000)
  [--ram-size 0x...]              (default: max(64KiB, FLM minimum))
```

## Python API

```python
from embflasher import flash, list_probes

flash(firmware="app.hex", flm="chip.flm")

# with overrides
flash(
    firmware="app.bin",
    flm="chip.flm",
    probe="0123456789ABCDEF",
    target="cortex_m",
    frequency="4M",
    erase="chip",
    verify=True,
    reset=True,
)

print(list_probes())
```

## Requirements

- Python >= 3.10
- A DAPLink or CMSIS-DAP compatible debug probe
- pyOCD (installed automatically as a dependency)

### USB permissions on Linux

On Ubuntu/Linux, the debug probe usually needs a udev rule to be accessible without root. pyOCD ships one:

```
python -m pyocd pack update   # optional, first run
sudo curl -o /etc/udev/rules.d/50-cmsis-dap.rules \
  https://raw.githubusercontent.com/pyocd/pyOCD/main/udev/50-cmsis-dap.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
```

Then unplug and replug the probe.

## License

MIT
