Hi Fred, The problem is that DDR_BASEADDR != PRU_SHARED_MEM_ADDR Ie. The shared memory from the PRU's view is 0x10000, but from the Arm host it is 0x4A300000.
Mark explains pru/host shared memory in a later part of chapter 5: https://markayoder.github.io/PRUCookbook/05blocks/blocks.html#_solution_4 "Controlling the PWM Frequency" Thanks, Alex On Thu, Nov 22, 2018 at 12:53 PM Fred Gomes <fred.p.gome...@gmail.com> wrote: > Thank you very much for your answer to Chad, > > I've tried this piece of code: > > Arm side: > > #define DDR_BASEADDR 0x10000 > 0x10000 is the location only the PRU has for shared memory. Change this to the value that the Arm sees in terms of PRU shared memory location. > #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", &DDR_regaddr1); > > return(0); > } > > PRU side: > > #include <stdint.h> > #include <pru_cfg.h> > #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 --> Shared memory > */ > CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; > } > > And the value returned from the printf is 0xBEFFFAFC , rather than > 0x000000ED. Maybe I am pointing to the wrong physical address, do you know > what am I doing wrong here? > > Thank you very much, > Fred Gomes > > > > Chad Baker <cmbak...@gmail.com> escreveu no dia quarta, 21/11/2018 à(s) > 16:55: > >> On the C-side, you need to find the address that maps the physical to >> logical address. The function "mmap" does that. >> volatile int *buffer = (volatile int *)mmao( PRU_SHARED_ADDRESS, ... >> Check the man pages for how to use mmap. >> Chad >> >> On 11/21/18 7:47 AM, Fred Gomes wrote: >> >> Can anyone explain to me why the below example does not work? I could >> confirm on the PRU side that I am writing correctly in the 0x10000 address, >> however, I can't get the written value in the beagle bone side. It's quite >> confusing to me, since if the memory is shared it should work. >> >> PRU code: >> >> #include <stdint.h> >> #include <pru_cfg.h> >> #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 --> Shared >> memory */ >> CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; >> } >> >> Host C++ code: >> >> #include <unistd.h> >> #include <stdio.h> >> #include <inttypes.h> >> #include <prussdrv.h> >> #include <pruss_intc_mapping.h> >> >> using namespace std; >> >> #define PRU_SHARED_MEM_ADDR 0x00010000 >> >> int main(int argc, char **argv) >> { >> >> volatile int* buffer = (volatile int *)PRU_SHARED_MEM_ADDR; >> >> >> printf("Memory address: %x\n", &buffer); >> >> return(0); >> } >> >> Regards, >> Fred Gomes >> >> <fred.p.gome...@gmail.com> escreveu no dia terça, 20/11/2018 à(s) 17:13: >> >>> Hi, >>> >>> I need your help, >>> >>> I am developing an application on the beagle bone for reading data for >>> an SPI slave. For that, I have to use the PRU since the data transmission >>> is up to 15 KHz. >>> >>> Following this tutorial: https://markayoder.github.io/PRUCookbook/ , in >>> the *Chapter** 5 - Memory allocation*, it is explained how memory >>> allocation works on the PRU, as well as how to store variables on specific >>> memory addresses. But he doesn't mention how do I get access to those >>> memory addresses from a host code. >>> >>> I did some researching on the internet and everything I can find is >>> examples of getting access to specific memory adresses using the prussdrv, >>> which I think no longer work in the latest Debian images ( I tried to use >>> it and it trhowed an error from the very beginning when trying to open the >>> drive (*prussdrv_open()*) . Can anyone give me an inkling on how can I >>> achieve this? >>> >>> >>> Ps: Here's an example using the prussdrv : >>> http://catch22.eu/beaglebone/beaglebone-pru-ipc/ >>> >>> Best regards, >>> Fred Gomes >>> -- >>> For more options, visit http://beagleboard.org/discuss >>> --- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "BeagleBoard" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/beagleboard/R8gzE6POFZU/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> beagleboard+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/beagleboard/c697c5b6-70ff-48e1-97e9-9f89613ba455%40googlegroups.com >>> <https://groups.google.com/d/msgid/beagleboard/c697c5b6-70ff-48e1-97e9-9f89613ba455%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> 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/CAJHs20xwyLQ3MVNmT7O%2BdBGTptzrYB-GTuN2xS-dB8qjLtgwKA%40mail.gmail.com >> <https://groups.google.com/d/msgid/beagleboard/CAJHs20xwyLQ3MVNmT7O%2BdBGTptzrYB-GTuN2xS-dB8qjLtgwKA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> >> >> -- >> For more options, visit http://beagleboard.org/discuss >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "BeagleBoard" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/beagleboard/R8gzE6POFZU/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> beagleboard+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/beagleboard/4b70ca6a-9593-4a38-b727-9f90b5b13dc3%40gmail.com >> <https://groups.google.com/d/msgid/beagleboard/4b70ca6a-9593-4a38-b727-9f90b5b13dc3%40gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > 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/CAJHs20zbxQu4fmF24JcOk4JnVEFHfHKunP%3DQHZfir08fW6x3YQ%40mail.gmail.com > <https://groups.google.com/d/msgid/beagleboard/CAJHs20zbxQu4fmF24JcOk4JnVEFHfHKunP%3DQHZfir08fW6x3YQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAHeneC8PSEOKa9QQ_asgu9Mft%3D6BF8CSjW4aUZNgBU4pFkqtLw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.