Skip to content

Refactor flash operations to use state-machine approach instead of blocking #109

Description

@coderabbitai

Problem

The current flash operations implementation uses blocking operations with long wait times that prevent other firmware operations from running. Specifically:

  • FLASH_REG_READ_RETRIES = 10 with FLASH_REG_READ_DELAY_US = 100,000 (100ms each)
  • Total potential blocking time: 1 second per operation
  • Functions like check_flash_tx_complete() sit in tight loops, preventing other firmware tasks (e.g., LED blinking)

Current Implementation

The flash operations in winc-rs/src/manager.rs use blocking loops in methods like:

  • check_flash_tx_complete()
  • send_flash_write()
  • send_flash_read_status_register()

Proposed Solution

Refactor flash operations to use a state-machine based approach similar to the existing boot_the_chip() function, which allows:

  • Non-blocking operation
  • Incremental progress tracking
  • Other firmware operations to continue running
  • Better responsiveness

References

This refactoring would improve firmware responsiveness while maintaining the same flash operation functionality.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions