Random EEPROM write/put failures - ARGON/XENON

@rickkas7 - removed SINGLE_THREADED_BLOCK - testing so far so good and not showing previous issues. I will expand test code to now publish to cloud to make sure it no longer deadlocks

Test APP (below):

  • removed SINGLE_THREADED_BLOCK and added in 2 Particle.publish() calls.
  • SYSTEM_THREAD(ENABLED)

XENON with Ethernet wing:
Still failing once publish functions are called - so I suspect the SPI issues as @rickkas7 describes above are in play once the SPI ethernet is used. It seems the SINGLE _THREADED_BLOCK just made he issue appear sooner.

ARGON:
Takes longer to fail but locks up within 3 iterations

The console does not receive the publish data from either device at all.

Remove SYSTEM_THREAD(ENABLED) - all devices work and do not lockup, Published messages received in console.

APP:

// SYSTEM_THREAD(ENABLED);

const int dbOffset = 50;
const int sizeOfAttributeName = 4;
const int largestAttributeValue = 20;
const int numOfAttributes = 75;

struct
{ // common struct for attributes stored in EEPROM
  int attributeNum;
  char attributeValue[largestAttributeValue + 1];
  time_t lastChanged;
} attributes;

char buf[128];

// ------------------------------------------------------------------------------
void eepromCreateDataTable() //set NVram to defaults
// ------------------------------------------------------------------------------
{

  Serial.printf("\nStarting EEPROM test");

  for (int recno = 0; recno < numOfAttributes; recno++)
  { //

    attributes.attributeNum = recno;
    attributes.lastChanged = Time.now();
    snprintf(attributes.attributeValue, largestAttributeValue, "%05d", recno);

    EEPROM.put((recno * sizeof(attributes)) + dbOffset, attributes);

    Serial.printf("\nRecord %d added", recno);
  }
}

// ------------------------------------------------------------------------------
void selectAll()
// ------------------------------------------------------------------------------
{
  Serial.print("\n#\tName\t\tUpdated\t\tValue");

  for (int recno = 0; recno < numOfAttributes; recno++)
  {

    EEPROM.get((recno * sizeof(attributes)) + dbOffset, attributes);

    Serial.printf("\n%d\t%d\t\t%lu\t%s", recno, attributes.attributeNum, attributes.lastChanged, attributes.attributeValue);
  }
}

// ------------------------------------------------------------------------------
void setup()
// ------------------------------------------------------------------------------
{
  Serial.begin();               // open serial over USB
  while (!Serial.isConnected()) // wait for Host to open serial port
    Particle.process();

  Particle.publish("sysMsg", "EEPROM Test Started", PRIVATE);
}

// ------------------------------------------------------------------------------
void loop()
// ------------------------------------------------------------------------------
{
  static int iterationCount = 0;
  eepromCreateDataTable();
  selectAll();

  Serial.printlnf("\n\n----------------------------\nIteration:%d\n----------------------------",
                  ++iterationCount);
  sprintf(buf,
          "Iteration:%d",
          ++iterationCount);

  Particle.publish("sysMsg", buf, PRIVATE);
  
  delay(5000);
}

What version of Device OS do you have on the device and what version are you targeting for your app?

1.4.4 - 1.4.4 - using workbench, latest CLI