Error flashing anything: "Flash requires modules not present on device"

I tried flashing some c++ code, and ever since then I get the following error, even on the first simple Wiring code I tried. Don’t see this error in a search of the forum. I have a photon.

$ particle flash breadboard blinky.ino
Including:
    blinky.ino
attempting to flash firmware to your device breadboard
flash device said  {"ok":true,"message":"Flash requires modules not present on device"}
$ echo $?
0

I even tried using the web IDE to flash Tinker, and it says “Flash successful! Please wait a moment while your device is updated…” but nothing happens on my Photon. It’s still doing what it has been. I’ve disconnected the power a few times, too.

It’s stuck with what was last flashed on it.

I guess you are using a Photon?

Did you do any local work that updated the system firmware?

No, I’m brand new to dealing with hardware stuff, but I found the issue.

I wrote the following for playing with the RGB LED, and I suppose that since it takes so long for that function to return, nothing else works.

void cycle() {
  for (int r = 0; r < 256; r++) {
    for (int g = 0; g < 256; g++) {
      for (int b = 0; b < 256; b++) {
        analogWrite(REDPin,   r);
        analogWrite(GREENPin, g);
        analogWrite(BLUEPin,  b);
      }
    }
  }
}

I was able to reset the firmware and install other code just fine, and replicate this issue.
The error message is cryptic, though.

Are you saying only a particular code is failing and the rest works on your Photon?

You are using particle-cli?

If this is running on a Photon, please put the device in Safe Mode - that will allow you to connect to the cloud and flash firmware. This is necessary since your code is blocking the main thread, stopping the system from performing any updates. n a few weeks, we will be releasing multithreading support on the Photon, which will address these kinds of problems.

I In the meantime, it’s a good idea to add a delay(1) to long loops like this call so that the system can perform background processing.

Thanks! Safe Mode is just as effective as Firmware Reset but quicker.

And yay to multithreaded support! :smiley:

I noticed a delay in the inner loop is interruptible, but even outside it with only 256 loops before a delay it still blocks:

void cycleInterruptible() {
  for (int r = 0; r < 256; r++) {
    for (int g = 0; g < 256; g++) {
      for (int b = 0; b < 256; b++) {
        analogWrite(REDPin,   r);
        analogWrite(GREENPin, g);
        analogWrite(BLUEPin,  b);
        delay(1);
      }
    }
  }
}

void cycleBlocks() {
  for (int r = 0; r < 256; r++) {
    for (int g = 0; g < 256; g++) {
      for (int b = 0; b < 256; b++) {
        analogWrite(REDPin,   r);
        analogWrite(GREENPin, g);
        analogWrite(BLUEPin,  b);
      }
      delay(1);
    }
  }
}

The reason is that the system doesn’t get a look-in until the delays accumulate to 1000 ms.

1 Like