cancel
Showing results for 
Search instead for 
Did you mean: 

How to port __no_init IAR directive with to GCC compiler? PLEASE HELP ME

007shay
Associate II

I am trying to port an IAR project to STM32CubeIDE and I having several problems. One of them is located in the following line of code

#pragma location=0x30024000
__no_init short rtp_rin_ni [RTP_SIZE_AR ];
#pragma location=0x30024400
__no_init short rtp_play_ni[RTP_SIZE_AR * 4];

and I need full code to help me with that issue I don't know what I need to do.

 

Best regards to everybody!!

 

 

 

7 REPLIES 7
Pavel A.
Evangelist III

Easy, and in a portable way: make the following change in the code 

 

#define rtp_rin_ni  ((short*)0x30024000)
#define rtp_play_ni ((short*)0x30024400)
_Static_assert(0x400 <= RTP_SIZE_AR, "sanity");

 

And verify in your link script (.ld file) that nothing conflicts with memory from  0x30024000, size = 2*5*RTP_SIZE_AR 

You can define this are in the link script for aesthetic reasons, but not really required.

You can also define these arrays in the link script and export them to C (you can try this as homework).

 

 

Make it as a pointer.

Or use a NOLOAD section in your linker script.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

HI,

Can you show me please example of the code

Thank you very much

Thank you for your answer...

if I do this code it will be ok too?

short __attribute__(( section(".noinit") )) rtp_rin_ni[RTP_SIZE_AR];

 

short __attribute__(( section(".noinit2") )) rtp_play_ni[RTP_SIZE_AR * 4];

 

 in flash ld file:

 

.noinit 0x30024000 :

{

KEEP(*(.noinit))

} > RAM_D1

 

.noinit2 0x30024400 :

{

KEEP(*(.noinit2))

} > RAM_D1

Thank you,

 

But in your answer, you define the pointer only...where I configure the array?

 

and if I need to keep memory in the ld FLASH.

I did something but the compiler told me that it is read-only memory error

Pavel A.
Evangelist III

@007shay the array itself is "virtual". you can use the pointer instead of array in most cases: like, rtp_rin_ni[0], rtp_rin_ni[1] and so on.

If you still want to modify the .ld file .... try to add (NOLOAD) :

 

.noinit 0x30024000 (NOLOAD) :
{
KEEP(*(.noinit))
} > RAM_D1
 

 

 Not sure about the syntax, refer to the ld documentation.

 

Absolute addresses as pointers, most portable

 

short *rtp_rin_ni = (short *)0x30024000;
short *rtp_play_ni = (short *)0x30024400;

 

NOLOAD sections in linker script

 

MEMORY
{
...
  RTP (rw) : ORIGIN = 0x30024000, LENGTH = 32K
}

SECTIONS
{
...
.noinit (NOLOAD) :
{
  KEEP(*(.noinit))
  KEEP(*(.noinit.*))
} >RTP
...
}

 

or RTFM..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..