I understand it is easy to designate that variables are kept in RTC RAM by using the RTC_DATA_ATTR prefix.
I am needing though to avoid using the first 128 bytes of the RTC RAM as the over-the-air update tool I will be using stomps on that memory. How then do I assign the variables I want to keep in RTC memory to a space somewhere after that first 128 bytes?
Thanks!
skipping over first 128 bytes of RTC RAM
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: skipping over first 128 bytes of RTC RAM
One quick&dirty way which may work is to define your own placeholder RTC variable, say a uint8_t[128], before any other RTC variables. If you're lucky, the linker will actually (al)locate that placeholder where you need it and you're done. If you're not so lucky, either the compiler or the linker may decide to remove your apparently "unused" placeholder variable alltogether, and the linker may "change its mind" about where exactly to put the placeholder from one build to the next.
The reliable solution would be to use a linker script to have the linker reserve the exact memory range required in the RTC section or to move the start of the RTC section by the desired amount.
The reliable solution would be to use a linker script to have the linker reserve the exact memory range required in the RTC section or to move the start of the RTC section by the desired amount.
Re: skipping over first 128 bytes of RTC RAM
I agree exactly about your first approach. I concluded the same level of uncertainty as to how the "smart" compiler would handle this.
As to
As to
well that is exactly what I don't know how to do and was hoping for some help on or an example.The reliable solution would be to use a linker script to have the linker reserve the exact memory range required in the RTC section or to move the start of the RTC section by the desired amount
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: skipping over first 128 bytes of RTC RAM
I believe with IDF that's not as straight forward as one would like: The linker script is dynamically generated during the build process from a template and a bunch of predefined or custom "linker fragment" files. While the linker fragment files are meant to customize your effective linker script, it seems their capabilities are limited and there's no provision for these kinds of customization (i.e. defining symbols via the linker).
The linker template, however, lives in IDF/components/esp_system (e.g. https://github.com/espressif/esp-idf/bl ... ions.ld.in), so you could try and copy that component into your project and modify the sections.ld.in file there. Then it may be as simple as adding at the beginning of the .rtc.data section to just skip over the first 128 bytes of that section.
The linker template, however, lives in IDF/components/esp_system (e.g. https://github.com/espressif/esp-idf/bl ... ions.ld.in), so you could try and copy that component into your project and modify the sections.ld.in file there. Then it may be as simple as adding
Code: Select all
. = . + 128;
Re: skipping over first 128 bytes of RTC RAM
I follow that. Thank you. I will see if that will work.
Re: skipping over first 128 bytes of RTC RAM
Incidentally, there is a Kconfig option to reserve memory at the start of RTC slow memory - it's designed for the ULP, but there's no reason why you can't use it for anything else. If your target supports it, you can enable the ULP and then the option to set the size of this reserved area will appear.
Also look into the option for reserved RTC memory, I think it's in the bootloader menu. This will be at the end of RTC fast memory, however, so you'll need to make changes to the OTA tool so it knows where to look.
Also look into the option for reserved RTC memory, I think it's in the bootloader menu. This will be at the end of RTC fast memory, however, so you'll need to make changes to the OTA tool so it knows where to look.
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 131 guests