[No Repro] Local build issues (and OneWire timing?)

I’m having trouble getting my local build version of the excellent OneWire library by @Hotaman to work on my Photon. If I build from the web IDE everything works perfectly - so I doubt it’s the fault of the library, more likely something up with my build setup.

I’ve got fresh checkouts of the latest firmware branch, and of the OneWire library. I’ve even cut down the platform-conditional logic around the fast pin access setup (and removed the non-Photon blocks), to ensure the right code is being used.

When I build from Eclipse or the command line with make all APP=myapp PLATFORM=photon I get garbage in the search results - sometimes all zeroes, sometimes garbage, e.g.:

0 - Sensor: 0000000000000000
1 - Sensor: 000000000C020000

0 - Sensor: 4800B7FF5D02000E
1 - Sensor: 0000000000000000

(These are two DS18B20s, so the address above should start with a ‘28’) OneWire is heavily timing dependent, so it feels like this is maybe running with the wrong clock rate/delay scaling or something?

One thing that might be relevant - I have GCC 5.2 (Arch Linux), which I understand from @mdma (Local build failing (in src/cc3000_spi.c)) is not yet fully tested/supported, so this could be the cause. How can I go about narrowing this down and identifying the problem?

It should work the same. Can you try out the examples from the library?

Unfortunately I’m away from the actual HW at the moment, so I can’t use the OneWire examples as they rely on Serial output. Instead I created a minimal test case to expose the search results to the cloud…which works fine across all my build options :sweat_smile: . Looks like I have to chase the problem down in my other app folder!

I’m including my sensor enumeration example here in case it is of benefit to others.

#include "OneWire/OneWire.h"

String sensorStr;
OneWire onewire(D2);
String id = "ow_test";

int enumerate(String command) {
  int i = 0;
  uint8_t nextAddr[8];
  sensorStr = "";
  int res = onewire.search(nextAddr);
  while(res == TRUE) {
    sensorStr.concat(String::format("Sensor %d: ", i));
    for(int j=0; j<8; j++) {
        sensorStr.concat(String::format("%02X", nextAddr[j]));
    }
    i++;
    res = onewire.search(nextAddr);
    if (res) { sensorStr.concat("; "); };
  }
  return i;
}

void setup() {
    Particle.function("search", enumerate);
    Particle.variable("sensors", sensorStr);
    Particle.variable("id", id);
}

void loop() {
    enumerate("");
}

Update to add - i put this enumeration function into my main project and it works… I’m slowly remembering how to bughunt :smile: