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
Adventurer
Adventurer
1,088 Views
Registered: ‎04-24-2017

Large memory block allocation

Jump to solution

Hi, first the problem then my idea for a solution.

I have a device connected via DMA that generates a lot of data ~22MiB/s in a standalone application.  This data is buffered in the DMA scatter/gather buffers fine, but these are not sufficient for storing the data to use later (either in Linux or for greater than buffer time), so I do some processing and store it elsewhere.  My problem is that I'd like a single contiguous block of memory to store into which makes access easier in a yet-to-be-developed linux application and protects the data from accidental overwriting.

 

I could use malloc, but this is messy and putting large data on the heap is not nice.  My solution is to allocate a block of memory via the linker (based on message two here).  When I do this, I get strange errors (code loops back to entry point and DMA fails to create rings).  My guess as to why is that I'm allocating some memory that is already being used.  According to my calculations I'm allocating memory after the DMA buffers and in DDR0 (see below).

 

So, my questions are, is this the prefered way to allocate memory?  Is there a convenient way to check if a section of memory is being used (other than reading xparameters.h)? and am I correctly allocating my memory blocks?

 

Linker.ld sections 

MEMORY
{
   psu_ddr_0_MEM_0 : ORIGIN = 0x0, LENGTH = 0x80000000
   psu_ddr_1_MEM_0 : ORIGIN = 0x800000000, LENGTH = 0x80000000
   psu_ocm_ram_0_MEM_0 : ORIGIN = 0xFFFC0000, LENGTH = 0x40000
   psu_qspi_linear_0_MEM_0 : ORIGIN = 0xC0000000, LENGTH = 0x20000000
   rawStoreArea(WA) : ORIGIN =0x11200000, LENGTH = 10M 
   eventStoreArea(WA) : ORIGIN =0x17800000, LENGTH = 10M  
   outStoreArea(WA) : ORIGIN =0x1DA00000, LENGTH = 10M  
}

/* Specify the default entry point to the program */

ENTRY(_vector_table)

/* Define the sections, and where they are mapped in memory */

SECTIONS
{
/* raw data section */
.rawStorePtr : {
  __rawStoreStart = . ;
  *(.rawStorePtr)
  _rawStoreEnd = . ;
} > rawStoreArea
/* event data section */
.eventStorePtr : {
  __eventStoreStart = . ;
  *(.eventStorePtr)
  _eventStoreEnd = . ;
} > eventStoreArea
/* out data section */
.outStorePtr : {
  __outStoreStart = . ;
  *(.outStorePtr)
  _outStoreEnd = . ;
} > outStoreArea
.text : {
....

 Set up pointer to these sections

nextSampleToAllocate = (Sample*) &__rawStoreStart;

Thanks

Adam

 

 

0 Kudos
1 Solution

Accepted Solutions
Scholar ericv
Scholar
1,676 Views
Registered: ‎04-13-2015

Re: Large memory block allocation

Jump to solution

@tayloral

 

What is the target processor?

- Zynq 7K series (ARM A9)

- UltraScale+ (ARM A53)

 

If you are on the A9, it can only access 4G memory and

psu_ddr_1_MEM_0 : ORIGIN = 0x800000000, LENGTH = 0x80000000

base address is out of range (1 zero too many error may be?).

No matter the target processor, there are also multiple overlapping sections:

   rawStoreArea(WA) : ORIGIN =0x11200000, LENGTH = 10M 
   eventStoreArea(WA) : ORIGIN =0x17800000, LENGTH = 10M  
   outStoreArea(WA) : ORIGIN =0x1DA00000, LENGTH = 10M  

overlap

   psu_ddr_0_MEM_0 : ORIGIN = 0x0, LENGTH = 0x80000000

 

 

0 Kudos
3 Replies
Scholar ericv
Scholar
1,677 Views
Registered: ‎04-13-2015

Re: Large memory block allocation

Jump to solution

@tayloral

 

What is the target processor?

- Zynq 7K series (ARM A9)

- UltraScale+ (ARM A53)

 

If you are on the A9, it can only access 4G memory and

psu_ddr_1_MEM_0 : ORIGIN = 0x800000000, LENGTH = 0x80000000

base address is out of range (1 zero too many error may be?).

No matter the target processor, there are also multiple overlapping sections:

   rawStoreArea(WA) : ORIGIN =0x11200000, LENGTH = 10M 
   eventStoreArea(WA) : ORIGIN =0x17800000, LENGTH = 10M  
   outStoreArea(WA) : ORIGIN =0x1DA00000, LENGTH = 10M  

overlap

   psu_ddr_0_MEM_0 : ORIGIN = 0x0, LENGTH = 0x80000000

 

 

0 Kudos
Adventurer
Adventurer
997 Views
Registered: ‎04-24-2017

Re: Large memory block allocation

Jump to solution

I'm using UltraScale so big addresses are ok. Thanks for that.  Seems to work now, just a few DMA issues to fix now....

0 Kudos
Adventurer
Adventurer
962 Views
Registered: ‎10-04-2017

Re: Large memory block allocation

Jump to solution

In Linux you can also reserve a block of memory by using reserved-memory in the devicetree.  This prevents this block of memory from being used for anything but it is still accessible for drivers or applications that know where it is at.

 

jeff

 

0 Kudos