On 8/15/2017 8:12 AM, M Pitman wrote: > I'm trying to get to the values of data stored in memory on the Beaglebone > Black > and experiencing a very fundamental problem. I have the following C code > running in Linux. > > int *p; > int value; > > p = (int *)0x4A300000; // Start of PRU0 data ram > printf("p addr: 0x%x\n", p); > value = *p; > printf("value: 0x%x\n", value); > > p prints fine but trying to print *p or value gives a Segmentation fault. > Can > anyone explain to me what is going on and how I can get to the data stored at > a > memory location on the BeagleBone?
In your code, p is a pointer to the user memory space, which goes through virtual address translation before becoming a physical address which is what you're trying to use. You need to mmmap() the physical region you want to use from /dev/mem into your user memory space. This will give you a user-mode pointer to the physical memory. There are many examples of how to do this floating around, but since you're trying to use the PRU, you might want to checkout something like: prussdrv (C code for accessing the PRU using uio_pruss): https://github.com/beagleboard/am335x_pru_package/blob/master/pru_sw/app_loader/interface/prussdrv.c#L70 -- Charles Steinkuehler char...@steinkuehler.net -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/1ce459d9-655f-f0b8-8765-a67379b0c3fc%40steinkuehler.net. For more options, visit https://groups.google.com/d/optout.