Part Number: AM6548
Hi Ti,
We are tying to get PRU memory by mmap on Ti EVM board with SDK ti-processor-sdk-linux-am65xx-evm-07_03_00_07.
Below is the sample code to access.
#define AM65X_PRU0_SHARED_ADDR 0x0B010000
#define AM65X_PRU0_HSIO_LEN 0x1000
#define AM65X_PRU1_SHARED_ADDR 0x0B110000
#define AM65X_PRU1_HSIO_LEN 0x1000
#define AM65X_PRU2_SHARED_ADDR 0x0B210000
#define AM65X_PRU2_HSIO_LEN 0x1000
#define AM65X_HSIO_REG_OFFSET 0x1000
PRU_fd = open("/dev/mem", O_RDWR);
if (PRU_fd == -1)
{
printf("get PRU device is error \n");
return -1;
}
g_pPru0HSIO = NULL;
AM65X_PRU0_SHARED_BASE = (unsigned char*) mmap(0, AM65X_PRU0_HSIO_LEN,
PROT_WRITE | PROT_READ,
MAP_SHARED, PRU_fd,
AM65X_PRU0_SHARED_ADDR + AM65X_HSIO_REG_OFFSET);
if (AM65X_PRU0_SHARED_BASE == MAP_FAILED)
{
printf("get PRU 0 shared memory mapping error %s(%d)\n", strerror(errno), errno);
}
else
{
g_pPru0HSIO = AM65X_PRU0_SHARED_BASE;
printf("PRU 0 = %x \n");
}
////////////////////////////////////////////////////////////////
g_pPru1HSIO = NULL;
AM65X_PRU1_SHARED_BASE = (unsigned char*) mmap(0, AM65X_PRU1_HSIO_LEN,
PROT_WRITE | PROT_READ,
MAP_SHARED, PRU_fd,
AM65X_PRU1_SHARED_ADDR + AM65X_HSIO_REG_OFFSET);
if (AM65X_PRU1_SHARED_BASE == MAP_FAILED)
{
printf("get PRU 1 shared memory mapping error %s(%d)\n", strerror(errno), errno);
}
else
{
g_pPru1HSIO = AM65X_PRU1_SHARED_BASE;
printf("PRU 1 = %x \n");
}
////////////////////////////////////////////////////////////////
g_pPru2HSIO = NULL;
AM65X_PRU2_SHARED_BASE = (unsigned char*) mmap(0, AM65X_PRU2_HSIO_LEN,
PROT_WRITE | PROT_READ,
MAP_SHARED, PRU_fd,
AM65X_PRU2_SHARED_ADDR + AM65X_HSIO_REG_OFFSET);
if (AM65X_PRU2_SHARED_BASE == MAP_FAILED)
{
printf("get PRU 2 shared memory mapping error %s(%d)\n", strerror(errno), errno);
}
else
{
g_pPru2HSIO = AM65X_PRU2_SHARED_BASE;
printf("PRU 2 = %x \n");
}
However, it always return fail as below. But when I use devmem2 to read, it looks good.
Also, I tried to use ti-processor-sdk-linux-rt-am65xx-evm-07_03_00_08, and execute the same program, it can work well.
I'm not sure if there any different from rt and non-rt version?
Thanks.
Eric