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.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I'm confused whether you're talking about memory or cpu as you mentioned registers.. if you really mean registers then use inline asm (assuming your language supports it). Access to physical memory is not really an option under any modern OS as the virtual memory system will control what processes see.
It is possible to read physical memory but I don't think you'll be able to map which process is in which location, you'd need to take into account paging as well.
Sorry I should have said physical addresses instead of physical memory. It looks like using mmap with /dev/mem to map the registers into virtual user space may be my best option. Does this sound right?
Sorry, I'm still confused by your terminology, its a little difficult to follow when you switch between "physical addresses", "physical memory" and "registers" - you want to be able to read physical memory from user space, correct? ...
I apologize for the confusing terminology, as I said I'm new to embedded linux. My background is with embedded software on devices running lower level RTOS where virtual addressing is not a consideration. I've solved my problem (I believe) but I'll try to clarify a bit for the sake of anyone else looking for the same answer.
First, forget I ever said "Physical memory." What I am trying to do is gain read/write access to a hardware register (not a processor register) from my user-mode application. Initially I was confused how to access physical addresses when my process is only using virtual addresses. Using mmap with /dev/mem I was able to map the section of physical address space that addresses the registers into virtual addresses in my process address space. From there reading and writing was trivial.
Rather than start a new thread I'll just follow up here. I have a memory mapped IO address that I'm unable to write to from user space. I can read to it. And I can read/write it from a kernel module or from uboot. I'm just unable to write to it from my user process.
What would cause such behavior? Is there some global write protections that's set up at startup?