1 2 Previous Next 16 Replies Latest reply on Nov 23, 2014 10:33 AM by HoverSky

    Mraa and Edison

    danny7yoo

      Hi, I was wondering if someone could explain to me how to build Mraa (compiling)

       

      I tried

       

      mkdir build

      cd build

      cmake ..

      make

       

      but no luck

       

      and I also tried to compile blink-io.c but no luck either

       

      root@eddiecam:/usr/share/mraa/examples# gcc -g blink-io.c -o blink

      /tmp/ccKYoc7t.o: In function `main':

      /usr/share/mraa/examples/blink-io.c:59: undefined reference to `mraa_init'

      /usr/share/mraa/examples/blink-io.c:60: undefined reference to `mraa_get_version'

      /usr/share/mraa/examples/blink-io.c:64: undefined reference to `mraa_gpio_init'

      /usr/share/mraa/examples/blink-io.c:72: undefined reference to `mraa_gpio_dir'

      /usr/share/mraa/examples/blink-io.c:74: undefined reference to `mraa_result_print'

      /usr/share/mraa/examples/blink-io.c:80: undefined reference to `mraa_gpio_write'

      /usr/share/mraa/examples/blink-io.c:82: undefined reference to `mraa_result_print'

      /usr/share/mraa/examples/blink-io.c:89: undefined reference to `mraa_gpio_write'

      /usr/share/mraa/examples/blink-io.c:91: undefined reference to `mraa_result_print'

      /usr/share/mraa/examples/blink-io.c:99: undefined reference to `mraa_gpio_close'

      /usr/share/mraa/examples/blink-io.c:101: undefined reference to `mraa_result_print'

      collect2: error: ld returned 1 exit status

       

       

      Thanks in advance,

      Danny

        • 1. Re: Mraa and Edison
          shb

          it depends,

          what happend during compiling? any errors?

          did you installed it?

          make install ?

           

          bye

          • 2. Re: Mraa and Edison
            mhahn

            why would you want to build for Edison at all? you could just opkg install the ready compiled package from intelgalactic?

            • 3. Re: Mraa and Edison
              danny7yoo

              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.

              • 4. Re: Mraa and Edison
                danny7yoo

                I did follow steps for installing mraa

                 

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

                opkg update

                opkg install libmraa0

                 

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

                 

                but what to do next to run example c, c++ codes?

                • 5. Re: Mraa and Edison
                  KurtE

                  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/

                  (linux i386)

                   

                  First get the down to your Edison:

                  Example: get clone intel-iot-devkit/mraa · GitHub

                   

                  Then : I do commands, I believe something like:

                    cd ~/mraa

                    mkdir build

                    cd build

                    cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr

                    make

                    make install

                   

                  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

                  make install

                   

                  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

                  Kurt

                  • 6. Re: Mraa and Edison
                    KurtE

                    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...

                    • 7. Re: Mraa and Edison
                      danny7yoo

                      Hi Kurt,

                       

                      I downloaded cmake linux i386 and I extracted at home/ but how do I install cmake?

                       

                      I am very knew at linux.... sorry

                       

                      Danny

                      • 8. Re: Mraa and Edison
                        KurtE

                        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:

                        git ...

                         

                        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...)

                        • 9. Re: Mraa and Edison
                          Orto

                          hi guys,

                          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>

                              import mraa

                          ImportError: No module named mraa

                          root@ubilinux:/usr/share/mraa/examples/python#


                          ========================================================================

                          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/javascript

                          -- Installing: /usr/share/mraa/examples/javascript/GPIO_DigitalRead.js

                          -- Installing: /usr/share/mraa/examples/javascript/AioA0.js

                          -- Installing: /usr/share/mraa/examples/javascript/Blink-IO.js

                          -- Installing: /usr/share/mraa/examples/javascript/rgblcd.js

                          -- Installing: /usr/share/mraa/examples/javascript/GPIO_DigitalWrite.js

                          -- 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

                          root@ubilinux:/mraa/mraa/build#

                           

                          ==============================================================

                          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!

                          Cheers

                          Flavio

                          • 10. Re: Mraa and Edison
                            danny7yoo

                            Thanks Kurt! It worked.

                             

                            Just one question though.

                            If I modify a source code (e.g. gpio.c) do i run just

                            >> make?

                             

                            or

                            >> make

                            >> make install?

                             

                            Thanks,

                            Danny

                            • 11. Re: Mraa and Edison
                              KurtE

                              I always do it as a two step process

                              make

                              make install

                               

                              You can probably just do make install  and it will probably do everything, but old habits...

                              • 12. Re: Mraa and Edison
                                danny7yoo

                                Hey Kurt,

                                 

                                1) I noticed that the example for "spi_mcp4261" under

                                /home/root/mraa/build/examples

                                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?

                                /home/root/mraa/src/intel_edison_fab_c.c

                                 

                                Thanks,

                                Danny

                                • 13. Re: Mraa and Edison
                                  KurtE

                                  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.

                                   

                                  Kurt

                                  • 14. Re: Mraa and Edison
                                    danny7yoo

                                    Yes, I guessed that spi.c is the main code. However, i'm just stuck as I am not sure how I could compile that source code.

                                     

                                    after cmake and make, make install,

                                    I only see mraa/build/examples/

                                    not the files from mraa/src (e.g. mraa/src/spi/spi.c)

                                     

                                    -Danny

                                    1 2 Previous Next