Placing strings

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Placing strings

跳至解决方案
2,333 次查看
Teckna
Contributor V

Hi everyone,

 

I'm using CW 10.2, MQX 3.8.1 and Kinetis K60.

Due to an alomst full RAM use, I'm doing some optimization in my code.

I noticed that the instruction:

printf( "String to print\n");

Is compiled putting the pointer to the string in the register and then calling the printf function: the pointer points to an address placed in RAM that is initialized in the startup phase by copying data from the flash to the RAM.

I would like to put the string "String to printf\n" only in flash the way the copying phase is not needed and the RAM location can be used in another way.

 

How must I specify this requirement in CW?

 

Many thanks

Teckna

标签 (1)
标记 (4)
0 项奖励
回复
1 解答
1,786 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

there is a compiler option you have to set for putting strings into .rodata:

2837_2837.png

Hope this helps,

Erich

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,786 次查看
Monica
Senior Contributor III

Hey there Teckna!

Has this helped you out?

We would like to know how is your project going!

Regards!

0 项奖励
回复
1,786 次查看
Teckna
Contributor V

Hi Monica,

At Erich suggestion, I saved a lot of RAM.

Many thanks

Teckna

0 项奖励
回复
1,787 次查看
BlackNight
NXP Employee
NXP Employee

Hello,

there is a compiler option you have to set for putting strings into .rodata:

2837_2837.png

Hope this helps,

Erich

0 项奖励
回复
1,786 次查看
Teckna
Contributor V

No one can help?

Teckna

0 项奖励
回复
1,786 次查看
CrasyCat
Specialist III

Hello

As far as I can tell the string constants are allocated in section .rodata.

Can you please check in your linker file, where this section is placed.

If it is placed in a block of memory located in RAM, you may just have to move it over into a block of memory located in flash

I hope this helps.

CrasyCat

0 项奖励
回复