xtaens 发表于 2013-11-5 11:25:50

iar 430中定义的const变量太多,提示超出范围了,xcl文件怎么

我在msp430f5438a上定义一个字库,变量都是用const修饰的,即他们都被放到了flash中。

但是当我再添加一个const数组时编译器提示报错了,看内容说xcl文件中设置的const 空间太小了。我用的软件默认的配置xcl文件。

哪位知道这个怎么改呢?

下面是错误截图:


下面是我的xcl文件:// ************************************************
//
// XLINK configuration file for MSP430F5438A
//
// Copyright 1996-2010 IAR Systems AB
//
// $Revision: $
//
// ************************************************

// ---------------------------------------------------------
// Description
//

//
// Usage:
//
//   xlink -f lnk430f5438a.xcl
//
// -----------------------------------------------
// Device summary
//

//
// Core:                           MSP430X
//
// Interrupt vectors:            64
//
// Peripheral units:                   0-00FFF
//
// Information memory (FLASH):   01800-019FF
//
// Read/write memory (RAM):      01C00-05BFF
//
// Read-only memory (FLASH):       05C00-0FFFF
//                                 10000-45BFF
//


// -----------------------------------------------
// Segments
//

// -------------------------------------
// Data read/write segments (RAM)
//

//
// The following segments are available for both
// the DATA16 and DATA20 segment groups.
//
// segment         Usage
// -------         --------------------------
// DATA<nn>_Z      Data initialized to zero
// DATA<nn>_I      Data initialized by copying from DATA<nn>_ID
// DATA<nn>_N      Data defined using __no_init
// DATA<nn>_HEAP   The heap used by 'malloc' and 'free'
//
// segment         Usage
// -------         --------------------------
// CSTACK          Runtime stack
// TLS16_I         Thread-local storage for main thread
//               (require custom runtime library)
//


// -------------------------------------
// Program and data read-only segments (FLASH)
//

//
// The following segments are available for both
// the DATA16 and DATA20 segment groups.
//
// segment         Usage
// -------         --------------------------
// DATA<nn>_C      Constant data, including string literals
// DATA<nn>_ID   initializers for DATA<nn>_I
//
// segment         Usage
// -------         --------------------------
// INFO            Information memory
// INFOA         Information memory, bank A
// INFOB         Information memory, bank B
// INFOC         Information memory, bank C
// INFOD         Information memory, bank D
// CSTART          Program startup code
// CODE            Program code
// ISR_CODE      Program code for interrupt service routines
// DIFUNCT         Dynamic initialization vector used by C++
// CHECKSUM      Checksum byte(s) generated by the -J option
// INTVEC          Interrupt vectors
// RESET         The reset vector
// TLS16_ID      Thread-local initializers for main thread
//               (require custom runtime library)
//
// Notes:
//
// * The segments CSTART, ISR_CODE, and DIFUNCT, as well as the segments in
//   the DATA16 and TLS16 segment groups must be placed in in the range
//   0000-FFFD.
//
// * The INFOx and INFO segments overlap, this allows data either to be
//   placed in a specific bank or anywhere in the info memory.
//
// * The INTVEC and RESET segments overlap. This allows an application to
//   either use the reset vector provided by the runtime library, or
//   provide a reset function by defining an interrupt function associated
//   with the reset vector.
//


// ---------------------------------------------------------
// Configuation
//

// -----------------------------------------------
// Stack and heap sizes
//

// Uncomment for command line use
//-D_STACK_SIZE=80
//-D_DATA16_HEAP_SIZE=80
//-D_DATA20_HEAP_SIZE=80


// -----------------------------------------------
// Define cpu
//

-cmsp430

// Compensate for hardware bug in CPU
-D?CPU30_OFFSET=2


// -----------------------------------------------
// Support for placing functions in read/write memory
//

-QCODE_I=CODE_ID


// ---------------------------------------------------------
// Placement directives
//

// -----------------------------------------------
// Read/write memory
//

-Z(DATA)DATA16_I,DATA16_Z,DATA16_N,TLS16_I,DATA16_HEAP+_DATA16_HEAP_SIZE=1C00-5BFF
-Z(DATA)CODE_I
-Z(DATA)DATA20_I,DATA20_Z,DATA20_N,DATA20_HEAP+_DATA20_HEAP_SIZE
-Z(DATA)CSTACK+_STACK_SIZE#


// -----------------------------------------------
// Read-only memory
//

// -------------------------------------
// Information memory
//

-Z(CONST)INFO=1800-19FF
-Z(CONST)INFOA=1980-19FF
-Z(CONST)INFOB=1900-197F
-Z(CONST)INFOC=1880-18FF
-Z(CONST)INFOD=1800-187F



// -------------------------------------
// Low memory 0-0FFFF
//

// ---------------------------
// Code
//

-Z(CODE)CSTART,ISR_CODE=5C00-FF7F

// ---------------------------
// Constant data
//

-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=5C00-FF7F


// -------------------------------------
// All memory 0-FFFFF
//

// ---------------------------
// Code
//

-P(CODE)CODE=5C00-FF7F,10000-45BFF
-Z(CODE)CODE_ID

// ---------------------------
// Constant data
//

-Z(CONST)DATA20_C,DATA20_ID=5C00-FF7F,10000-45BFF


// -------------------------------------
// Interrupt vectors
//

-Z(CODE)INTVEC=FF80-FFFF
-Z(CODE)RESET=FFFE-FFFF

lcofjp 发表于 2013-11-5 11:44:34

试试把变量定义到DATA20_C行不, @ “DATA20_C”

dianyuan 发表于 2013-11-5 12:09:36

可以试下看将
-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=5C00-FF7F 这一行改为:
-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=10000-45BFF
或者
-P(CODE)CODE=5C00-FF7F,10000-45BFF这一行改为:
-P(CODE)CODE=10000-45BFF

xtaens 发表于 2013-11-5 12:16:13

lcofjp 发表于 2013-11-5 11:44 static/image/common/back.gif
试试把变量定义到DATA20_C行不, @ “DATA20_C”

iar 下面的3个设置我都试了,不行

我觉得还得改xcl文件。。

xtaens 发表于 2013-11-5 12:16:53

dianyuan 发表于 2013-11-5 12:09 static/image/common/back.gif
可以试下看将
-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=5C00-FF7F 这一行改为:
-Z(CONST)D ...

好的,我试试

lcofjp 发表于 2013-11-5 11:25:51

xtaens 发表于 2013-11-5 12:16 static/image/common/back.gif
iar 下面的3个设置我都试了,不行

我觉得还得改xcl文件。。

需要选择large

xtaens 发表于 2013-11-5 13:29:24

lcofjp 发表于 2013-11-5 12:38 static/image/common/back.gif
需要选择large

large 也报错的

ShuJi187 发表于 2013-11-5 13:30:37

这个问题和这个是一样的,http://www.edaboard.com/thread137577.html
继续关注!

xtaens 发表于 2013-11-5 16:00:03

dianyuan 发表于 2013-11-5 12:09 static/image/common/back.gif
可以试下看将
-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=5C00-FF7F 这一行改为:
-Z(CONST)D ...

Ls,这个方法不行
第一种改法:




xtaens 发表于 2013-11-5 16:03:45

dianyuan 发表于 2013-11-5 12:09 static/image/common/back.gif
可以试下看将
-Z(CONST)DATA16_C,DATA16_ID,TLS16_ID,DIFUNCT,CHECKSUM=5C00-FF7F 这一行改为:
-Z(CONST)D ...

第二种改法还是不行



xtaens 发表于 2013-11-5 20:25:02

lcofjp 发表于 2013-11-5 11:25 static/image/common/back.gif
需要选择large

刚才我仔细看了5438A手册中关于flash 的布局与地址分配,发现

这个xcl文件没有一点需要改的地方。

然后又看了iar 430 c compiler中的说明,发现还是要配置data model。我选择了large,但是提示报错,仔细看原来是我包含的启动文件报错了,去掉包含后就不报错了。

不知道large模式下用的是什么启动文件

lcofjp 发表于 2013-11-5 21:24:33

xtaens 发表于 2013-11-5 20:25 static/image/common/back.gif
刚才我仔细看了5438A手册中关于flash 的布局与地址分配,发现

这个xcl文件没有一点需要改的地方。


不清楚你的启动文件是什么,因为我用IAR建立C工程的时候,从来就没有过启动文件。

xtaens 发表于 2013-11-6 09:52:31

lcofjp 发表于 2013-11-5 21:24 static/image/common/back.gif
不清楚你的启动文件是什么,因为我用IAR建立C工程的时候,从来就没有过启动文件。 ...

下面是我以前用的启动文件,这个文件在软件安装目录下。

包含到工程中的好处是:可以看到程序到main函数前都干了什么,这个过程都是在启动文件中度过的。

文件名:cstartup.s43/**************************************************
*
* System initialization code for the MSP430 IAR C/EC++ Compiler.
*
* Copyright ?2002-2008 IAR Systems AB.
*
* $Revision: 7961 $
*
**************************************************/

//
// There are two libraries provided with compilers from IAR Systems,
// CLib and DLib.This file is designed to work with both libraries.
// Some parts of it is DLib-specific.However, those parts will not
// be included when building an application using CLib.
//

//
// Please define one of the following preprocessor symbols in order to
// customize the system initialization process.
//
// IGNORE_SEG_INIT   -- To remove segment initialization
// IGNORE_DATA16_DATA-- To remove segment initialization of DATA16 data
// IGNORE_DATA20_DATA-- To remove segment initialization of DATA20 data
// IGNORE_RAMFUNC_INIT -- To remove segment initialization of ramfunc code
// DISABLE_WATCHDOG    -- To disable the watchdog
//
// Note: In the current version the symbols "IGNORE_SEG_INIT" and
// "IGNORE_DATA16_DATA" will perform the same task.However, both are
// supported in order to be compatible with other IAR Compilers.
//
// Note: To disable the watchdog, a device-specific header file will
// be included.
//

#include "macros.m43"
#include "cfi.m43"

#define DISABLE_WATCHDOG   //新增宏,关闭狗,2013-08-02

#ifdef DISABLE_WATCHDOG
#include "msp430.h"
#endif


#define XRSEGCSTART RSEG CSTART:CODE:NOROOT(1)

      XCFI_NAMES libNames
      XCFI_COMMON libCommon, libNames

      // The CPU40 warning is issued when a Jxx instruction is place
      // at the end of a segment part. However, this case is safe,
      // as we have control of what will be placed right after the
      // instruction.
      SUPPRESS_CPU40_WARNING


// ---------------------------------------------------------
// The cstartup code -- call __low_level_init, perform initialization,
// call constructors and call main.If main returns the exit system
// is started.
//

      MODULE?cstart

//
// Ensure that this is build with the same "positions independent
// code" settings as the compiler uses.
//

      XPICRTMODEL


//
// Forward declarations of segments.
//

      RSEG    HEAP:DATA:NOROOT(1)
      RSEG    CSTACK:DATA:NOROOT

      RSEG    DATA16_Z:DATA:NOROOT
      RSEG    DATA16_I:DATA:NOROOT
      RSEG    DATA16_ID:CONST:NOROOT
      RSEG    CODE_I:DATA:NOROOT
      RSEG    CODE_ID:CONST:NOROOT
#if __CORE__==__430X_CORE__
      RSEG    DATA20_Z:DATA:NOROOT
      RSEG    DATA20_I:DATA:NOROOT
      RSEG    DATA20_ID:CONST:NOROOT
#endif
      RSEG    TLS16_I:DATA:NOROOT
      RSEG    TLS16_ID:CONST:NOROOT

// ---------------------------------------------------------
// System initialization.
//

      XRSEGCSTART
      PUBLIC__program_start

      EXTERN?reset_vector
      REQUIRE ?reset_vector

__program_start:

      PUBLIC ?cstart_begin
?cstart_begin:

      // --------------------
      // Turn off the watchdog.
      //
      // Note: This is excluded by default. Please define
      // DISABLE_WATCHDOG to include it.
      //

#ifdef DISABLE_WATCHDOG

      MOV   #WDTPW + WDTHOLD, &WDTCTL
#endif

      // --------------------
      // Initialize SP to point to the top of the stack.
      //
      MOV   #SFE(CSTACK), SP

      //
      // Ensure that main is called.
      //
      REQUIRE ?cstart_call_main


// -----------------------------------------------
// Call __low_level_init to perform initialization before initializing
// segments and calling main. If the function returns 0 no segment
// initialization should take place.
//
// Link with your own version of __low_level_init to override the
// default action: to do nothing but return 1.
//

      XRSEGCSTART

      PUBLIC?cstart_call_low_level_init
      EXTERN__low_level_init

?cstart_call_low_level_init:
      XXCALL__low_level_init
      CMP   #0, W0
      JEQ   ?cstart_call_main


// -----------------------------------------------
// Segment initialization:
//
// xxx_Z-- uninitialized data that are filled with zeros.
// xxx_I-- initialized data that gets the values from the corresponding
//         xxx_ID segment.
//

#ifndef IGNORE_SEG_INIT


      // --------------------
      // Initialize code for __ramfunc functions.
      //

      XRSEGCSTART
      PUBLIC?cstart_init_copy_ramfunc

?cstart_init_copy_ramfunc:

#ifndef IGNORE_RAMFUNC_INIT

#ifndef REGISTER_MODEL_REG20

      MOV   #SFB CODE_I,CW0
      XMOVROPIADDR SFB CODE_ID, CW1

      MOV   #sizeof CODE_I, CW2

      XXCALL__data16_memcpy

#else// MSP430X with 20 bit pointers.

      EXTERN__data20_memcpy

      MOVA    #SFB CODE_I,CW0
      XMOVROPIADDR SFB CODE_ID, CW1
      MOV.W   #LWRD(sizeof CODE_I), L1L
      MOV.W   #HWRD(sizeof CODE_I), L1H

      XXCALL__data20_memcpy


#endif // REGISTER_MODEL_REG20

#endif // IGNORE_RAMFUNC_INIT


      // --------------------
      // Initialize data16
      //

#ifndef IGNORE_DATA16_DATA

      //
      // Clear DATA16_Z.
      //

      XRSEGCSTART
      PUBLIC?cstart_init_zero
      EXTERN__data16_memzero

?cstart_init_zero:
      MOV   #SFB DATA16_Z,    CW0
      MOV   #sizeof DATA16_Z, CW1

      XXCALL__data16_memzero


      //
      // Copy DATA16_ID to DATA16_I
      //

      XRSEGCSTART
      PUBLIC?cstart_init_copy
      EXTERN__data16_memcpy

?cstart_init_copy:
      MOV   #SFB DATA16_I,CW0
      XMOVROPIADDR SFB DATA16_ID, CW1

      MOV   #sizeof DATA16_I, CW2

      XXCALL__data16_memcpy

#endif // IGNORE_DATA16_DATA


      // --------------------
      // Data20
      //

#if __CORE__==__430X_CORE__


#ifndef IGNORE_DATA20_DATA

      //
      // Clear DATA20_Z.
      //

      XRSEGCSTART
      PUBLIC?cstart_init_zero20
      EXTERN__data20_memzero

?cstart_init_zero20:
      MOVA    #SFB DATA20_Z,W0
      MOV.W   #LWRD(sizeof DATA20_Z), L1L
      MOV.W   #HWRD(sizeof DATA20_Z), L1H

      XXCALL__data20_memzero


      //
      // Copy DATA20_ID to DATA20_I
      //

      XRSEGCSTART
      PUBLIC?cstart_init_copy20
      EXTERN__data20_memcpy

?cstart_init_copy20:
      MOVA    #SFB DATA20_I,CW0
      XMOVROPIADDR SFB DATA20_ID, CW1
      MOV.W   #LWRD(sizeof DATA20_I), L1L
      MOV.W   #HWRD(sizeof DATA20_I), L1H

      XXCALL__data20_memcpy

#endif // IGNORE_DATA20_DATA

#endif // MSP430X


      // --------------------
      // Thread-local storage
      //

      //
      // Copy TLS16_ID to TLS16_I
      //

      XRSEGCSTART
      PUBLIC__cstart_init_tls
      EXTERN__data16_memcpy

__cstart_init_tls
      MOV.W   #SFB TLS16_I,    CW0
        XMOVROPIADDR SFB TLS16_ID, CW1
      MOV.W   #sizeof TLS16_I, CW2

      XXCALL__data16_memcpy

#endif // IGNORE_SEG_INIT



// -----------------------------------------------
// Call constructors of static objects.
//

      RSEG    DIFUNCT:CONST:NOROOT(1)
      XRSEGCSTART
      PUBLIC?cstart_call_ctors

      EXTERN__call_ctors

?cstart_call_ctors:

      XMOVROPIADDR SFB DIFUNCT, CW0
      XMOVROPIADDR SFE DIFUNCT, CW1

      XXCALL__call_ctors


// -----------------------------------------------
// Call main() with no arguments and then exit using the return value
// of main as the parameter.
//

      XRSEGCSTART
      PUBLIC?cstart_call_main

      EXTERNmain
      EXTERNexit

?cstart_call_main:
      XXCALLmain
      XXCALLexit

      PUBLIC?cstart_end
?cstart_end:

      // Note: "ENDMOD label" means code that this module is the
      // start of the application.
      ENDMOD__program_start




// ---------------------------------------------------------
// __low_level_init
//
// The only action of this default version of __low_level_init is to
// return 1. By doing so it signals that normal initialization of data
// segments should be done.
//
// A customized version of __low_level_init may be created in order to
// perform initialization before initializing segments and calling main
// and/or to skip initialization of data segments under certain
// circumstances.
//
// For further details see sample file lowinit.c
//


      MODULElowinit

      PUBLIC__low_level_init

      RSEG    CODE:CODE:NOROOT(1)

__low_level_init:
      MOV   #1, W0                  // By returning 1 this function
      XRET                            // indicates that the normal
                                        // initialization should take place

      ENDMOD


// ---------------------------------------------------------
// Define reset vector.
//

      MODULE?reset_vector

      RSEG    RESET:CONST:NOROOT(1)
      PUBLIC?reset_vector
      EXTERN__program_start

?reset_vector:
      DC16    __program_start

      ENDMOD


// ---------------------------------------------------------
// ?CPU30_OFFSET
//
// The compiler compensates for the CPU30 hardware bug by adding or
// subtracting the symbol ?CPU30_OFFSET from certain immediates.Here,
// it is defined to the default value zero (0), for when the device is
// not affected by CPU30.If the device is affected, the value must be
// set to two (2) using a linker command line override:
//
//   -D?CPU30_OFFSET=2.
//
// The override is normally placed in the device-specific .xcl file.

      MODULE?cpu30_offset

        PUBLIC?CPU30_OFFSET

?CPU30_OFFSET   EQU   0

        ENDMOD

      END

lcofjp 发表于 2013-11-6 09:58:30

xtaens 发表于 2013-11-6 09:52 static/image/common/back.gif
下面是我以前用的启动文件,这个文件在软件安装目录下。

包含到工程中的好处是:可以看到程序到main函数 ...

分析报错的原因,最终会找到问题所在的。
页: [1]
查看完整版本: iar 430中定义的const变量太多,提示超出范围了,xcl文件怎么