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 ...
- 05-26-2011 #1Just 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:
Part of the code has the following:Code:Memory Mapping failed. Error: 1
I have seen that "errno=1" means an operation not permitted but I can not see where that could happen.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 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:
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.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); }
Thanks in advance!
Frederico
- 05-27-2011 #2Just 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.
- 05-27-2011 #3Just Joined!
- Join Date
- May 2011
- Posts
- 38
I have changed the address from 0x80F00000 to 0xE0C00000 and it works...
- 05-28-2011 #4Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,975
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!


Reply With Quote