mmap fail with error 22

1,095 views
Skip to first unread message

Prasad Bc

unread,
Jun 9, 2014, 7:29:59 AM6/9/14
to inside...@googlegroups.com
Hi All,

   I need help with the mmap failure with my linux kernel version 3.6.4

   here is the following code 
    if ((fd = open ("/dev/mem", O_RDWR)) < 0)
    {
        return ((uint32_t) -1);
    }

    mem_virt_addr = mmap (NULL,
                              mem_size,
                              PROT_READ | PROT_WRITE,
                              MAP_SHARED | MAP_NORESERVE,
                              fd,
                              0);
    close (fd);

    if (mem_virt_addr == NULL)
    {
        error_msg ("memory count not be mapped (%d).", errno);
        return ((uint32_t) -1);
    }

From the above code if I specify mem_size as 1MB (1024*1024) code works fine. If I increase the size >1MB then I get error number 22 which is "EINVAL". Can any one help me on how to get rid of this error. I need a memory size of 64MB.

I have unset the .config file for CONFIG_STRICT_DEVMEM and built the kernel.

Regards,
-Prasad

Anil Kumar Pugalia

unread,
Jun 10, 2014, 6:28:32 AM6/10/14
to inside...@googlegroups.com
Hi Prasad,
    What are you trying to do, by directly mmaping such big chunk of memory?

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)

Prasad Bc said the following on Monday 09 June 2014 04:59 PM:
--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages