We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello everyone!
I am using Keil uVision 5.28 with Compiler V6.12.
How to declare a constant structure in flash memory so that it is not initialized by programmer / debugger and functions from scatterloader?
I'm looking at document https://static.docs.arm.com/100748/0609/compiler_user_guide_100748_0609_00_en.pdf.
There is an example on page 120 for peripheral registers, but it does not quite suit me, since there can be many such structures, and I do not want to make many files for each structure.
Now I have limited the size of the flash memory in the scatter file and refer to the structure at an absolute address.Maybe there is some other, more correct solution?
Thanks for the answer.
My scatter file:
LR1 0x08000000 0x0007C800 { USRROM 0x08000000 0x0007C800 { *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) .ANY (+XO) } NVRAM 0x20000000 UNINIT 0x00000008 { *.o (.bss.dfuflg) } USRRAM 0x20000008 0x0000FFF8 { .ANY (+RW +ZI) } } LR2 0x0807E800 0x00001000 { NVROM1 0x0807E800 UNINIT 0x00001000 { *.o (.bss.wtime) } } LR3 0x0807F800 0x00000800 { NVROM2 0x0807F800 UNINIT 0x00000800 { *.o (.bss.nvm) } }
In my source code:
static const u32 Var[10] __attribute__((section(".bss.nvm")));
Moreover, in the message "Program size: code = 16176 RO-data = 1732 RW-data = 16 ZI-data = 7904" I notice that my array (for example, or structure) is placed in ZI-data.Does this violate linker logic?
It's fine -- ZI is really a synonym for .bss. See also section B3.34 in the Arm Compiler Reference Guide v6.14.