Skip to content

Proposal: Provide persistence in RAM and Flash across low-power and reset states #1716

Open
@kenbell

Description

@kenbell

I've been thinking about how to support super-low power states in TinyGo, and I think there are two interesting cases:

  1. CPU core and peripherals powered off, but RAM still powered
  2. CPU core, peripherals and RAM powered off

Various chips (I'm most aware of the STM32 line) support entering sleep states like these, being woken on specific GPIO pins, RTC alarms, and similar. In order to support these low-power states, it would be super-cool to have ways to persist data. A beneficial side-effect is that it would also enable some persistence across reset (and potentially flashing).

Example use-cases:

  1. Battery-powered sensing device that wakes every minute (RTC alarm) to collect a sample, save to RAM, then returns to low-power state. Once per day it powers up wifi to deliver the samples collected.
  2. Logging device that wants to ensure samples are not lost on a crash / watchdog event by holding samples in RAM until they can be delivered.
  3. Configuration settings - allow users to configure a device and persist those settings to flash so they survive power-out and reset

I've put a prototype implementation for RAM persistence here: #1715

I've tried to put fairly details docs in the package runtime/persistence: https://github.com/tinygo-org/tinygo/blob/537ef22f7365bdc7d3e04b03dc943262f43730fe/src/runtime/persistence/persistence.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions