打印
[开发工具]

求教:IAR5.3中,数据存放到绝对地址问题

[复制链接]
4138|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
elecbug|  楼主 | 2009-4-1 23:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
在4.42中如下形式编译正常:
__root const char xxx[3] @ LLLL = {1,2,3};

在5.3中报错:
Error[Be022]: location address not allowed for initialized variables (writable variables without the __no_init attribute)

请问应写成什么形式?
沙发
Again_gyf| | 2009-4-2 21:02 | 只看该作者

re

Technical Note 36121
Absolute placement (v.5.xx) (in C source)
EW targets:     ARM
EW component:     C/C++ compiler
Keywords:     "@" / #pragma locate, absolute address
Last update:     February 17, 2009

Background - general
There are major changes in the EWARM between version 4.x and version 5.x. The link to the right gives some more information.

Background - specific
Absolute placement of constants are no longer allowed:

int const a @ 102030;


Problem
There is no way of express the above in an output file in the elf/dwarf format.

Solution 1 - (if you must use const)
The solution consists of two changes.
In the .c file place the variable in a named segment. In the .icf (for the linker) place the segment at a specific location.

The C source can have looked like this in 4.xx:

const char RELEASEDATE[16] @ 0x0000FF10 = __DATE__ ;
const char RELEASETIME[16] @ 0x0000FF20 = __TIME__ ;

This will be changed to this in the .c file in 5.xx:

#pragma location = "ConstSection1"
__root const char RELEASEDATE[16] = __DATE__ ;
#pragma location = "ConstSection2"
__root const char RELEASETIME[16] = __TIME__ ;

In the .icf file are these lines added:

place at address mem: 0x0000FF10    { readonly section ConstSection1 };
place at address mem: 0x0000FF20    { readonly section ConstSection2 };

The Ilink will then place the sections ConstSection1 at address 0x0000FF10, and the section ConstSection2 is placed at address 0x0000FF20.

Solution 2 - (if you dare not to use const)
The solution consists of a change from..

int const a @ 102030;

...to...

int a @ 102030;

...the drawback of this solution is that you disable the ICCARM which make checks for "do not write to const object". So this solution can lead to run-time errors.

Migration
It is also highly recommended that you have a look at the "The migration process" in the above guide. This will give you a good picture of what has to be done to migrate from version 4 to version 5 of the ARM IAR Embedded Workbench.

使用特权

评论回复
板凳
colaring| | 2009-4-2 21:24 | 只看该作者

。。

楼主,我也正在用IAR 5.3,但是全速跑的时候放了断点不会停,而手动停止后,在当前指令前或者后面放断点再全速跑就可以停止。。。昏死,运行uCOS Probe都不行。不过用的不是一个月试用版,是D版的,你呢?

使用特权

评论回复
地板
elecbug|  楼主 | 2009-4-2 21:38 | 只看该作者

楼上:我换回4.42了

谢谢回复。
5.3下,一开始程序还可以下载,现在下载都成问题,受不了,只好换回4.42。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

13

帖子

0

粉丝