Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


  Search this Thread
Old 07-16-2010, 10:00 AM   #1
LQ Newbie
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
Question the same story, userspace accees error for a memory mapped control register

Hi guys,
I'm a novice c programmer that got the responsibility of writing a simple function for an embedded system(superH architecture, running linux). i have a memeory-mapped register (it's the status & control registers of a DRAM controller) which i'm interested to write to and read from. the datasheet gives me their offset address and I have the base address, which i believe, means i have their physical address in hand.

here is my program which is just one line reading this register:

BOOL LMI_SET_FREQUENCY(parse_t *pars_p,char *result)


U32 Ddiv = 0;
Ddiv = *((volatile unsigned int *)(0xfe001012); /* base address+ offset */

InitialFrequency = 30*Ddiv*5;


when i call this function, it give me UNALIGNED USERSPACE ACCESS in xxxx.c .
I don't see any executable binary file called map or mmap in my directories to use for virtual to physical address and actually i don't see any reason for using it.
could you please tell me how to approach to the solution? any comment, word which can give me the idea what to read or to do is highly appreciated

Old 07-16-2010, 11:19 PM   #2
Hidden Windshield
Registered: Jul 2010
Distribution: Fedora
Posts: 65

Rep: Reputation: 26
I'm not familiar with the superH architecture specifically, but I do know that the vast majority of architectures (embedded, desktop, or other) require that all memory access be aligned to a multiple of whatever size data you're working with. In other words, if you're going to read a 32 bit (4 byte) piece of data, you need to read it from an address that's a multiple of 4 bytes.

The address you're trying to read from, 0xfe001012, isn't a multiple of 4 bytes, hence the error. It is a multiple of 2 bytes, so I bet if you tried to read 16 bits from that location, it would work.
Old 07-21-2010, 06:49 AM   #3
LQ Newbie
Registered: Jul 2010
Posts: 2

Original Poster
Rep: Reputation: 0
i changed the address to a multiple of 4, and then used mmap()


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
memory mapped i/o and i/o mapped i/o shilpa rangappa General 1 12-14-2009 10:27 PM
Network device Memory mapped or Port mapped ?? Bignon Linux - Hardware 0 10-20-2009 08:36 AM
Can we register a userspace funtion as a callback to kernel space? duyuyang Linux - Kernel 0 12-20-2008 12:24 AM
Kernel crashes while accessing the IO mapped memory rohshall Linux - Embedded & Single-board computer 0 12-10-2008 09:52 AM
Memory Mapped file IO problems legogt Programming 0 08-01-2003 01:52 PM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration