title: Acessing shared memory between the PRU and beagle bone
body: <p>I need your help </p>
  
  <p>I am having some problems in accessing the PRU shared registers on the Beaglebone side. </p>
  
  <p>So, I am writing in the desired memory addresses on the PRU side ( I can verify it be using the prudebug tool provided here: <a href="https://markayoder.github.io/PRUCookbook/" rel="nofollow noreferrer">https://markayoder.github.io/PRUCookbook/</a> , which I can use to check the content of the PRU registers). But the trouble comes when I try to access it from the arm side: in the Pru, I have written the value 0xED in the registers 0x10000, however, in the arm side I am unable to read it. </p>
  
  <p>I think I have to use the mmap function of the kernel to get access of physical memory addresses, but might I been doing something wrong on the usage of the function itself. Can anyone shed some light on what might be happening here? </p>
  
  <p>PRU side:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  #include &lt;pru_cfg.h&gt;
  #include "resource_table_empty.h"
  
  #define PRU_SHARED_MEM_ADDR 0x00010000
  
  void main(void)
  {
      // enable OCP
      CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
      volatile int* buffer = (volatile int *) PRU_SHARED_MEM_ADDR;
      buffer[0] = 0xED;
      /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port-&gt;Shared memory */
      CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
  }
  </code></pre>
  
  <p>Arm side: </p>
  
  <pre><code>#include &lt;sys/mman.h&gt;
  
  #define DDR_BASEADDR   0x10000
  #define OFFSET_DDR     0x00
  
  int main(int argc, char **argv)
  {
     int mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
     if (mem_fd == -1){
          printf("Err");
          return 0;
     }
     volatile void *ddrMapp = NULL;
     volatile void *DDR_regaddr1 = NULL;
  
     ddrMapp = mmap(0, 0x0FFFFFFF, PROT_WRITE | PROT_READ, MAP_SHARED, mem_fd, DDR_BASEADDR);
  
     DDR_regaddr1 = ddrMapp + OFFSET_DDR;
     printf("PRU address: %X\n", &amp;DDR_regaddr1); // returns 0xBEFFFB00
     return(0);
   }
  </code></pre>
  
  <p>ps: Here's the documentation of mmap function: <a href="http://man7.org/linux/man-pages/man2/mmap.2.html" rel="nofollow noreferrer">http://man7.org/linux/man-pages/man2/mmap.2.html</a></p>