Do not pass MAP_FIXED to mmap() to avoid EINVAL
devmem sets the flag MAP_FIXED on calls to mmap(). MAP_FIXED is defined
as "Don't interpret addr as a hint: place the mapping at exactly that
address." At the same time, devmem passes 0 for addr basically asking to
map the requested page at virtual address 0 which is doomed to failure.
You cannot map things at VA 0 on ARM because that's where the interrupt
vector is located (citation needed). The kernel would return EINVAL (at
least on ARM).
Interestingly, it works on our MIPS platform because you actually can
map things at address 0. See below.
110120914169# cat /proc/24232/maps
00000000-00002000 rw-s 00000000 00:05 1026 /dev/mem
1 file changed