element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Raspberry Pi and /dev/mem access
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 30 replies
  • Subscribers 680 subscribers
  • Views 4851 views
  • Users 0 members are here
  • raspberry
  • pi
  • raspberry_pi
Related

Raspberry Pi and /dev/mem access

Former Member
Former Member over 11 years ago

Question(s) regarding Raspberry Pi and GPIO.

 

Been working with RPi.GPIO for several weeks trying to get the following script to run: (from Third Eye Visions, using the GPIO Python library that they suggest to use)

 

import RPi.GPIO as GPIO

GPIO.setmode (GPIO,BOARD)

GPIO.setup (7, GPIO.OUT)

GPIO.output (7, True)

 

When running from the Lynux command line, an error is posted “no access to /dev/mem.  Try running as root”

 

I go to command line and run sudo/home/pi/file name and another error is returned “command not found”.

 

Doing a brief search on line, I don’t seem to be the only person having this problem.  I simply don’t understand the solutions that are presented and it is not clear that the solutions solve the problem.

 

When using RPi.GPIO 0.5.4 revision of the Python Package Index, isn’t this problem resolved?

 

I am using the Debian Wheezy Rasbiabn 2012.12.img 192, Debian GNU/Linux 7 raspberry pi tty1

 

I have Python 2.7, 3.2 and 3 on the SD and Python IDE.

 

I want to program the raspberry pi using GPIO functions with Python not C or any other script.

 

Why won’t the current upgrade of Raspberry Pi from Third Eye Visions work with the above script?  This is not the only GPIO program (from other sources) that I have tried and receive the same result.  I can control the pins in the command line of Linux from the keyboard using set mode, etc and read the status of the pins using readall.

 

I have used Pygame with this distribution of Debian and it works perfectly.

 

Can anyone supply a simple fix for this problem?  Can it be solved with a new SD loaded with a raspberry pi compatible program set-up with Python?  If so. where can I find one.? Or can I simply add one or two lines to the script that will allow access into

/dev/mem and then reinstate root privileges to /dev/mem at the point of exit from the program?

 

Help!

morgsterdad

  • Sign in to reply
  • Cancel
Parents
  • rew
    0 rew over 11 years ago

    Bill,

    A Linux system has some protections: "normal" users cannot access things that could damage possible other users on the system or the system itself. A command "delete-all-files" would also delete the operating system, but protections are in place that should prevent this.

     

    Now, when you try to access the GPIO pins, the way that "import RPi.GPIO as GPIO" works is that it accesses  the hardware of the CPU directly. This is something that the operating system cannot allow to normal users. So... if you're logged in as "pi" the system will not allow you access to the hardware in "/dev/mem". The system tells the program "permission denied", the program catches this error and prints a message that explains what you can do (run as root).

     

    Now, when you DO run it as root, you seem to be getting a different problem. somehow, a file is not being found.

     

    Again a simple problem if you know how to solve it. But things like "switch to a different operating system" will not automagically solve these problems. All Linux operation systems will protect the hardware by preventing access to "/dev/mem" for normal users. All Linux systems will report an error if you mistype a command.

     

    If you ask us to spot-the-typo in your commands and then make typo's in the post about it, that makes things a lot harder to help you in "one go".

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • rew
    0 rew over 11 years ago

    Bill,

    A Linux system has some protections: "normal" users cannot access things that could damage possible other users on the system or the system itself. A command "delete-all-files" would also delete the operating system, but protections are in place that should prevent this.

     

    Now, when you try to access the GPIO pins, the way that "import RPi.GPIO as GPIO" works is that it accesses  the hardware of the CPU directly. This is something that the operating system cannot allow to normal users. So... if you're logged in as "pi" the system will not allow you access to the hardware in "/dev/mem". The system tells the program "permission denied", the program catches this error and prints a message that explains what you can do (run as root).

     

    Now, when you DO run it as root, you seem to be getting a different problem. somehow, a file is not being found.

     

    Again a simple problem if you know how to solve it. But things like "switch to a different operating system" will not automagically solve these problems. All Linux operation systems will protect the hardware by preventing access to "/dev/mem" for normal users. All Linux systems will report an error if you mistype a command.

     

    If you ask us to spot-the-typo in your commands and then make typo's in the post about it, that makes things a lot harder to help you in "one go".

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube