[riot-notifications] [RIOT-OS/RIOT] cpu/saml21: Make Low-Power SRAM available to programs (#11486)

benpicco notifications at github.com
Fri May 3 17:58:17 CEST 2019

### Contribution description

SAML21 contains up to 8 kiB low-power SRAM that can be retained during deep sleep modes.

This adds a section for this memory in the linker script, so structures can be placed in it by giving them the `__attribute__((section(".backup")))`


    static uint8_t persistent_buffer[64] __attribute__((section(".backup")));

Compile-tested only, run-tested on same54-xpro which also has 8 kiB of Backup RAM.

### Testing procedure

static uint8_t persistent_buffer[64] __attribute__((section(".backup")));

int main(void) {
    /* simple check if the memory is still the same after reboot */
    if (persistent_buff[0] != 0x23) {
            persistent_buff[0] = 0x23;
            puts("fresh memory");
        } else {
            puts("retained memory");

    /* let the RTC trigger a reset after 5s */
    struct tm time;
    time.tm_sec += 5;
    rtc_set_alarm(&time, NULL, NULL);

    /* this will trigger a deep sleep */

    return 0;

### Issues/PRs references

I'm doing the same in #11305 as SAMD5x has a very similar feature (Backup Ram instead of Low-Power SRAM but the idea is the same).
You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * cpu/saml21: Make Low-Power SRAM available to programs

-- File Changes --

    M cpu/saml21/Makefile.include (12)
    A cpu/saml21/ldscripts/saml21.ld (35)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190503/bc86fd53/attachment.html>

More information about the notifications mailing list