码迷,mamicode.com
首页 > 其他好文 > 详细

关于如何在MDK中将环境常量(ENV)直接烧写到内置flash的一些设置

时间:2014-10-07 16:22:03      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   io   使用   ar   for   

Placing a key in flash memory using __at

Placing a key in flash memory using __at

Some flash devices require a key to be written to an address to activate certain features. An __at section provides a simple method of writing a value to a specific address.

Assuming a device has flash memory from 0x8000 to 0x10000 and a key is required in address 0x8000. To do this with an __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
}



实际使用测试:

; *************************************************************
; *** 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!"} 
红色字体是字段标志,用于索引。
bubuko.com,布布扣

 


关于如何在MDK中将环境常量(ENV)直接烧写到内置flash的一些设置

标签:des   style   blog   http   color   io   使用   ar   for   

原文地址:http://www.cnblogs.com/yuwl26/p/4009300.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!