Find the answer to your Linux question:
Results 1 to 4 of 4
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2011
    Posts
    38

    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:
    Code:
    Memory Mapping failed. Error: 1
    Part of the code has the following:
    Code:
    volatile ulong *memory;
    
    int fd = open("/dev/mem", O_RDWR | O_SYNC);
    
    	if (fd < 0) {						
    		printf("Could not open memory.\n");
    		return(0);
    	}
    
    
    // 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);
    		close(fd);
    		return(0);
    	}
    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:
    Code:
    #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);
    		close(fd);					
    		return(0);
    	}
    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!
    Frederico

  2. #2
    Just Joined!
    Join Date
    May 2011
    Posts
    38
    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
    Just Joined!
    Join Date
    May 2011
    Posts
    38
    I have changed the address from 0x80F00000 to 0xE0C00000 and it works...

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,453
    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
  •