8 Replies Latest reply on Dec 13, 2014 9:04 AM by orphanping

    Intel IoT Eclipse C++ Build and Run Problem on Edison

    ihacivelioglu

      I can build and run Eclipse C example projects on my edison arduino board as described in the below link. The example in the guideline builds and runs the code in "Debug" mode. So the code only keeps on working on edison while eclipse is running. When I exit from eclipse, the code stops working on edison at the same time.

       

      As a solution I tried to build the projects in "Release" mode. But it's impossible to build any project successfully in this mode. Each time I get some building and making errors. Is there any guideline that explains configuration details to build the projects in Release mode? Or any alternative solution to run the projects independent from eclipse?

       

      Running a Sample Application

        • 1. Re: Intel IoT (Edison) Eclipse C++ Build Error in Release Mode
          CMata_Intel

          Hi ihacivelioglu

           

          I think you could get more information and appropriate help about this in the XDK forums. Even though, have you tried to run the code in background using the terminal console? You could save the code in a directory of your Edison and run the code in there.

           

          Regards;

          CMata

          • 2. Re: Intel IoT (Edison) Eclipse C++ Build Error in Release Mode
            mhahn

            Just run the binary directly on the board. Either in a terminal within Eclipse as described on https://software.intel.com/en-us/blogs/2014/09/23/intel-iot-devkit-remote-access-through-ide (you would have to start as "nohup <sw>&" if you want to close Eclipse) or directly from a terminal

             

            @CMata_Intel I guess you wanted to refer to Internet of Things rather than to XDK forum?

            • 3. Re: Intel IoT (Edison) Eclipse C++ Build Error in Release Mode
              ihacivelioglu

              Could you pls give me some more detailed information to overcome my difficulty? I read all the forums that you refered (XDK and IoT) but it is impossible to find any satisfying answer. I know that the codes run on edison with a remote connection. During Run process the compiled codes transfer into /tmp folder on Edison. But without eclipse how should I use gcc or similar command on edison?  If i try to use "gcc filename" I get lots of error each time.  Regards.

              • 4. Re: Intel IoT (Edison) Eclipse C++ Build Error in Release Mode
                mhahn

                That sounds different to me than your initial question.

                You understood you were asking on how to run binaries generated by Eclipse outside of it.

                That's what I answered.

                Now you seem to ask how to compile on the target. Could you please clarify what you are up for?

                • 5. Re: Intel IoT (Edison) Eclipse C++ Build Error in Release Mode
                  KurtE

                  I use gcc all of the time directly on the Edison.  I use PuTTY on a PC to create a terminal window, I use WinSCP to transfer files from my machine to the Edison.  Alternatively I also use the git commands to download stuff from place like github.com.

                   

                  Note:  many of my makefiles get sort-of convoluted as I run them on several different platforms, but as an example here is one that I have been playing with this week for testing out a Ping sensor using MRAA.

                   

                  In a directory I have the source file, in this case testMraaPing.cpp, which has:  Warning, this is a test program that started out for a different device and I just hack on it enough to try out MRAA with a ping sensor.

                   

                  Example Source file:

                  #include <iostream>
                  #include "stdio.h"
                  #include "unistd.h"
                  #include <time.h>
                  #include <pthread.h>
                  
                  
                  //=========================================================================
                  //#include "fast_gpio.h"
                  #include <time.h>
                  #include "mraa.h"
                  #include <string>
                  #include "memory.h"
                  
                  
                  mraa_gpio_context gpioDBG;
                  
                  
                  using namespace std;
                  
                  
                  static float cpufreq = 0;
                  static uint64_t tsc_init = 0;
                  static float clocks_per_ns = 0;
                  
                  
                  unsigned long micros2(void)
                  {
                    struct timespec t;
                    t.tv_sec = t.tv_nsec = 0;
                    clock_gettime(CLOCK_REALTIME, &t);
                    return (unsigned long)(t.tv_sec) * 1000000L + t.tv_nsec / 1000L;
                  
                  
                  }
                  
                  
                  //=========================================================================
                  using namespace std;
                  
                  
                  #define HIGH 1
                  #define LOW  0
                  #define STARTDELAY 2
                  #define GPIO_INDEX 2
                  
                  
                  unsigned long time_s;
                  unsigned long time_e;
                  
                  
                  __syscall_slong_t echotime;
                  
                  
                  unsigned long ulDRStart, ulDeltaDr;
                  unsigned long ulDeltaSum = 0;
                  unsigned long ulCnt = 0;
                  unsigned long DoPing(  mraa_gpio_context gpio) {
                      mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
                      mraa_gpio_write(gpioDBG, HIGH);
                      mraa_gpio_write(gpio, HIGH);
                      usleep(STARTDELAY);
                      mraa_gpio_write(gpio, LOW);
                      mraa_gpio_write(gpioDBG, LOW);
                      
                      ulDRStart = micros2();
                      mraa_gpio_dir(gpio, MRAA_GPIO_IN);
                      ulDeltaDr = micros2() - ulDRStart;
                      
                      while (mraa_gpio_read(gpio) == LOW)
                          ; //pthread_yield();
                      time_s = micros2();
                      mraa_gpio_write(gpioDBG, HIGH);
                  
                      while (mraa_gpio_read(gpio) == HIGH)
                          ; //pthread_yield();
                      time_e = micros2();
                      mraa_gpio_write(gpioDBG, LOW);
                  
                      ulDeltaSum += ulDeltaDr;
                      ulCnt++;
                      cout << "dt dir: " << ulDeltaDr << "(" << (ulDeltaSum/ulCnt) <<" ): ";
                      
                      return time_e - time_s;
                  }
                  
                  int main(int argc, char **argv)
                  {
                    mraa_result_t rtv = mraa_init();
                    if (rtv != MRAA_SUCCESS && rtv != MRAA_ERROR_PLATFORM_ALREADY_INITIALISED)
                    {
                      cout << "MRAA Init Failed,Return Value is ";
                      cout << rtv << endl;
                      return 0;
                    }
                    fprintf(stdout, "MRAA Version: %s\nStarting Read\n",mraa_get_version());
                  
                    mraa_gpio_context gpio;
                    gpio = mraa_gpio_init(GPIO_INDEX);
                    gpioDBG = mraa_gpio_init(3);
                    if (gpio == NULL)
                    {
                      cout << "Init GPIO Out Failed" << endl;
                      return 0;
                    }
                  
                    mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
                    mraa_gpio_dir(gpioDBG, MRAA_GPIO_OUT);
                    mraa_gpio_use_mmaped(gpio, true);
                    mraa_gpio_use_mmaped(gpioDBG, true);
                    bool finishcycle = false;
                  
                    
                    usleep(1000000);  // give time for the ping to settle...
                    
                    for (;;)
                    {
                      echotime = DoPing(gpio);
                      
                      cout << echotime << endl;
                      usleep(500000);
                    }
                  
                    mraa_gpio_close(gpio);
                  
                  
                    return 0;
                  }
                  
                  

                   

                  example: makefile

                  #~~~~~~~~~~~~~~~~~~~~ Output File Name ~~~~~~~~~~~~~~~~~~~~
                  MAIN_OUT = TestMraaPing
                  
                  #~~~~~~~~~~~~~~~~~~~~ Source Files ~~~~~~~~~~~~~~~~~~~~
                  SOURCES = \
                          TestMraaPing.cpp 
                  
                  MAIN_OBJS:= $(subst .cpp,.o,$(SOURCES))
                  
                  MAIN_DEPS:= $(subst .cpp,.d,$(SOURCES))
                  
                  #~~~~~~~~~~~~~~~~~~~~ Include Directories ~~~~~~~~~~~~~~~~~~~~
                  INCLUDE_DIRS = -I. 
                  #~~~~~~~~~~~~~~~~~~~~ Library Directories ~~~~~~~~~~~~~~~~~~~~
                  LIBRARY_DIRS = -L/usr/lib/arm-linux-gnueabihf -L../library 
                  
                  #~~~~~~~~~~~~~~~~~~~~ Compiler Options ~~~~~~~~~~~~~~~~~~~~
                  COMPILE_OPTS = -pedantic -g -O2 -fno-rtti
                  
                  #~~~~~~~~~~~~~~~~~~~~ Linker Options ~~~~~~~~~~~~~~~~~~~~
                  LDFLAGS = $(LIBRARY_DIRS) -lpthread -lmraa
                  
                  #~~~~~~~~~~~~~~~~~~~~ Toolchain Prefix ~~~~~~~~~~~~~~~~~~~~
                  #Edison hard coded OSTYPE
                  TCHAIN_PREFIX=i586-poky-linux-
                  
                  CXX = $(TCHAIN_PREFIX)g++
                  CXXFLAGS = $(COMPILE_OPTS) $(INCLUDE_DIRS)
                  
                  #~~~~~~~~~~~~~~~~~~~~ all ~~~~~~~~~~~~~~~~~~~~
                  all: begin gccversion build end
                  
                  #~~~~~~~~~~~~~~~~~~~~ build ~~~~~~~~~~~~~~~~~~~~
                  build: $(MAIN_OUT)
                  
                  $(MAIN_OUT): $(MAIN_OBJS) ../library/libArduinoPort.a
                      $(CXX) $(CXXFLAGS) $(MAIN_OBJS) -o $(MAIN_OUT) $(LDFLAGS)
                  
                  MSG_BEGIN = -------- begin --------
                  MSG_END = --------  end  --------
                  
                  #~~~~~~~~~~~~~~~~~~~~ Eye candy ~~~~~~~~~~~~~~~~~~~~
                  begin:
                      @echo
                      @echo $(MSG_BEGIN)
                  
                  end:
                      @echo $(MSG_END)
                      @echo
                  
                  gccversion:
                      @$(CC) --version
                  
                  #~~~~~~~~~~~~~~~~~~~~ clean ~~~~~~~~~~~~~~~~~~~~
                  clean: begin clean_list end
                  
                  clean_list:
                      -rm $(MAIN_OBJS)
                      -rm $(MAIN_OUT)
                      -rm $(MAIN_DEPS)
                  
                  #~~~~~~~~~~~~~~~~~~~~ backup ~~~~~~~~~~~~~~~~~~~~
                  backup: clean
                      tar cJvf ../$(MAIN_OUT)_`date +"%Y-%m-%d_%H%M"`.tar.xz *
                  
                  #~~~~~~~~~~~~~~~~~~~~ Dependency Generation
                  include $(subst .cpp,.d,$(SOURCES))
                  
                  %.d: %.cpp
                      $(CC) -M $(CXXFLAGS) $< > $@.$$$$; \
                      sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@;  \
                      rm -f $@.$$$$
                  
                  

                   

                  Again sorry that these files are a lot more complex than what is needed, But my makefiles have changed/convoluted over time.  I have them setup to do some dependency checking, builds...  Also most of mine have stuff in them that detect which platform it is running on and change some of the settings, like where the compiler is, or what include directories to use...

                   

                  Again sorry if this is not the type of thing you are looking for.

                   

                  Kurt

                  • 6. Re: Intel IoT (Edison) Eclipse C++ Build Error in Release Mode
                    ihacivelioglu

                    I have two main issues which are related to eachother.

                    1st one: I can run sample codes as the same way that explained in the guideline but the codes run only while eclipse ide is opened. When I exit from eclipse the project stops working on edison. The answer is ok, I should run the codes inside the edison with a remote connection.

                    2nd one: I can see the files which are compiled by eclipse inside the /tmp folder on edison. But I'm not sure what should I do as the next step. So I'm asking for your help. I tried gcc command in different ways with a putty connection but each time I get lots of error messages.

                     

                    If anyone can share a link or some documents that explains the procedure briefly and step by step that should be followed, I would be appreciated.

                    Regards.

                    • 8. Re: Intel IoT Eclipse C++ Build and Run Problem on Edison
                      orphanping

                      In the setting of eclipse's Run configurations,you have set the path to remote create the excutable  file, and the command to set the properties of the file. When you disconnect the Edison without eclipse remote method. You can use the putty or something else tools to connect the Edison. And directly excute the excutable files you create.