What I wish to do is run some sample C or C++ code that's under Mraa/examples (e.g blink-io.c or analogin_a0.c)
I found those examples in "root@eddiecam:/usr/share/mraa/examples" but I can't seem to figure out how to compile these C code to run it on the Edison.
Assuming you are building on the edison?
There are some instructions up on the MRAA site: https://github.com/intel-iot-devkit/mraa/blob/master/docs/building.md
Building MRAA depends on cmake. I downloaded it from the site: http://www.cmake.org/download/
First get the down to your Edison:
Example: get clone intel-iot-devkit/mraa · GitHub
Then : I do commands, I believe something like:
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr
Note: you more or less only do the cmake the first time you build. Later if you make simple changes you just do the make and optionally
Note: As mentioned in previous posts, you don't necessarily need to build your own copy, but can nupdate from their latest official builds. I build my own as I am testing stuff and making some fixes.
If you do build, the build directory will contain compiled versions of the test programs as well.
Hope that helps
Note to above: what I have not done yet is to build MRAA to update my windows 7 machine with update headers and libraries. Not sure what the proper way to do this is... But my guess is it would not be hard to upload the built libraries and headers and simply copy them to where the eclipse setup is looking for them...
I have not done much of this yet as I either use Arduino interface or go directly to the edison...
Actually today it got a lot easier
First configure your self to be able to install stuff from AlexT_Intel repos.
Then to do the above, you should be able to do:
opkg install git
opkg install cmake
And then most of the steps I mentioned earlier starting with:
I did this earlier today on my Intel Breakout board version as to try it out. Note: the higher speed GPIO stuff was integrated into today, so should be out very soon now with something you can simply install.
As for not knowing a lot about Linux, I fully understand. I was a complete novice about this, not that long ago. Still feel that way some times. For what it is worth, I keep my cheat sheet of notes about setting stuff up, and how to do things, in my readme.md file that is associated with my Raspberry_Pi project up on github. I should rename the project, but it was the first linux card I started with... Since then played with a few (BeagleBone Black, Odroid U2/U3, Now these...)
I've installed UbiLinux, then I updated Python, then I followed the instructions from David Hunt from a previous post, on how to install MRAA on Ubilinux/Debian and everything got compiled, built, etc etc... it all worked just nicely !!!
Then when I tried to execute one simple script within the mraa/examples/python which call the mraa module, I get the following error:
root@ubilinux:/usr/share/mraa/examples/python# python blink-io8.py
Traceback (most recent call last):
File "blink-io8.py", line 25, in <module>
ImportError: No module named mraa
here is my console output for when I compiled and installed mraa module:
-- Install configuration: ""
-- Installing: /usr/include/mraa.h
-- Installing: /usr/include/mraa.hpp
-- Installing: /usr/include/mraa
-- Installing: /usr/include/mraa/pwm.hpp
-- Installing: /usr/include/mraa/common.h
-- Installing: /usr/include/mraa/aio.h
-- Installing: /usr/include/mraa/gpio.h
-- Installing: /usr/include/mraa/uart.h
-- Installing: /usr/include/mraa/uart.hpp
-- Installing: /usr/include/mraa/common.hpp
-- Installing: /usr/include/mraa/i2c.hpp
-- Installing: /usr/include/mraa/aio.hpp
-- Installing: /usr/include/mraa/spi.h
-- Installing: /usr/include/mraa/i2c.h
-- Installing: /usr/include/mraa/pwm.h
-- Installing: /usr/include/mraa/gpio.hpp
-- Installing: /usr/include/mraa/spi.hpp
-- Installing: /usr/include/mraa/types.h
-- Installing: /usr/lib/pkgconfig/mraa.pc
-- Installing: /usr/lib/libmraa.so.0.5.2
-- Installing: /usr/lib/libmraa.so.0
-- Installing: /usr/lib/libmraa.so
-- Installing: /usr/lib/python2.7/site-packages/_mraa.so
-- Installing: /usr/lib/python2.7/site-packages/mraa.py
-- Installing: /usr/share/mraa/examples
-- Installing: /usr/share/mraa/examples/hellomraa.c
-- Installing: /usr/share/mraa/examples/python
-- Installing: /usr/share/mraa/examples/python/rgblcd.py
-- Installing: /usr/share/mraa/examples/python/cycle-pwm3.py
-- Installing: /usr/share/mraa/examples/python/blink-io8.py
-- Installing: /usr/share/mraa/examples/python/i2c_HMC5883.py
-- Installing: /usr/share/mraa/examples/python/hello_isr.py
-- Installing: /usr/share/mraa/examples/python/hello_gpio.py
-- Installing: /usr/share/mraa/examples/python/aio.py
-- Installing: /usr/share/mraa/examples/blink_onboard.c
-- Installing: /usr/share/mraa/examples/gpio_read6.c
-- Installing: /usr/share/mraa/examples/i2c_HMC5883L.c
-- Installing: /usr/share/mraa/examples/analogin_a0.c
-- Installing: /usr/share/mraa/examples/cycle-pwm3.c
-- Installing: /usr/share/mraa/examples/spi_mcp4261.c
-- Installing: /usr/share/mraa/examples/CMakeLists.txt
-- Installing: /usr/share/mraa/examples/mmap-io2.c
-- Installing: /usr/share/mraa/examples/c++
-- Installing: /usr/share/mraa/examples/c++/Pwm3-cycle.cpp
-- Installing: /usr/share/mraa/examples/c++/Spi-pot.cpp
-- Installing: /usr/share/mraa/examples/c++/CMakeLists.txt
-- Installing: /usr/share/mraa/examples/c++/AioA0.cpp
-- Installing: /usr/share/mraa/examples/c++/Blink-IO.cpp
-- Installing: /usr/share/mraa/examples/c++/I2c-compass.cpp
-- Installing: /usr/share/mraa/examples/isr_pin6.c
-- Installing: /usr/share/mraa/examples/uart_setup.c
-- Installing: /usr/share/mraa/examples/blink-io.c
In order to fix the problem, I searched google and tried 2 solutions from other users
1) I've tried installing the Python Dev tools and that didn't work either
2) I've tried creating a file named mraa.pth inside the folder usr/local/lib/python2.7/site-packages and added one line with /usr/include/mraa ... but that didn't work either.
I ask you, the awesome Gods of Linux, to share some light on my problem and stupidity !!
Thanks in advance to all of you great contributors of this community!
1) I noticed that the example for "spi_mcp4261" under
does not do anything in the sample code when I run it by >> ./spi_mcp4261
I was looking through and found that
/home/root/mraa/src/spi/spi.c has more code.
Do you know a way I could compile this spi.c code as well? Doing make and make install doesn't work.
2) Does anyone know what this code do?
1) I have not tried the example you mentioned as I don't have one of the mcp4261 devices (at least I don't think so). I have tested spi code with other devices like the Adafruit display.
the file spi.c - Is the actual code (most of it), that implements the SPI interface, the C version. The c++ version is a real simple wrapper around these functions as well.
2) The intel_edison_fab_c.c code is the actual code specific to the Edison. the main function which I believe is in mraa.c does a query to figure out which board you are running on, and then either sets up to use the functions in this file or if it is one of the Galileo boards, it hooks up with the functions associated with those boards. These board files includes both data, like what is on which pin and also contains code specific for each platform. Example to use a GPIO pin, there may be different code needed to change a pin from input to output...
All of these API files and board specific files are compiled as part of the make and are internal to the built library.