Storing variables into data ocm memory

Hallo, I' developing a microcontroller based on powerpc. the only way I know to store some variables into a specific region of memory is instantiating them directly using the command:

unsigned char (*variable_name) = (unsigned char(*))XPAR_PERIPHERAL_BASEADDR;

There are other ways?

If use use the linker script there is a way to "choose" which variables store into a certain region of memory?

Many Thanks Marco

Reply to
Marco T.
Loading thread data ...

Hi Marco,

Yes, you can use a linker script for this, together with a gcc attribute to indicate which segment should receive a given variable.

For example, somewhere in the linker script you could add

. = 0x40000000; .ocm : { *(.ocm) }

This creates a new segment, "ocm", starting at address 0x40000000 (or wherever your OCM is mapped). To actually cause variables to be allocated to this segment, use something like

#define __ocm__ __attribute__((aligned(32),section(".ocm")))

and then declare your variables:

int __ocm__ foo; int __ocm__ bar[128];

You can verify that these ended up in the ocm segment with objdump. And you'll want "ld -T my_linker_script.ld"; google linker-script for tutorials.

Cheers, Peter

Reply to
Peter Monta

Many Thanks for your reply! Marco

Reply to
Marco T.

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.