Skip to content

[Feature] Refactor drv/block_device and sys/storage #2264

@laurensvalk

Description

@laurensvalk

At the moment, drv/block_device is the platform specific implementation of the disk I/O operations and sys/storage manages data and decides whether to write on shutdown.

We can re-balance this to give drv/block_device more control over the initial read and final write of the "ram disk", but keep the data logic in sys/storage. This has a few benefits:

  • We can move the logic for pbsys_storage_update_checksum to the platform specific driver, which is really a much better place. So this field would not be in the data map anymore:
    #if PBSYS_CONFIG_STORAGE_OVERLAPS_BOOTLOADER_CHECKSUM
    /**
     * Checksum complement to satisfy bootloader requirements. This ensures
     * that words in the scanned area still add up to precisely 0 after user
     * data was written.
     */
    volatile uint32_t checksum_complement;
    #endif
  • When the logic for handling the initial read resides in drv, we can do it before the adc driver is started, which is needed for EV3 in [EV3 - help wanted]: Implement SPI flash block device driver #2247. They can run sequentially, both asynchronously alongside the other drivers being initialized. We need the adc for the intermediate pbio layer, so we can't delay the adc until after sys completes initializing.

  • This has the added benefit of having storage ready before pbio and sys begins. This means that some of its modules like the UI don't need to await user settings to become ready. They'll just be available directly.

Metadata

Metadata

Assignees

Labels

hub: cityhubIssues related to the LEGO Powered Up Smart hub (Hub No. 4)hub: movehubIssues related to the LEGO BOOST Move hubhub: technichubIssues related to the LEGO Technic hub (Hub No. 2)platform: EV3Issues related to LEGO MINDSTORMS EV3software: pybricks-micropythonIssues with Pybricks MicroPython firmware (or EV3 runtime)

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions