Results 1 to 2 of 2
hi all
I am new on this forum and new on linux (and french for 23 years).
I will try to write correctly but be indulgent...
so as describe in ...
- 06-16-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 1
access registers
hi all
I am new on this forum and new on linux (and french for 23 years).
I will try to write correctly but be indulgent...
so as describe in the title I have a CPU ARM and I want to access a register.
i tried with mmap but it doesn't work.
i attach my program if someone see the problem...
so when I run the program there isn't any error, all works (open, mmap ...) but I know that my program do nothing because i have ask to read something that i know and there is nothing...
so please help me
thanks
- 06-16-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,970
There are several problems with this code.
1. The data type for your base address which you are going to map is off_t not the unsigned int you use for the variable registre. Second, the value passed to mmap for the hardware address MUST be a multiple of the page size. You think you are doing with by the expression (registre & 0xFFFFF000, but there is no guarantee of that. What I usually do is pass in a base address and an offset from the address to the register in question. Than after mapping the base address to a virtual (mapped) address, I simply add the offset of the register to the virtual address (map_base).
In reality, your registre & 0xFFFFF000 should work ok. I do wonder why you are executing msync(). This is not a memory-mapped physical file, so it is possible that this is causing a problem with reading the register. Another possibility is that you haven't enabled the device that the register is associated with. I know that on ARM boards I use, there is the need to do an 8-bit I/O out operation on a specific address to enable a PC-104 daughter board, for instance.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote