嗨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.
嗨,
/MHv
Thank you so much!
嗨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.
嗨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
非常感谢。:)