Repository navigation
Add swarm bootload info and flash (unicast) - #32
Merged
Merged
Conversation
cfcli swarm bootload flash flashes every Crazyflie of a swarm, one after another over unicast, the same way bootload flash flashes one, and takes the same --release, --zip, --bin and --targets. The release, the files and the targets are resolved before any Crazyflie is touched; each Crazyflie's platform then decides which files of a release it gets, so a swarm can mix platforms. A Crazyflie that fails doesn't stop the others, and a summary shows how each one went. cfcli swarm bootload info shows the bootloader versions of each Crazyflie, and whether both bootloaders can take broadcast flashing (protocol 0x11). Unlike bootload info, it restarts each Crazyflie back into its firmware afterwards, and gives each Crazyflie 15 s so that one that hangs doesn't hold up the rest. The release, --bin and --targets handling moves out of main.rs into utils/flash_source.rs, and the four arguments into FirmwareSourceArgs, shared by both commands. bootload flash works as before.
STM32 images differ between platforms (a Crazyflie 2.1 and a 2.1 Brushless can't run each other's), and so do nRF51 images for some of them. A release has the files for every platform and is downloaded per platform, but --bin gave the same file to every Crazyflie of a swarm. swarm bootload flash now refuses --bin STM32 or nRF51 images when the Crazyflies to flash have more than one platform, before flashing anything. Deck firmware works whatever the Crazyflie and still goes to all. --platform cf21|cf21bl|bolt11|flapper|tag flashes only the Crazyflies of one platform and skips the others, so a mixed swarm can be flashed one platform at a time. The firmware for every platform is now prepared before any Crazyflie is flashed: a zip built for another platform stops the command instead of failing those Crazyflies halfway, and each platform is prepared once. The platform names move into utils/flash_source.rs, shared with the --platform of bootload flash --cold, which now gives exit code 30 for an unknown platform.
The answer to GET_INFO is [target, GET_INFO, page size, buffer pages, flash pages, start page, 12-byte CPU ID, protocol version], as cfloader and cflib read it. get_info took the protocol version from byte 1, which is the GET_INFO command echoed back, so every bootloader reported 0x10: bootload info always printed "Protocol Version: 16", and swarm bootload info said no Crazyflie could take broadcast flashing. It also read the CPU ID as 2 bytes instead of 12. The version now comes from byte 22 (0 for bootloaders from before it was added, which stop after the CPU ID) and the CPU ID is printed in full.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
cfcli swarm bootload infoandcfcli swarm bootload flash.This is unicast only for now: the Crazyflies are flashed one after another, the same way
cfcli bootload flashflashes one. Broadcast flashing, where every Crazyflie with a new enough bootloader receives each image at the same time, will follow in a separate PR. It depends on bitcraze/cfloader-rs#3, which isn't merged or released yet.What's in it
cfcli swarm bootload flash--release,--zip,--binand--targetsasbootload flash, plus the usual--cf,--excludeand--swarm.--zipbuilt for another platform stops the command instead of failing halfway.Swarms with several platforms
STM32 images differ between platforms (a Crazyflie 2.1 and a 2.1 Brushless can't run each other's), and nRF51 images differ for some of them:
--release: downloaded per platform, so every Crazyflie gets its own platform's files.--bin: only flashed when all the Crazyflies to flash have the same platform. Otherwise the command stops before flashing anything, listing the platforms and their Crazyflies.--platform cf21|cf21bl|bolt11|flapper|tag: flashes only the Crazyflies of one platform and skips the rest, so a mixed swarm is flashed one platform at a time.cfcli swarm bootload infobootload info, it restarts each Crazyflie back into its firmware afterwards.--csvis supported.Refactoring
--binand--targetshandling ofbootload flashmoves out ofmain.rsintoutils/flash_source.rs, and the four arguments intoFirmwareSourceArgs, shared by both commands.bootload flashworks as before.--platformforbootload flash --coldnow exits 30 instead of 1.bootloader::bootloader_versions()reads both versions and restarts into the firmware, andFirmwareUpgradeisClone.Fix: bootloader protocol version
get_inforead the protocol version from byte 1 of the GET_INFO answer, which is the GET_INFO command echoed back. So every bootloader reported 0x10, andbootload infoalways printed "Protocol Version: 16". It also read the CPU ID as 2 bytes instead of 12. The answer is[target, GET_INFO, page size, buffer pages, flash pages, start page, 12-byte CPU ID, protocol version], as cfloader and cflib read it. The version now comes from byte 22 (0 for bootloaders from before it existed), and the CPU ID is printed in full. This affectsbootload infotoo.Testing
--binkeys are platform-bound, and the refusal for mixed platforms.--platformwith no matching Crazyflie (20).--binthat can't be read stops before flashing, after reading the platforms.swarm bootload flashwas run on the swarm.swarm bootload infoshowed protocol 0x11 on both bootloaders after the version fix (0x10 before it). The Crazyflies were back in their firmware afterwards.