Skip to content

Conversation

@gemenerik
Copy link
Member

@gemenerik gemenerik commented Jan 29, 2025

PR #69 introduced a 1-second delay before booting the STM32 and decks to prevent the GAP8 from freezing. However, we still saw the issue, even when using only the AI-deck. The severity varied depending on the combination of attached decks.

This PR increases the delay to 5 seconds, which, based on testing, significantly improves stability. However, if issues persist, a further increase may be necessary.

Additionally, this PR ensures that the delayed boot is deck-dependent. Now, the delay is only applied when an AI-deck is attached. To achieve this, we read the OW memory during startup. If no AI-deck is present, the previous 1-second delay is removed entirely.

@gemenerik
Copy link
Member Author

For flashing to work correctly with the updated delay, you also need the corresponding PR from the Python lib: bitcraze/crazyflie-lib-python#510

Copy link
Member

@ataffanel ataffanel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but I think the memory handling code would be nicer if a bit more generic.

- Updated `memoryHasDeck(...)` to take `vid`, `pid`, and `boardName` as parameters, making it more flexible for different deck types.
- Introduced `#define MEMORY_BITCRAZE_VID 0xBC`, `#define MEMORY_AIDECK_PID 0x12`, and `#define MEMORY_AIDECK_BOARDNAME "bcAI"` for specifying AI-deck search parameters.
- Now calling `memoryHasDeck(MEMORY_BITCRAZE_VID, MEMORY_AIDECK_PID, MEMORY_AIDECK_BOARDNAME)` to check for AI-deck presence.

This improves reusability and makes it easier to extend deck detection logic in the future.
- Introduce `DeckInfo` struct to parse the deck header (vid, pid, etc.)
  instead of using raw offsets.
- Compute a 32-bit CRC over the header, comparing its LSB
  with the stored single-byte CRC in the deck.
- Add a second CRC check for the TLV region.
- Replace magic offset constants with named macros (e.g.
  DECK_INFO_HEADER_SIZE, DECK_INFO_TLV_DATA_POS).
- Maintain the original logic for board name detection, but ensure any
  corrupted header or TLV fails early.
- Include and reference a separate `crc32_calc.h/.c` for the 32-bit
  polynomial-based CRC calculations.
@gemenerik gemenerik requested a review from ataffanel February 11, 2025 10:21
Copy link
Member

@ataffanel ataffanel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loogs great, thanks for the changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants