Latest LQ Deal: Latest LQ Deals
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 05-20-2018, 03:34 PM   #1
Registered: Apr 2018
Posts: 53

Rep: Reputation: Disabled
memory mapping using /dev/mem versus /dev/gpiomem ?

Per doc /dev/mem usage requires "root" "privileges.
Also per doc /dev/gpiomem no "root privileges " are necessary since "Linux will take care of privileges".
I am not sure my complier is smart enough to stop me from opening the /dev/mem if my app has no root privileges. My app does not fully run so at this point I do not know that.

For now I can open both /dev/mem and /dev/gpiomem.
Since it appears that I can use both , therefore my question to the forum is
which /dev is more appropriate to use to access RPi hardware.
Old 05-20-2018, 05:13 PM   #2
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043

It is your program which decides to use which /dev/xxx. There is no automatic choice. Unless you use some development library or framework and have not told us. Libraries often offer functions which encapsulate access to /dev/xxx. So you don't see which device is used.

IIRC Python offers a library with functions to read/write GPIO. It doesn't tell you, but if /dev/gpiomem is available it uses /dev/gpiomem. If it is not available it reverts to /dev/mem and you need to run the program with root privileges.

Not 100%, I access GPIO with Tcl.




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
[SOLVED] Stupidly ran "cat /dev/urandom > /dev/mem", worried I broke firmware crosstalk Linux - Hardware 2 10-25-2010 06:27 PM
What would happen if I where to cat /dev/mem > /dev/null Joey.Dale Linux - General 11 07-26-2009 01:46 PM
[SOLVED] wiping HDD using /dev/urandom versus /dev/zero, a theoretical question H_TeXMeX_H Linux - General 6 06-29-2009 07:55 AM
using flash drive changes device /dev/sr0 to /dev/sr1 for mapping to /dev/pktcdvd/0? lugoteehalt Linux - Software 3 10-24-2007 11:27 AM
Startx Permission problems on /dev/null and /dev/mem on freshly compiled Eric_Cartman Linux - Kernel 2 09-09-2007 02:42 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:20 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
Open Source Consulting | Domain Registration