9 Replies Latest reply on Jan 27, 2015 11:29 AM by CMata_Intel

    (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console

    Chanduino

      I have done some looking in to the error "sketch.elf[289]: segfault at 4c ip b763fffd sp bf8731c0 error 4 in libuClibc-0.9.34-git.so" and there isn't anything related. Has anyone see this error and know of a workaround? It may just be cosmetic, but I am not sure.

       

      Thanks!

        • 1. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
          CMata_Intel

          Hi Chanduino

           

          Could you please be more detailed of what is happening? I'm not sure if the problem happens when you upload a sketch in your Galileo Board using the IDE. Does the error appeared on the log?

          Have you updated the Galileo firmware? Are you using Gen1 or Gen2?

          Let me know if there are more information that you think it could help us to find a solution to your problem

           

          Regards;

          CMata

          • 2. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
            Chanduino

            Hello CMata,

             

            When uploading a sketch from the Arduino IDE the error appears on the console of the Galileo. I have updated the Galileo firmware to 1.0.4 and this occurs only on the GEN2, the GEN1 works just fine.

             

            Thanks!

             

            Chandler

            • 3. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
              CMata_Intel

              Hi Chandler;

               

              Could you attach the log that you are receiving, maybe a screenshot? 

              Also I want to know if you could answer me some doubts:

              1. Are you following the Getting Started Guide and selecting the port and board as it should.

              2. Are you uploading the Blink sketch or your own customized sketch?

               

              Regards;

              CMata

              • 4. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
                Chanduino

                Hi CMata,

                 

                Thank you for your reply! I am following the Getting Started Guide, I have screenshots of what I have set up and what happens. I am uploading a customized sketch for IoT Analytics. Here is what I have:

                 

                The Galileo serial console is on the left and the Arduino IDE is on the Right. It looks like the upload is successful according to the Arduino IDE however the last line on the Galileo side shows the segfault.

                 

                I am using the correct Board and Port Indicated below:

                 

                Thank you for taking the time to look at this!

                 

                Screenshot 2014-12-10 16.08.35.png

                This screenshot shows that the segfault does not appear when loading a vanilla sketch

                Screenshot 2014-12-10 16.10.07.png

                This is the sketch:

                 

                //This example reads the temperature sensor on the Galileo's

                //onboard ADC, AD7298, using the iio (Industrial I/O) subsystem and

                //sends the observed data to the Intel IoTkit Cloud

                 

                 

                #include <IoTkit.h>    // include IoTkit.h to use the Intel IoT Kit

                #include <Ethernet.h>  // must be included to use IoTkit

                #include <aJSON.h>

                //#include <OneWire.h>

                //#include <DallasTemperature.h>

                #include <SPI.h>

                #include "EmonLib.h"

                //

                const int CT1 = 1;

                const int CT2 = 1;                                                      // Set to 0 to disable CT channel 2

                const int CT3 = 1;

                const int CT4 = 1;

                const int UNO = 0;

                //

                EnergyMonitor ct1;                                                     // Create  instances for each CT channel

                EnergyMonitor ct2;

                EnergyMonitor ct3;

                EnergyMonitor ct4;

                //

                //#define ONE_WIRE_BUS 4                                                  // Data wire is plugged into port 2 on the Arduino

                //OneWire oneWire(ONE_WIRE_BUS);                                          // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)

                //DallasTemperature sensors(&oneWire);                                    // Pass our oneWire reference to Dallas Temperature.

                // DeviceAddress address_T1 = { 0x28, 0x47, 0x28, 0xB5, 0x05, 0x00, 0x00, 0x0D };

                //

                typedef struct {

                  int realPower;                                        // RealPower

                  int apparentPower;                                        // ApparentPower

                  int T1;                                        // temperature sensor 1

                } Payload;

                Payload emontx;

                //

                // create an object of the IoTkit class

                IoTkit iotkit;       

                int temp;

                //

                //

                void setup() {

                  Serial.begin(115200);

                  // call begin on the IoTkit object before calling any other methods

                  iotkit.begin();

                //

                  ct1.currentTX(1, 90.9);                                              // Setup emonTX CT channel (channel, calibration)

                  ct2.currentTX(2, 90.9);

                  ct3.currentTX(3, 90.9);                                              // CT Calibration factor = CT ratio / burden resistance

                  ct4.currentTX(4, 90.9);  

                }

                 

                 

                void loop() {

                  temp = getADCTemp();

                //  Serial.print("Temperature is ");

                //  Serial.print(temp);

                //  Serial.println(" degrees celcius.");

                  //Serial.print("Current Tap 1");

                //  Serial.println(ct1.calcIrms(1480));

                //  Serial.println(ct2.calcIrms(1480));

                //  Serial.println(ct3.calcIrms(1480));

                //  Serial.println(ct4.calcIrms(1480));

                //  Serial.println(" Amps");

                  //

                  //

                //   sensors.requestTemperatures();                                        // Send the command to get temperatures//

                  //

                //  emontx.T1 = sensors.getTempF(address_T1);

                  //

                //  float Irms1 = ct1.calcIrms(1480);   // Calculate RMS current 1

                //  float Irms2 = ct2.calcIrms(1480);   // Calculate RMS current 2

                //  float Irms3 = ct3.calcIrms(1480);   // Calculate RMS current 3

                //  float Irms4 = ct4.calcIrms(1480);   // Calculate RMS current 4

                //

                  double Irms1 = ct1.calcIrms(1480);   // Calculate RMS current 1

                  double Irms2 = ct2.calcIrms(1480);   // Calculate RMS current 2

                  double Irms3 = ct3.calcIrms(1480);   // Calculate RMS current 3

                  double Irms4 = ct4.calcIrms(1480);   // Calculate RMS current 4

                //

                //

                  // call send to generate one observation.

                  // parm1 - the name of the measurement. It must have been previously registered.

                  // parm2 - the value to send as the measurement observation

                  // you can also generate your own JSON and send multiple keys and values

                  // in this format:

                  //

                  // {

                  //   “n”: “temperature sensor”,

                  //   “v”: “27.2"

                  // }

                  //

                  // you need to escape the quotations to pass it directly to iotkit.send:

                  //iotkit.send("{\"n\": \"temperature.v1.0\",\"v\":\"27.2\"}");

                  //iotkit.send("{\"n\": \"obtemp\",\"v\":\"temp\"}");

                  //

                 

                 

                  iotkit.send("obtemp", temp*1.8+32);

                  iotkit.send("current1", ct1.calcIrms(1480));

                  iotkit.send("current2", ct2.calcIrms(1480));

                  iotkit.send("current3", ct3.calcIrms(1480));

                  iotkit.send("current4", ct4.calcIrms(1480));

                 

                 

                  // you can also send a full JSON string with your own variables:

                  //

                  // aJsonObject* root = aJson.createObject();

                  // if (root != NULL) {

                  //    aJson.addItemToObject(root, "n", aJson.createItem(metric));

                  //    aJson.addItemToObject(root, "v", aJson.createItem(value));

                  //    iotkit.send(aJson.print(root)); // this sends your full json

                  //    aJson.deleteItem(root);

                  // }

                  //

                 

                 

                  // If you are receiving incoming commands, listen for them with receive

                  // If you have your own custom json-parsing receive function, pass as argument

                  // such as iotkit.receive(callback);

                  // It must follow this prototype, but any name: void callback(char* json)

                  //

                 

                 

                  iotkit.receive();

                  iotkit.receive(callback);

                 

                 

                  delay(30000);

                }

                 

                 

                // this is an example callback that parses a user-created JSON in the form

                // {

                //    "component": "led",

                //    "command": "off"

                // }

                // and turns off LED at pin 13 hard-coded

                //

                 

                 

                void callback(char* json) {

                  Serial.println(json);

                  aJsonObject* parsed = aJson.parse(json);

                  if (&parsed == NULL) {

                    // invalid or empty JSON

                    Serial.println("received invalid JSON");

                    return;

                  }

                  aJsonObject* component = aJson.getObjectItem(parsed, "component");

                  aJsonObject* command = aJson.getObjectItem(parsed, "command");

                  if ((component != NULL)) {

                    if (strcmp(component->valuestring, "led") == 0) {

                      if ((command != NULL)) {

                        if (strcmp(command->valuestring, "off") == 0) {

                          pinMode(13, OUTPUT);

                          digitalWrite(13, false);

                        }

                        if (strcmp(command->valuestring, "on") == 0) {

                          pinMode(13, OUTPUT);

                          digitalWrite(13, true);

                        }

                      }

                    }

                  }

                }

                 

                 

                // reads hardware temp sensor

                int getADCTemp(){

                  char scale[4];

                  char raw[4];

                  char offset[4];

                 

                  int raw_i;

                  int scale_i;

                  int offset_i;

                 

                 

                   

                  FILE *fp_raw;

                  fp_raw = fopen("/sys/bus/iio/devices/iio:device0/in_temp0_raw", "r");     //read the values from scale, raw and offset files.

                  fgets(raw, 4, fp_raw);                                                    //we need all three values, because the formula for

                  fclose(fp_raw);                                                           //calulating the actual temperature in milli-degrees Celcius

                                                                                            //is: TEMP = (RAW + OFFSET) * SCALE

                  FILE *fp_scale;

                  fp_scale = fopen("/sys/bus/iio/devices/iio:device0/in_temp0_scale", "r");

                  fgets(scale, 4, fp_scale);

                  fclose(fp_scale);

                 

                  FILE *fp_offset;

                  fp_offset = fopen("/sys/bus/iio/devices/iio:device0/in_temp0_offset", "r");

                  fgets(offset, 4, fp_offset);

                  fclose(fp_offset);

                  

                  raw_i = atoi(raw);         //we have the values now, but they are in ASCII form-                                                      

                  scale_i = atoi(scale);     //we need them as integers so we can use them for calculations.

                  offset_i = atoi(offset);

                 

                  int temp = (raw_i + offset_i) * scale_i;  //Calculate temperature in milli-degrees celcius

                  temp /= 1000;                         //divide by 1000 to convert to degrees celcius

                  return temp; 

                 

                }

                • 5. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
                  CMata_Intel

                  Hi Chanduino

                   

                  Sorry for the late response, have you had any updates working in this?

                  If you still having problems could you tell me which image are you using in the SDcard? Let me know if you are using the IOT image from: https://software.intel.com/en-us/iot/downloads

                  Or if you are using the one from here: Galileo Software Downloads

                   

                  Regards;

                  CMata

                  • 6. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
                    Chanduino

                    Hi Cmata,

                     

                    I am using the image from the first link, the IoT image, I have tried using simple code sketch and the same occurs. On my second galileo I tried an update to the uclibc (forced) using a code repo that wasn't intel's where the default error went away but the sketch doesn't run, I don't see data passed to iotkit-agent.

                     

                    I purchased an Edison kit and with the IoT image it appears the sketch downloads but I don't see any info passed to iot kit-agent to go to the dashboard.

                     

                    What's interesting is the IoT image works great on galileo gen1.

                     

                    I am willing to try other options or recommendations. Thank you for your help!

                     

                    Cheers

                    • 7. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
                      CMata_Intel

                      Hi Chanduino

                       

                      Could you send us the link from where are you getting the repo for uclibc? Just to check how it was tested.

                      The iot image is in eglibc, so I guess that when you are calling the IOT libraries in the IDE you will need that the image will be eglibc. You moved to uclibc but I think that is not going to solve it cause the IOT works with eglibc. You should keep using the image from here:  https://software.intel.com/en-us/iot/downloads.

                      I think that you could get more appropriate help from the IOT forums, have you tried with them? . And yes, It is strange that it works on Gen 1 but not on Gen 2.

                      I'm going to research about this and be back to you as soon as possible. If you get an update from them please post it here too.

                       

                      Regards,

                      CMata

                      • 8. Re: (iot-devkit 1.1) When upload from Arduino IDE 1.5.3 (1.0.4) segfault in libuClibc galileo console
                        Chanduino

                        Hi CMata,

                         

                        I found this thread that had some code references to uclibc from Alex_T. It looked like a non-standard way to update uclibc, and I attempted it just to see what would happen.

                        opkg commands to install compiler tools on SD image

                         

                        I followed the instructions at the bottom of the thread.

                         

                        Cheers,

                         

                        Chandler