[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")))`

e.g.:

    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;
    rtc_get_time(&time);
    time.tm_sec += 5;
    mktime(&time);
    rtc_set_alarm(&time, NULL, NULL);

    /* this will trigger a deep sleep */
    pm_unblock(0);
    xtimer_usleep(10000);

    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:

  https://github.com/RIOT-OS/RIOT/pull/11486

-- 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 --

https://github.com/RIOT-OS/RIOT/pull/11486.patch
https://github.com/RIOT-OS/RIOT/pull/11486.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11486
-------------- 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