Placing strings

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Placing strings

Jump to solution
1,264 Views
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

Labels (1)
0 Kudos
1 Solution
717 Views
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

View solution in original post

0 Kudos
5 Replies
717 Views
Monica
Senior Contributor III

Hey there Teckna!

Has this helped you out?

We would like to know how is your project going!

Regards!

0 Kudos
717 Views
Teckna
Contributor V

Hi Monica,

At Erich suggestion, I saved a lot of RAM.

Many thanks

Teckna

0 Kudos
718 Views
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 Kudos
717 Views
Teckna
Contributor V

No one can help?

Teckna

0 Kudos
717 Views
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 Kudos