Skip to main content
Associate
April 14, 2024
Question

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

  • April 14, 2024
  • 7 replies
  • 2294 views

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!!

 

 

 

    This topic has been closed for replies.

    7 replies

    Pavel A.
    April 14, 2024

    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).

     

     

    007shayAuthor
    Associate
    April 15, 2024

    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

    Tesla DeLorean
    Guru
    April 14, 2024

    Make it as a pointer.

    Or use a NOLOAD section in your linker script.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    007shayAuthor
    Associate
    April 15, 2024

    HI,

    Can you show me please example of the code

    Thank you very much

    Pavel A.
    April 16, 2024

    @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.