Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ prompt) a few flags make the output predictable:
`param list`/`get`, `log list`/`print`, `mem list`, `deck list`,
`platform info`, `swarm config list`/`show`, `swarm scan`,
`swarm platform info`, `swarm param get`, `swarm log print`,
`swarm deck list`, `swarm debug assert`). Other commands ignore the flag.
`swarm deck list`, `swarm debug assert`, `swarm bootload info`). Other
commands ignore the flag.

Exit codes:

Expand Down
3 changes: 3 additions & 0 deletions docs/bootload.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ This command shows you the bootloader version and other related information of t
cfcli bootload info
```

To flash, or show the bootloaders of, every Crazyflie of a swarm, see
[Swarms](swarm.md#flashing).

## List available releases

This command will list the available releases from the [Crazyflie release repository](https://github.com/bitcraze/crazyflie-release).
Expand Down
52 changes: 52 additions & 0 deletions docs/swarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ These commands work like the normal ones, on every Crazyflie in the swarm:
| `cfcli swarm log print` | Log variables from each Crazyflie |
| `cfcli swarm deck list` | The decks on each Crazyflie |
| `cfcli swarm debug assert` | The assert info of each Crazyflie |
| `cfcli swarm bootload info \| flash` | Bootloaders and firmware, see [Flashing](#flashing) |

`--cf` and `--exclude` (comma-separated names) pick some of the Crazyflies,
and `--swarm <id>` runs on another swarm than the selected one:
Expand Down Expand Up @@ -296,6 +297,57 @@ TOC that isn't in the cache yet is downloaded from one Crazyflie only; the
others wait and then use the cache. Run with `-n` (no TOC cache) and every
Crazyflie downloads its own.

### Flashing

`swarm bootload flash` flashes every Crazyflie, one after another, the same
way `cfcli bootload flash` flashes one. It takes the same `--release`,
`--zip`, `--bin` and `--targets`:

```bash
cfcli swarm bootload flash --release 2026.08
cfcli swarm bootload flash --bin stm32-fw=cf21bl.bin --cf CF-01,CF-02
```

The release, the files and the targets are checked before any Crazyflie is
touched, and the firmware for every platform in the swarm is prepared before
anything is flashed: a `--zip` built for another platform stops the command
instead of failing halfway. A Crazyflie that fails while flashing doesn't
stop the others, and a summary at the end shows how each one went. A unicast
flash keeps the radio busy, so flashing several Crazyflies at once wouldn't
be faster; plan for about 20 seconds per Crazyflie for the STM32 and nRF51
firmware, more with decks.

#### Swarms with several platforms

A release has the files for every platform, so `--release` flashes each
Crazyflie with the files of its own platform. STM32 and nRF51 images given
with `--bin` are built for one platform, so they are only flashed when all the
Crazyflies to flash have the same platform; otherwise the command stops
before flashing anything. Deck firmware works whatever the Crazyflie.

`--platform` flashes only the Crazyflies of one platform (`cf21`, `cf21bl`,
`bolt11`, `flapper` or `tag`), the others are skipped:

```bash
cfcli swarm bootload flash --platform cf21bl --bin stm32-fw=cf21bl.bin
cfcli swarm bootload flash --platform cf21 --bin stm32-fw=cf21.bin
```

`swarm bootload info` shows the bootloader versions of each Crazyflie. It
restarts each one into its bootloader to read them and back into its
firmware afterwards:

```text
$ cfcli swarm bootload info
CF | nRF51 bootloader | STM32 bootloader | Broadcast
------+------------------+------------------+-----------
CF-01 | 0x11 | 0x11 | yes
CF-02 | 0x10 | 0x10 | no
```

`Broadcast` tells whether both bootloaders are new enough to receive one
image for many Crazyflies at the same time (protocol 0x11).

## Spreading a swarm over channels

Crazyflies on the same channel always share a Crazyradio (see
Expand Down
51 changes: 40 additions & 11 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,14 @@ enum SwarmCommands {
#[clap(subcommand)]
command: SwarmLogCommands,
},
/// Bootload the Crazyflies in the swarm
Bootload {
#[clap(flatten)]
target: SwarmTargetArgs,

#[clap(subcommand)]
command: SwarmBootloadCommands,
},
/// Debugging utilities for the Crazyflies in the swarm
Debug {
#[clap(flatten)]
Expand Down Expand Up @@ -581,6 +589,28 @@ enum SwarmLogCommands {
Print(VariablesAndPeriod),
}

#[derive(Debug, Subcommand)]
enum SwarmBootloadCommands {
/// Show the bootloader versions of each Crazyflie (restarts each one into
/// its bootloader and back)
Info,
/// Flash firmware to each Crazyflie, one after another
Flash(SwarmFlashParameters),
}

#[derive(Debug, Args)]
struct SwarmFlashParameters {
#[clap(flatten)]
source: FirmwareSourceArgs,
/// Only flash the Crazyflies of this platform. STM32 and nRF51 images
/// given with --bin are built for one platform, so a swarm with several
/// platforms is flashed one platform at a time.
///
/// Valid values: cf21, cf21bl, bolt11, flapper, tag
#[clap(long, verbatim_doc_comment)]
platform: Option<String>,
}

#[derive(Debug, Subcommand)]
enum SwarmDeckCommands {
/// List the decks attached to each Crazyflie
Expand Down Expand Up @@ -961,22 +991,15 @@ struct InfoParameters {
cold: bool,
}

/// The firmware to flash, shared by `bootload flash` and `swarm bootload flash`.
#[derive(Debug, Args)]
#[command(
// group(
// ArgGroup::new("source_type")
// .args(&["release", "zip"])
// .required(false)
// .multiple(false)
// ),
group(
#[command(group(
ArgGroup::new("firmware_source")
.args(&["release", "zip", "bin"])
.required(true)
.multiple(true)
)
)]
struct FlashParameters {
))]
struct FirmwareSourceArgs {
/// Release name, interactive selection if left blank (cannot be combined with zip)
#[clap(long)]
release: Option<Option<String>>,
Expand All @@ -1000,6 +1023,12 @@ struct FlashParameters {
/// Example: stm32-fw,nrf51-fw
#[clap(long, verbatim_doc_comment)]
targets: Option<Option<String>>,
}

#[derive(Debug, Args)]
struct FlashParameters {
#[clap(flatten)]
source: FirmwareSourceArgs,
/// Use coldboot (i.e rescue mode) to flash the device
#[clap(long, default_value_t = false)]
cold: bool,
Expand Down
Loading
Loading