Skip to content

[Feature] Reserve memory region for persistent system settings. #1622

Closed

Description

@laurensvalk

Is your feature request related to a problem? Please describe.
We have a persistent memory section for user data. We might need one for system settings as well.

We can either reduce the existing user data size, or reduce program size instead.

Taking it out of the user data has the benefit that there is no breaking change for user programs already on SPIKE hubs when they upgrade the firmware. I've also not seen many projects that use large amounts of persistent data anyway.

Persistent data we could consider reserving space for:

Activity

  1. added
    triage
    topic: bluetooth
    software: pybricks-micropython
    topic: imu
    and removed
    triage
    on Apr 29, 2024
  2. laurensvalk commented on May 3, 2024

    @laurensvalk
    MemberAuthor

    One issue when starting this is that the region could contain any random data to begin with on Spike Hubs. On Technic/Boost/City it is erased on update.

    Do we want to clear it on first boot on SPIKE hubs? Should we erase user programs too?

  3. dlech commented on May 3, 2024

    @dlech
    Member

    Maybe on those hubs, we could use a magic number or checksum to tell if the persistent data is valid or not.

  4. afarago commented on May 4, 2024

    @afarago

    Could we consider having 3 BT modes?

    • BT on open (current)
    • BT off
    • BT on secure - only connect to last connected MAC (after mode 1)

    Though kids are nice it is a disaster if during the competition anyone can connect to your hub when doing the programming / testing part.

    (You know the analogy - in the IoT abbreviation the letter "s" stands for security)

  5. laurensvalk commented on May 4, 2024

    @laurensvalk
    MemberAuthor

    Thanks @afarago --- it might be best to add that to #1615

    This issue is more about the generics of storing persistent data 🙂

  6. afarago commented on May 4, 2024

    @afarago

    Apologies, I was going to, but accidentally left the wrong ticket open on my phone.
    note to myself: never comment on github before the morning coffee.

    I will add it there, please feel free to remove my comment(s) from here.

  7. laurensvalk commented on May 4, 2024

    @laurensvalk
    MemberAuthor

    Oh, don't worry! Please keep the comments coming before your morning coffee, those are often the best 😄

  8. laurensvalk commented on Jun 5, 2024

    @laurensvalk
    MemberAuthor

    I would like to avoid a repeat of #744, so maybe we should just take the space needed for persistent storage out of the user data area.

    On the other platforms this shouldn't matter, since all user data gets erased during a firmware update anyway.

  9. dlech commented on Jun 5, 2024

    @dlech
    Member

    On the other platforms this shouldn't matter, since all user data gets erased during a firmware update anyway.

    Perhaps we could emulate this on the SPIKE hubs by including a hash of the data plus the firmware version (or a data layout version that only changes when the layout changes, like this proposed change here - this would need to include PBSYS_APP_HUB_FEATURE_FLAGS in the hash too). If the hash is bad, the write over the memory with 0s before reading the first time.

  10. laurensvalk commented on Jun 5, 2024

    @laurensvalk
    MemberAuthor

    Related / maybe addressable at the same time #1496:

    (...) a program is not really able to tell if the contents of the persistent storage are valid for the given program or not, because new programs are possible to install without clearing the storage, which makes it hard to use it safely (...)

  11. laurensvalk commented on Jun 7, 2024

    @laurensvalk
    MemberAuthor

    The mechanics for this have been implemented. There is just one setting for now, but we can add more with every release since the settings are erased after an update.

  12. added theissue type on Aug 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    software: pybricks-micropythontopic: bluetoothtopic: imu

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions