Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Memory Mapping failed. Error: 1

    Hello everyone!
    So, I was working with Ubuntu 9.10 and I wrote a C program which was working just fine. Then, I have installed Ubuntu 10.10 and tried to run this same program again. However, I get the following error:
    Memory Mapping failed. Error: 1
    Part of the code has the following:
    volatile ulong *memory;
    int fd = open("/dev/mem", O_RDWR | O_SYNC);
    	if (fd < 0) {						
    		printf("Could not open memory.\n");
    // Memory address to save data
    	ulong address2;
    	address2 = 0x80F00000;	
    // Memory access
    	memory = (ulong*) mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (address2 & 0xFFFF0000));
    	if (memory == MAP_FAILED) {
    		printf("Memory Mapping failed. Error: %d.\n", errno);
    I have seen that "errno=1" means an operation not permitted but I can not see where that could happen.

    I have reduced the 0x10000 to 0x1000, changed the name "memory" to "memoria" and changed "(address2 & 0xFFFF0000)" to "address2". However, the same error persists.

    I have also something similar in this same program and it is working fine:
    #define PIN_CONF	0x48000000
    volatile ulong *pinconf;
    // Pad configuration							
    pinconf = (ulong*) mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, PIN_CONF);  //0x10000 are the 4KB adressed to the mem.
    	if (pinconf == MAP_FAILED) {
    		printf("Pinconf Mapping failed. Error: %d.\n", errno);
    Does anyone have an idea what the problem could be? I do not know if there would be any significant change between Ubuntu 9.10 and 10.10 that could be generating me this problem.

    Thanks in advance!

  2. #2
    Apparently, this new version of Linux reserves some memory addresses which the older one did not. So, if I find another memory address which has not been used, it might work.
    However, it is weird that I can not access a large range of memory addresses which I could access with the older Linux Version.
    Last edited by freddyglima; 05-27-2011 at 08:34 AM.

  3. #3
    I have changed the address from 0x80F00000 to 0xE0C00000 and it works...

  4. $spacer_open
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    One thing you have to remember is that you have to map memory at page boundaries. Each page is 4096 (4K) bytes.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts