Allocate Custom Address to shared_dram

Any technical questions about the Epiphany chip and Parallella HW Platform.

Moderator: aolofsson

Allocate Custom Address to shared_dram

Postby msuthar25 » Wed Aug 06, 2014 10:40 am


While executing the hello_world program i noticed that the outbuf is defined in the shared_dram
char outbuf[128] SECTION("shared_dram");

and while reading the output of the core from host it is reading from location 0x0
e_read(&emem, 0, 0, 0x0, emsg, _BufSize);

I want to know how to change the default address of 0x0 allocated by device to some other address in the shared dram which can be accessed by the epiphany code.

Thank you
Posts: 17
Joined: Mon Jun 30, 2014 7:31 am

Re: Allocate Custom Address to shared_dram

Postby sebraa » Wed Aug 06, 2014 8:36 pm

On the host, you choose the address at allocation time. The default linker scripts use the lower 16 MB of DRAM for the C library, and declare the upper 16 MB as a section "shared_dram". All e_read()/e_write() offsets are relative to the address you allocated in the beginning.

On the other hand, nobody keeps you from accessing shared memory on the Epiphany through a pointer; on the Parallella board, the shared_dram section is at 0x8f000000 - if you allocate with an offset of 0x01000000, you need to use the offset 0x0. Write to 0x8f004000 on the Epiphany, and you need to e_read from 0x4000 (given the same allocation).
Posts: 495
Joined: Mon Jul 21, 2014 7:54 pm

Re: Allocate Custom Address to shared_dram

Postby msuthar25 » Thu Aug 07, 2014 11:59 am

I am using this code for testing the mutex
Code: Select all
int main(void)
   e_mutex_t *mutex_p;
   unsigned counter;
   unsigned *p;
   unsigned *p1;
   mutex_p = (void *)0x00002000;

   // Wait to get the key
   e_mutex_lock(e_group_config.core_row, e_group_config.core_col, mutex_p);
   // After get the key, add 1 to the counter
   counter = *((unsigned *) 0x8f004000);//access the global memory increment counter
   counter = counter + 1;
   *((unsigned *) 0x8f004000) = counter;
   // Release the key
   e_mutex_unlock(e_group_config.core_row, e_group_config.core_col, mutex_p);
   return 0;

and host code for this is
Code: Select all
#include <e-hal.h>
#define _BufOffset (0x10000000)

int main(int argc, char *argv[])
   e_platform_t platform;
   e_epiphany_t dev;
   e_mem_t emem;
   unsigned buf;

   // initialize system, read platform params from
   // default HDF. Then, reset the platform and
   // get the actual system parameters.


   //allocate memory in the shared dram
   e_alloc(&emem, _BufOffset, sizeof(unsigned));
       // Open a workgroup
   e_open(&dev, 0, 0, platform.rows, platform.cols);
   // Load the device program onto all the other eCores
   e_load_group("e_mutex_test.srec", &dev, 0, 0, 4, 4, E_TRUE);
   // Wait for core program execution to finish
   // Read message from shared buffer
   e_read(&emem, 0, 0, 0x4000, &buf, sizeof(unsigned));

   // Print the message
   printf("Counter Value in Shared memory is: %0d",buf);

   // Finalize the e-platform connection.

   return 0;

This is showing error as
mutex_test.elf: ee_mread_buf(): Buffer range is out of bounds.

I am not able to figure out why?

Posts: 17
Joined: Mon Jun 30, 2014 7:31 am

Return to Epiphany and Parallella Q & A

Who is online

Users browsing this forum: No registered users and 13 guests