Results 1 to 6 of 6
Hi all,
The problem:
I'm running an embedded Linux kernel, and I want to obtain a real memory address from user space.
After goggeling a little, I found that the ...
- 02-25-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 4
mmap() and /dev/mem
Hi all,
The problem:
I'm running an embedded Linux kernel, and I want to obtain a real memory address from user space.
After goggeling a little, I found that the only way was to use mmap to access /dev/mem.
But I never used mmap, and everything I read about it didn't help me much more.
Si, I wondered if someone could explain me how I could do in my case?
What I want to do:
I want to load a program in memory, in order to make it available from another processor, that has access to the DDR, but not to the flash memory where program is stored.
Here is the code I use:
As you can see, program_address is only a virtual address. But I need to know its real address, in order to transmit it to the other processor, that does not have a Linux, but a standalone application that I wrote by myself.Code:// Open file and get its size FILE* program = fopen(argv[3],"rb"); fseek(program, 0, SEEK_END); long program_size = ftell(program); fseek(program, 0, SEEK_SET); // Prepare memory to copy it in void* program_address = malloc(program_size+1); FILE* memory_stream = fmemopen(program_real_address, program_size + 1, "wb"); printf("Program address: 0x%x\n", (int)program_address); // Do the copy int temp; while ((temp = getc(program)) != EOF) putc(temp, memory_stream); fclose(memory_stream); fclose(program);
if anyone could help me, just telling how I could use mmap in my case?
Thank you.
- 02-25-2010 #2Linux 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,961
I think you should move this post to "The Linux Kernel" forum. That's where kernel boffins tend to gather.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 02-25-2010 #3Just Joined!
- Join Date
- Feb 2010
- Posts
- 4
Thank you, i'll do it. Is there a way to move this thread without creating a new one?
- 02-25-2010 #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,961
I know moderators can, but I think the originator of a thread can also move it. Look at the "Thread Tools" tab at the top of the thread.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 02-25-2010 #5Just Joined!
- Join Date
- Feb 2010
- Posts
- 4
I've already looked there, and there is no option for that.
That's not a problem, I'll create a new one in the kernel section.
- 02-25-2010 #6Linux 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,961
Then close this thread first since duplicate postings are not allowed.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
