element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • 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
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Forum Accessing hardware on the Edison?
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 20 replies
  • Subscribers 5 subscribers
  • Views 1989 views
  • Users 0 members are here
Related

Accessing hardware on the Edison?

Workshopshed
Workshopshed over 8 years ago

I'm wondering about accessing the GPIO of the Edison in high-level languages such as Python or Node.

 

So far I've found MRAA but wondered if there are other options?

 

https://github.com/intel-iot-devkit/mraa

  • Sign in to reply
  • Cancel

Top Replies

  • jasonwier92
    jasonwier92 over 8 years ago +3
    MRAA should be the way to go. Looks like they have Python interface. Check out this link: Getting Started With Intel Edison - Python Programming - All I cannot wait to play with Python and Node on the…
  • Former Member
    Former Member over 8 years ago +2
    If you can access the gpio through the standard linux filesystem method it should be possible to write out the bash commands in Python using os.popen e.g. import os p = os.popen("echo 1 > /sys/class/gpio…
  • mcb1
    mcb1 over 8 years ago in reply to konstantinoskonstas +2
    I'm learning as I go. I've always said I'm more a hardware guy that pokes and prods at software. I was hoping to get a head start on you guys/gals ...
  • mcb1
    mcb1 over 8 years ago in reply to mcb1

    It seems there is no default user with the Yocto image.

    root@MyEdison:/# cat /etc/passwd-
    root::0:0:root:/home/root:/bin/sh
    daemon:*:1:1:daemon:/usr/sbin:/bin/sh
    bin:*:2:2:bin:/bin:/bin/sh
    sys:*:3:3:sys:/dev:/bin/sh
    sync:*:4:65534:sync:/bin:/bin/sync
    games:*:5:60:games:/usr/games:/bin/sh
    man:*:6:12:man:/var/cache/man:/bin/sh
    lp:*:7:7:lp:/var/spool/lpd:/bin/sh
    mail:*:8:8:mail:/var/mail:/bin/sh
    news:*:9:9:news:/var/spool/news:/bin/sh
    uucp:*:10:10:uucp:/var/spool/uucp:/bin/sh
    proxy:*:13:13:proxy:/bin:/bin/sh
    www-data:*:33:33:www-data:/var/www:/bin/sh
    backup:*:34:34:backup:/var/backups:/bin/sh
    list:*:38:38:Mailing List Manager:/var/list:/bin/sh
    irc:*:39:39:ircd:/var/run/ircd:/bin/sh
    gnats:*:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
    nobody:*:65534:65534:nobody:/nonexistent:/bin/sh
    messagebus:!:999:998::/var/lib/dbus:/bin/false
    systemd-journal-gateway:!:998:995::/home/systemd-journal-gateway:/bin/sh
    systemd-timesync:!:997:994::/home/systemd-timesync:/bin/sh
    sshd:!:996:993::/var/run/sshd:/bin/false
    rpc:!:995:992::/:/bin/false
    rpcuser:!:994:991::/var/lib/nfs:/bin/false
    pulse:!:993:1000::/var/run/pulse:/bin/false
    root@MyEdison:/#

     

    I see that the Tutorial at Sparkfun has them installing a Debian (Ubilinux) image.

    https://learn.sparkfun.com/tutorials/loading-debian-ubilinux-on-the-edison#log-into-ubilinux

     

    The link to the image file at Emutex still works.

    https://emutex.com/products/ubilinux

     

    mark

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to mcb1

    There is some interesting comments about harware in this document.

    mraa: Intel Edison

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to mcb1

    So a little more playing

     

    It seems that under /usr/bin there is mraa-gpio which is happy to run from the command line.

    The options are.

    root@edison:/usr/bin# mraa-gpio
    Invalid command, options are:
    list              List pins
    set pin level     Set pin to level (0/1)
    setraw pin level  Set pin to level (0/1) via mmap (if available)
    get pin           Get pin level
    getraw pin        Get pin level via mmap (if available)
    monitor pin       Monitor pin level changes
    version           Get mraa version and board name
    root@edison:/usr/bin#

     

    mraa-gpio version gives you

    Version v1.0.0 on Intel Edison

     

    while list

    root@edison:/usr/bin# mraa-gpio list

    00       J17-1: GPIO PWM
    01       J17-2:
    02       J17-3:
    03       J17-4:
    04       J17-5: GPIO
    05       J17-6:
    06       J17-7: GPIO I2C
    07       J17-8: GPIO I2C
    08       J17-9: GPIO I2C
    09      J17-10: GPIO SPI
    10      J17-11: GPIO SPI
    11      J17-12: GPIO SPI
    12      J17-13:
    13      J17-14: GPIO
    14       J18-1: GPIO PWM
    15       J18-2: GPIO
    16       J18-3:
    17       J18-4:
    18       J18-5:
    19       J18-6: GPIO I2C
    20       J18-7: GPIO PWM
    21       J18-8: GPIO PWM
    22       J18-9:
    23      J18-10: GPIO SPI
    24      J18-11: GPIO SPI
    25      J18-12: GPIO
    26      J18-13: GPIO UART
    27      J18-14:
    28       J19-1:
    29       J19-2:
    30       J19-3:
    31       J19-4: GPIO
    32       J19-5: GPIO
    33       J19-6: GPIO
    34       J19-7:
    35       J19-8: GPIO UART
    36       J19-9: GPIO
    37      J19-10: GPIO
    38      J19-11: GPIO
    39      J19-12: GPIO
    40      J19-13: GPIO
    41      J19-14: GPIO
    42       J20-1:
    43       J20-2:
    44       J20-3:
    45       J20-4: GPIO
    46       J20-5: GPIO
    47       J20-6: GPIO
    48       J20-7: GPIO
    49       J20-8: GPIO
    50       J20-9: GPIO
    51      J20-10: GPIO
    52      J20-11: GPIO
    53      J20-12: GPIO
    54      J20-13: GPIO
    55      J20-14: GPIO

     

     

    I tried setting GPIO 48 (pin 7 on the Arduino shield) and it wouldn't work.

     

    If I used the echo command it worked, and using mraa-gpio get 48, it gave the current state (0 or 1) in response to the echo commands.

     

    So I'm a little puzzled ... more digging is required.

     

     

     

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to mcb1

    A little digging and this table shows that the mraa number and the GPIO number (and then the Arduino) are not the same.

    mraa: Intel Edison

     

    It seems mraa 33 is GPIO 48 and it works BUT.

    You can use either the echo or the mraa-gpio to set the pin or change it,

    BUT if you read the pin with get or getraw, you get a write error.

     

    root@edison:/sys/class/gpio/gpio48# /usr/bin/mraa-gpio getraw 33
    Pin 33 = 0
    root@edison:/sys/class/gpio/gpio48# echo 1 > value
    -sh: echo: write error: Operation not permitted
    root@edison:/sys/class/gpio/gpio48# /usr/bin/mraa-gpio set 33 1
    root@edison:/sys/class/gpio/gpio48# echo 0 > value
    root@edison:/sys/class/gpio/gpio48# /usr/bin/mraa-gpio getraw 33
    Pin 33 = 0
    root@edison:/sys/class/gpio/gpio48# echo 0 > value
    -sh: echo: write error: Operation not permitted
    root@edison:/sys/class/gpio/gpio48#

     

    Seems strange that a read (get) will lock out changing it but you can set it with one method and change it with the other ???

     

     

    mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago in reply to mcb1

    I'm not a big fan of running everything as root. But I also appreciate that setting up a user with the right access levels is a non-trivial task

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago

    I just spotted UPM, runs on top of MRAA and provides a further abstraction so you can programme with LEDs and Light Sensors rather than working at the Pin level

     

    https://github.com/intel-iot-devkit/upm

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • konstantinoskonstas
    konstantinoskonstas over 8 years ago in reply to Workshopshed

    Workshopshedmcb1

    You are touching upon some very interesting topics.

    Thanks a lot.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to konstantinoskonstas

    I'm learning as I go.  image

     

    I've always said I'm more a hardware guy that pokes and prods at software.

     

    I was hoping to get a head start on you guys/gals ...image

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • mcb1
    mcb1 over 8 years ago in reply to Workshopshed

    Following our conversation yesterday ...

    I did some searching and it turns out that the version of mraa-gpio is not the latest.

     

    From here https://github.com/intel-iot-devkit/mraa

     

    https://github.com/intel-iot-devkit/mraa#installing-on-intel-32bit-yocto-based-opkg-imageInstalling on Intel 32bit Yocto based opkg image

    See the section below on compiling or use our repository to install on a glibc based yocto poky image that supports opkg.

    Adding this repository is as simple as and you'll have the latest stable tagged build of mraa installed!

    echo "src mraa-upm http://iotdk.intel.com/repos/3.5/intelgalactic-dev/opkg/i586" > /etc/opkg/mraa-upm.conf

    opkg update

    opkg install mraa

     

    it took a few minutes

    root@Edison_2:~# echo "src mraa-upm http://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586" > /etc/opkg/mraa-upm.conf
    root@Edison_2:~# opkg update
    Downloading http://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586//Packages.
    Updated list of available packages in /var/lib/opkg/iotkit.
    Downloading http://iotdk.intel.com/repos/3.5/iotdk/edison/all/Packages.
    Updated list of available packages in /var/lib/opkg/iotdk-all.
    Downloading http://iotdk.intel.com/repos/3.5/iotdk/edison/core2-32/Packages.
    Updated list of available packages in /var/lib/opkg/iotdk-core2-32.
    Downloading http://iotdk.intel.com/repos/3.5/iotdk/edison/edison/Packages.
    Updated list of available packages in /var/lib/opkg/iotdk-edison.
    Downloading http://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586/Packages.
    Updated list of available packages in /var/lib/opkg/mraa-upm.
    root@Edison_2:~# opkg install mraa
    Upgrading mraa from 1.0.0-r0 to 1.5.1 on root.
    Downloading http://iotdk.intel.com/repos/3.5/intelgalactic/opkg/i586/mraa_1.5.1_i586.ipk.
    Removing package mraa-dev from root...
    Removing package mraa-doc from root...
    Removing obsolete file /usr/lib/libmraa.so.1.0.0.
    Configuring mraa.
    root@Edison_2:~# /usr/bin/mraa-gpio version
    Version v1.5.1 on Intel Edison
    root@Edison_2:~#

     

     

    and now I have version 1.5.1

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago

    There's some tips and code in the book Jason mentioned, things like interrupts, pwm and memory mapped GPIO for high speed pulses

     

    Exploring Edison by Harry Fairhead

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
<
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