Skip to content

Skip rewriting unchanged samples on boot to speed up load and reduce flash wear #1436

Description

@iaalm

I don't know if this is a common use case, but it is common for me: I often power the device on and off while working on the same project and continuing to edit it.

I noticed that on every boot, all samples are reloaded from the TF card into flash. On my device this takes around 1s. Since flash is non-volatile and reads are much faster than writes, I think boot loading could be much faster by reusing samples already in flash when unchanged.

I don't want a complex caching system. So to minimize changes, I tried the following:

  • make sample load order predictable (alphabetical)
  • before writing a flash sector/page, read existing flash data first; if it is identical, skip the write

I implemented this on my device and reduced load time from about 1s to around 0.5s (which is a very noticeable improvement in practice) for a 600k project. It should also significantly reduce flash wear by avoiding unnecessary erase/program cycles.

I can open a PR for this. I just want to check whether this direction fits the project before I do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions