Placing a key in flash memory using _
Arm compiler toolchain v5.02 for µvision using the linker |
|
|
Home> using scatter files> placing a key in flash memory using _ |
Placing a key in flash memory using _
Some flash devices require a key to be written to an address to activate certain features.__at
Section provides a simple method of writing a value to a specific address.
Assuming a device has flash memory from0x8000
To0x10000
And a key is required in address0x8000
. To do this with__at
Section, you must declare a variable so that the compiler can generate a section called.ARM.__at_0x8000
.
Example 24. Placement of the flash key variable in C or C ++ code
// place flash_key in a section called .ARM.__at_0x8000
long flash_key __attribute__((section(".ARM.__at_0x8000")));
The following example shows a scatter file with manual placement of the flash execution region:
Example 25. Manual placement of Flash execution regions
ER_FLASH 0x8000 0x2000{ *(+RO) *(.ARM.__at_0x8000) ; key}
Use the linker command-line option--no_autoat
To enable manual placement.
The following example shows a scatter file with automatic placement of the flash execution region. Use the linker command-line option--autoat
To enable automatic placement.
Example 26. Automatic Placement of Flash execution regions
Er_flash 0x8000 0x2000 {* (+ RO); Other code and read-only data, the; _ at section is automatically selected}
Test:
; *************************************************************; *** Scatter-Loading Description File generated by uVision ***; *************************************************************LR_IROM1 0x08000000 0x00010000 { ER_IROM1 0x08000000 0x0000F000 { startup.o (RESET, +First) .ANY (+RO) } ER_IROM2 0x0800F000 FIXED 0x00001000 { main.o (.ARM.__at_0xF000) } RW_IRAM1 0x20000000 0x00004000 { .ANY (+RW,+ZI) } ; RW_IRAM3 0x20004800 UNINIT 0x0000200 ; HEAP { startup.o(HEAP) } RW_IRAM2 0x20004A00 UNINIT 0x0000600 ; STACK { startup.o(STACK) }}// main.c/* Private macro -------------------------------------------------------------*/const char buf[4096] __attribute__((section(".ARM.__at_0xF000"))) = {"Hello World!"}
The red font is a field identifier used for indexing.
How to directly write the environment constant (ENV) in MDK to some built-in flash settings