UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Participant mberemand
Participant
330 Views
Registered: ‎10-22-2018

How do I refer to a specific memory region from my applications?

I am using a Zynq ZC702. I am trying to create a shared memory region that both CPUs can access. I referred to the example here https://www.xilinx.com/support/documentation/application_notes/xapp1079-amp-bare-metal-cortex-a9.pdf but I would like to use a region of DDR instead of OCM and use semaphores.

In my lscript.ld files for both CPU applications I specified a new sharedMem region at 0x10 0000 and moved the main regions up to 0x1000 0000 and 0x2000 0000 respectively.

MEMORY
{
   ps7_ddr_0 : ORIGIN = 0x10000000, LENGTH = 0x10000000
   ps7_qspi_linear_0 : ORIGIN = 0xFC000000, LENGTH = 0x1000000
   ps7_ram_0 : ORIGIN = 0x0, LENGTH = 0x30000
   ps7_ram_1 : ORIGIN = 0xFFFF0000, LENGTH = 0xFE00
   sharedMem  : ORIGIN = 0x100000, LENGTH = 0xFF00000
}
MEMORY
{
   ps7_ddr_0 : ORIGIN = 0x20000000, LENGTH = 0x10000000
   ps7_qspi_linear_0 : ORIGIN = 0xFC000000, LENGTH = 0x1000000
   ps7_ram_0 : ORIGIN = 0x0, LENGTH = 0x30000
   ps7_ram_1 : ORIGIN = 0xFFFF0000, LENGTH = 0xFE00
   sharedMem  : ORIGIN = 0x100000, LENGTH = 0xFF00000
}

How would I allocate storage from this region for data structures? Do I need to declare them in the main region and manually call Xil_MemCpy?

Tags (3)
0 Kudos
3 Replies
Scholar ericv
Scholar
295 Views
Registered: ‎04-13-2015

Re: How do I refer to a specific memory region from my applications?

@mberemand 

In your linker script, use this:

Sections
{
   ...                   /* Other sections                                       */

.Shared { /* THIS IS YOUR SHARED SECTION */
PROVIDE(Var1 = .); /* Export the symbol Var1 at the current address */
. = .+ 4; /* Reserve 4 bytes for Var1 */
PROVIDE(Var2 = .); /* Export the symbol Var2 at the current address */
. = .+ 16; /* Reserve 16 bytes for Var2 */
} > sharedMem /* Var1 & Var2 land in sharedMem */

Using that scheme you must declare in "C"  Var1 and Var2 as extern everywhere.

i.e.

extern int Var1;
extern int Var2[4];

You should simplify your life using SMP instead AMP.

 

0 Kudos
Participant mberemand
Participant
276 Views
Registered: ‎10-22-2018

Re: How do I refer to a specific memory region from my applications?

Is there an example of how to configure the two CPU projects for an SMP configuration? Does the linker script need any changes from the default for that?

0 Kudos
Scholar ericv
Scholar
266 Views
Registered: ‎04-13-2015

Re: How do I refer to a specific memory region from my applications?

@mberemand 

running SMP is not very difficult; it's basically alike this and only you only need a single image meaning all variables & code is shared between the 2 cores and the linker script doesn't require anything special.

1 - create a vector table for core #1
2 - Set the reset entry in that vector table to branch to something like this:
ldr sp, =Core1Stack
b Core1Main
and fill the rest of the table with the same stuff as in Core #0 vector table.
3 - Like in AMP, Core #0 set VBAR of Core #1 vector table and release Core #1 from reset.

Even simpler: download our free SMP Barmetal framework (It provides many add-ons) from

www.code-time.com

0 Kudos