[SOLVED] Firmware always reset to tinker on reboot

I have noticed that everytime I reboot my Pi, the firmware is reset to Tinker.

Here is what I find in particle-agent logs:

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
  what():  resolve: Host not found (non-authoritative), try again later
Firmware exited with status pid 879 SIGABRT (signal 6)
Quitting firmware gracefully
Entering safe mode because firmware exited too many times in a row. Reverting to Tinker

This was happening with this code which uses stream to write to a file:

#include "Particle.h"
#include <iostream>
#include <fstream>
using namespace std;

ofstream myfile;

#define FILENAME "/home/pi/log.txt"

int writeToFile(String message)
{
  message.concat("\n");
  myfile.open(FILENAME, ios::app);

  char * cstr = new char [message.length()+1];
  std::strcpy (cstr, message.c_str());

  myfile << cstr;
  myfile.close();
  return 0;
}

void setup()
{
  Particle.function("write", writeToFile);
}

void loop()
{

}

As well as this code which uses Process control to call a python script:

#include "Particle.h"

void setup()
{

}

void loop() {
  Process proc = Process::run("/home/pi/bitcoin.py");
  proc.wait();
  String price = proc.out().readStringUntil('\n');
  Particle.publish("price", price);
  delay(5000);
}

Even something as simple as this crashes with the same error and gets replaced by tinker on reboot:

#include "Particle.h"

void setup() // Put setup code here to run once
{
pinMode(GPIO18, OUTPUT);
digitalWrite(GPIO18, HIGH);
}

void loop() // Put code here to loop forever
{

}

@jvanier are you experiencing this?

1 Like

I assume your Raspberry Pi connects through WiFi to the internet. It takes a while for the network to come up at boot and before then the DNS resolution of the Particle cloud fails.

There’s a conflict between the “safe mode” that doesn’t distinguish different failures like DNS failure and real firmware crash. The agent replaces the firmware too aggressively.

1 Like

It is a Pi 3 using onboard Wi-Fi. I hope this issue of overly aggressive safe mode is fixed soon.

I see this situation on a Pi 3 and a Pi 2B, each with eth0 only, no wlan. The agent starts reliably on both.

This is fixed in the latest agent version.

Update by running the install command again.

bash <( curl -sL https://particle.io/install-pi )

1 Like

The firmware is working great now without crashes.

1 Like

All good here, thanks for the rapid response. :grinning:

1 Like