How to directly write the environment constant (ENV) in MDK to some built-in flash settings

Source: Internet
Author: User
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.__atSection provides a simple method of writing a value to a specific address.

Assuming a device has flash memory from0x8000To0x10000And a key is required in address0x8000. To do this with__atSection, 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_0x8000long 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_autoatTo enable manual placement.

The following example shows a scatter file with automatic placement of the flash execution region. Use the linker command-line option--autoatTo 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.