How can I allocate a piece of memory from a certain physical memory in embedded arm processor?

859 views Asked by At

I am using zynq device, trying to transfer data from DRAM to the peripheral of ARM by a piece of standalone program (without OS). In the example code, I found this code to statement the source address and destination address of the transaction.

volatile static u8 SrcBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (64)));
volatile static u8 DestBuffer[BUFFER_BYTESIZE] __attribute__ ((aligned (64)));

Since there's no OS, what's the value of address from? How can I change it?

2

There are 2 answers

2
Realtime Rik On

You need to define a section a in the linker file and then place the data in it using (for GCC):

__attribute__ (( section ( "your_section" ) ) )

In the linker file (will have other stuff in it already as well) something like:

MEMORY
{
   ....will be other stuff here
   ....
   YOUR_MEMORY_NAME : ORIGIN = 0xWhatever, Length = a_length // Creates a memory region 
}

SECTIONS
{
   ...
   ...

   .something_data :
   {
      *(your_data)
   } > YOUR_MEMORY_NAME 

   ...

}
0
Gaurav Pathak On

Looking at the piece of information provided it seems that the code is doing DMA to and from DRAM to a particular hardware buffer register of the peripheral of the micro-controller.

There should be a code where the hardware peripheral register address is used like SBUF or I2C_DATA_REG or something similar to this. If you want to know the address of both the buffers you may need Debugger using which you can view the address of both the arrays or if you have UART working then you can print it on console. If you want to fix the memory of both the buffers then you need to follow what @Realtime Rik suggested