Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust flashing sleep times to prevent AI-deck timeouts #510

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 17 additions & 4 deletions cflib/bootloader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@ def flash(self, filename: str, targets: List[Target], cf=None, enable_console_lo
# Reset to firmware mode
self.reset_to_firmware()
self.close()
time.sleep(3)

if any(deck.target == 'bcAI:gap8' for deck in deck_targets):
time.sleep(7)
else:
time.sleep(2)

# Flash all decks and reboot after each deck
current_index = 0
Expand All @@ -289,7 +293,10 @@ def flash(self, filename: str, targets: List[Target], cf=None, enable_console_lo
self.progress_cb('Deck updated! Restarting...', int(100))
if current_index != -1:
PowerSwitch(self.clink).reboot_to_fw()
time.sleep(3)
if any(deck.target == 'bcAI:gap8' for deck in deck_targets):
time.sleep(7)
else:
time.sleep(2)

# Put the crazyflie back in Bootloader mode to exit the function in the same state we entered it
self.start_bootloader(warm_boot=True, cf=cf)
Expand Down Expand Up @@ -601,7 +608,10 @@ def _flash_deck_incrementally(self, artifacts: List[FlashArtifact], targets: Lis
self.progress_cb(f'Updating deck {deck.name}', 0)

# Test and wait for the deck to be started
timeout_time = time.time() + 5
if any(deck.name == 'bcAI:gap8' for deck in decks.values()):
timeout_time = time.time() + 9
else:
timeout_time = time.time() + 4
while not deck.is_started:
if time.time() > timeout_time:
raise RuntimeError(f'Deck {deck.name} did not start')
Expand All @@ -628,7 +638,10 @@ def _flash_deck_incrementally(self, artifacts: List[FlashArtifact], targets: Lis
continue

# Wait for bootloader to be ready
timeout_time = time.time() + 5
if any(deck.name == 'bcAI:gap8' for deck in decks.values()):
timeout_time = time.time() + 9
else:
timeout_time = time.time() + 4
while not deck.is_bootloader_active:
if time.time() > timeout_time:
raise RuntimeError(f'Deck {deck.name} did not enter bootloader mode')
Expand Down