This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM6548: Different mmap result between rt and non-rt linux version

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

  • Hi Eric,

    The TI SDK uses 64K page size for regular Linux kernel and 4K page size for RT-Linux kernel. Can you confirm if you are customizing the page sizes on your build (I think not)?

    Your error code is -EINVAL, and one of the failure reasons for it is an issue with addr, length or offset field (e.g., they are too large, or not aligned on a page boundary). Your mmap arguments use 4K address and size and these match the RT Kernel's page size, but not the regular Linux 64K page size.

    Please try either by using 64K page size aligned address and size (should pass on both), or modify the regular Linux kernel to use 4K page size.

    regards

    Suman

    NOTE: /dev/mem usage is primarily meant for debug/development only, you should not be relying on this in production systems. I hope you understand the implications of /dev/mem.