2024-04-14 02:59 AM
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!!
2024-04-14 02:57 PM - edited 2024-04-14 02:59 PM
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).
2024-04-14 02:59 PM
Make it as a pointer.
Or use a NOLOAD section in your linker script.
2024-04-14 09:17 PM
HI,
Can you show me please example of the code
Thank you very much
2024-04-14 09:23 PM
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
2024-04-14 09:31 PM
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
2024-04-16 10:06 AM - edited 2024-04-16 10:06 AM
@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.
2024-04-16 10:45 AM - edited 2024-04-16 10:45 AM
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..