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?
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?
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
There is some interesting comments about harware in this document.
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
A little digging and this table shows that the mraa number and the GPIO number (and then the Arduino) are not the same.
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
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
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
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
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
There's some tips and code in the book Jason mentioned, things like interrupts, pwm and memory mapped GPIO for high speed pulses