variable in retention_mem_area0

⚠️
嗨there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
6 posts / 0 new
Last post
stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
variable in retention_mem_area0

嗨there,
I declare many variables such as following example...
static uint8_t test __attribute__((section("retention_mem_area0"), zero_init));

And my questions are...
1. After printing the address of the variable, It's 0x7FD4804(in SysRAM4:). Why?
2. Why doesn't the variable be stored in SysRAM1?
3. Does It means the variable will be cleared in extend sleep mode? But the value of the variable is still correct, why?

4. In addition, if I want keep some "global variables" or "in-function-static variables", these variables should be added the "__attribute__((section("retention_mem_area0"), zero_init))" description, is it true?

5. If the area is full, how should I know?

6. If I want to give the variable a initial value, can I write: "static uint8_t test __attribute__((section("retention_mem_area0"))) = 0xFF; "?

Many thanks.

Keywords:
Device:
MHv_Dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2013-12-06 15:10
嗨,

嗨,

  1. SysRAM 4 is where retention memory area 0 is located
  2. See above
  3. Variables in SysRAM4 are retained during sleep
  4. That is true
  5. The project would fail to link
  6. Yes, that is how it is done

/MHv

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
Thank you so much!

Thank you so much!

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
嗨MHv,

嗨MHv,
I find a problem about the item 6.
If I use "static int8_t time_zone __attribute__((section("retention_mem_area0"))) = 0x08;", the init value 0x08 will be located at 0x14404 address of the bin file.
It will cause my bin file becomes a large size (from 30 KB -> 80 KB). There are 0xFF between 0x9EE0 and 0x14403.
I can't understand, do you have any idea?
Thanks a lot.

MT_dialog
Offline
Last seen:3 months 3 days ago
Staff
加入:2015-06-08 11:34
嗨stanley_yeh,

嗨stanley_yeh,

The reason for that is that when you are applying an initialized value in the retention memory area, the problem with that is that the retention memory areas are far from the actual code as an address, when you apply an initialized variable in the retention area then the linker is not able to properly handle it and the binary that gets generated expands in large addresses (it will explicitly hardcode that value of the variable in that specific memory address along with an enormous padding until that value). As a work around you can set the variable as zero initialized and then apply a value via code.

Thanks MT_dialog

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
非常感谢。:)

非常感谢。:)