[SOLVED] the same story, userspace accees error for a memory mapped control register
Linux - Embedded & Single-board computerThis 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.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
U32 Ddiv = 0;
Ddiv = *((volatile unsigned int *)(0xfe001012); /* base address+ offset */
InitialFrequency = 30*Ddiv*5;
printf("%d",Ddiv);
return(FALSE);
}
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.