Issue acessing pru_data_ram from Ubuntu

Hi,

after implementing the ddr acces example from https://github.com/sagedevices/am335x_pru_package/tree/master/pru_sw/example_apps/ddr_access into my project im stuc at one point.

In my User space code I do

`
prussdrv_map_prumem(PRUSS0_PRU1_DATARAM, (void *) &info->pru_memory);

if (info->pru_memory == NULL) {
fprintf(stderr, “Cannot map PRU0 memory buffer.\n”);
return -ENOMEM;
}
`

to map the Data Ram at 0x2000 from PRU 0 point of view.

physadress=(uint32_t*)prussdrv_get_phys_addr(info->pru_memory);

Gives me the right Physical Adress at 0x4A302000 (refering to AM335x Technical Reference Manual).

On the PRU the init is done by

CT_CFG.SYSCFG_bit.STANDBY_INIT = 0; PRU_ram = ((uint32_t *)&CT_PRU1_0)

When I pass there some Values from the Userspace to the the PRU data RAM the PRU doesn’t seem to get them. (tried various numbers of pin toggling for example etc).
I verified the PRU code via JTAG. When playing with the Memory Browser everything seems working. Even when i am going over the JTAG Connection to the main Processor an therefor the global memory map.

Also when i do something on the PRU like
`
for(x=0;x<100;x++)
{
*(PRU_ram+x)=5;
}

`

and read the memory area back in my user space application I only get the earlier passed data an some garbage.
Am I something missing?

With kind regards
Philipp

Damn it, found my mistake.
Its is very recommended to use the same link.cmd file for linking in CCS as on the Board. facepalm

`

PRU1_0 : org = 0x00002000 len = 0x00000100 CREGISTER=25

`

I didn’t know that those values in the link.cmd file have an effect on the in the actual PRU application loaded values. Thought those addresses where some kind of hard coded inside of the PRU and the link.cmd only some kind of help for the linker. Or is the kind of using them in C messing that up?

At the beginning of the PRU application file they are mapped with

volatile far uint32_t CT_PRU1_0 __attribute__((cregister("PRU1_0", near), peripheral));

and inside of main() the pointer is loaded with

`
PRU_ram = ((uint32_t *)&CT_PRU1_0)

`

I thought that way the address comes from the “cregister” as intended.

Any idea how to really read from cregister?!

With kind regards
Philipp