Upcoming maintenance
Dear Customers and Partners.
This website will be undergoing scheduled maintenance on June 14, 2023. Please be aware there may be disruption to the developer portal website and associated services during the scheduled maintenance period.
This upgrade is essential to ensure the continued performance, reliability, and security of Developer World.
We apologize for any inconvenience.
How properly use BackupSRAM with Arduino stack ?
-
Hello,
In order to keep a counter between several cold sleeps of the card, I try to use Backup SRAM.
I managed to get the desired behaviour thanks to the starting address of this SRAM :// BACKUP_MEM into MP.cpp, arbitrary 1024 shift int* count = 0x04400070 + 1024; bootcause_e bc = LowPower.bootCause(); if ((bc == POR_SUPPLY) || (bc == POR_NORMAL)) { Serial.println("Normal boot !"); (*count) = 0; } else { (*count)++; Serial.print("Wakeup from cold sleep for the "); Serial.print(*count); Serial.println("th time !"); }
To have a clean code, is there an allocation function, a macro or something cleaner than what I did ?
Thanks,
Romain. -
Did not know about Backup SRAM, so I investigated a little on this.
How about this?
See arch/arm/src/cxd56xx/hardware/cxd5602_backupmem.h
#define CXD56_BKUP_SRAM_BASE (0x04400000) #define BKUP ((backup_info_t*)CXD56_BKUP_SRAM_BASE) typedef struct { uint32_t rcosc_clock; /* 0x04400000 ~ 0x04400003 */ uint32_t chip_revision; /* 0x04400004 ~ 0x04400007 */ uint32_t sbl_version; /* 0x04400008 ~ 0x0440000b */ uint32_t sysfw_version; /* 0x0440000c ~ 0x0440000f */ uint32_t gnssfw_version; /* 0x04400010 ~ 0x04400013 */ uint32_t reserved_version[2]; /* 0x04400014 ~ 0x0440001b */ uint32_t fw_free_space; /* 0x0440001c ~ 0x0440001f */ uint32_t bootcause; /* 0x04400020 ~ 0x04400023 */ uint32_t bootmask; /* 0x04400024 ~ 0x04400027 */ uint32_t bootreserve; /* 0x04400028 ~ 0x0440002b */ uint32_t systemconfig; /* 0x0440002c ~ 0x0440002f */ uint8_t rtc_saved_data[32]; /* 0x04400030 ~ 0x0440004f */ uint32_t irq_wake_map[4]; /* 0x04400050 ~ 0x0440005f */ uint32_t irq_inv_map[4]; /* 0x04400060 ~ 0x0440006f */ uint8_t reserved0[0x100 - 0x70]; /* 0x04400070 ~ 0x044000ff */ uint8_t power_monitor_data[0x420]; /* 0x04400100 ~ 0x0440051f */ uint8_t reserved1[2 * 1024 - 0x520]; /* 0x04400520 ~ 0x044007ff (2KB-0x520) */ uint8_t gnss_backup_data[24 * 1024]; /* 0x04400800 ~ 0x044067ff (24KB) */ uint8_t gnss_pvtlog_data[4 * 1024]; /* 0x04406800 ~ 0x044077ff (4KB) */ uint8_t reserved_romcode[2 * 1024]; /* 0x04407800 ~ 0x04407fff (2KB) */ uint8_t log[32 * 1024]; /* 0x04408000 ~ 0x0440ffff (32KB) */ } backup_info_t;
Searching for BKUP reveal that it is used in various locations.
e.g. arch/arm/src/cxd56xx/cxd56_backuplog.cstatic struct logheader_s *get_logheader(void) { return (struct logheader_s *)BKUP->log; }
Looks like it is already in use? Maybe the log can be switched off (or already is?)?
I would also need as much as memory as I can get -
Seems like in the Arduino SDK build the backup log is defined. If there is no plan to use this backup log it would be probably save to disable this feature and create a custom Arduino SDK (which was quite easy with the instructions in the documentation)
.../Arduino15/packages/SPRESENSE/tools/spresense-sdk/2.5.2/spresense/release/nuttx/include/nuttx/config.h
#define CONFIG_CXD56_BACKUPLOG 1
-
Hey, @jens6151-0-1-1
For what I could gather you already solved your issue, right?
Do you need any more help in this topic? -
Hello,
Thanks for your answers.
I had not seen this structure. It helps a lot.I have a few questions left.
- Is it clean to always write/rewrite the same memory byte ?
- Who are
reserved0
andreserved1
reserved for ? May I use these spaces freely ?
Disabling logs and use this free space otherwise seems to be the best solution.
-
- It's okay, I don't see any problems with that.
- reserved0 and reserved1 are not being used in this current version of the SDK. So yes, you can use those spaces freely.
It is important to note, though, that if you were to eventually update your SDK to a newer version, you'd have to check if those spaces are still not being used.