P2 and Argon won't take WiFi credentials

I have two P2 and one Argon board that somehow got damaged. Everything seems to work fine, except they won't take any WiFi credentials.
The Argon is on OS 4.0.2 and the P2s on 5.3.1. The example below is taken from a P2, but the same is happening with the Argon

Attempting to set credentials over CLI fails with a time-out error:

> particle serial wifi
? Should I scan for nearby Wi-Fi networks? Yes
? SSID XXXXXX
? Security Type WPA2
? Cipher Type AES
? Wi-Fi Password xxxx
! Something went wrong: Serial timed out

Attempting to set up the credentials in code like this:

Serial.println("Checking for credentials");
  WiFi.disconnect();
  for(uint32_t ms = millis(); millis() - ms < 5000; Particle.process());
  if (!WiFi.hasCredentials()){
    Serial.println("No Credentials. Setting up new credentials");
    if (WiFi.clearCredentials()){
      Serial.println("Credentials cleared successfully");
    }else{
      Serial.println("Failed to clear credentials!");
    }
    if (WiFi.setCredentials("XXXXXXX","xxxxxxx")){
      Serial.println("New credentials set successfully");
    }else{
      Serial.println("Failed to set new credentials!");
    }
    for(uint32_t ms = millis(); millis() - ms < 2000; Particle.process());
  }

  //Do we have WiFi credentials?
  if (WiFi.hasCredentials()){
    Serial.println("Trying to connect");
    tryToConnect(20);//First attempt, try for 20 seconds
    if (Particle.connected()){
      Serial.println("Connected");
    }else{
      Serial.println("Could not connect");
    }
  }else{
    Serial.println("No WiFi credentials");
  }

Also fails. Output on terminal is:

Checking for credentials
No Credentials. Setting up new credentials
Failed to clear credentials!
Failed to set new credentials!
No WiFi credentials

The WiFi module seems to be working, as I can scan the visible SSIDs over Bluetooth, but it also fails to retrieve the list of networks over Serial in the CLI

Questions:
Is there a way to recover these boards?
What could have caused this to happen?

User firmware can prevent setting Wi-Fi credentials from working if it writes to the USB serial port. Putting the device into safe mode (breathing magenta) before going into listening mode, or flashing Tinker before setting credentials can help.

Using the web-based Configure Wi-Fi tool can also help in that case, because it uses control requests, not the USB serial port (CDC).

The error from clearCredentials isn't significant it returns false even on success, also on Argon. See this post

Is the network SSID visible? You must specify the encryption type on the P2 when using the device API to set the credentials for hidden SSID, and also use Device OS 5.7.0 or later. Hidden SSIDs are not supported on Argon.

Is the network available? You can't setCredentials to a network that is not currently visible to the device on the P2 and Argon.

Thank you for your suggestions. However, still no luck:

The WiFi setup tool returns:

Wi-Fi setup failed. This can happen if the password is invalid. It may help to reset the device and try again.

Of course I tried again in case I mistyped the password, with the same result. The network is visible and does get listed by the web-based WiFi configuration tool

particle serial wifi still fails with the same time-out error

Tinker flashed without problems (I think):

particle flash --usb tinker
Flashing p2 device 0a10aced20219494xxxxxxxx
[█████████████████████████] 100% | Flash success!

After this, I tried the web-based tool and particle serial wifi, with the same results

Tried to update to 5.5.0 with no luck:

particle update --target 5.5.0
Updating p2 0a10aced20219494xxxxxxxx to Device OS version 5.5.0
[█████████████████████████] 100% | Flash success!
Unable to flash device

Because it said both Flash success and Unable to flash device, I verified with particle identify

Your device id is 0a10aced20219494xxxxxxxx
Your system firmware version is 5.3.1

So it did not update

I tried with 5.7.0:

particle update --target 5.7.0
Updating p2 0a10aced20219494xxxxxxxx to Device OS version 5.7.0
Downloaded Device OS 5.7.0
[█████████████████████████] 100% | Flash success!
Unable to flash device

Once again, verified with particle identify

particle identify

Your device id is 0a10aced20219494xxxxxxxx
Your system firmware version is 5.3.1

Then I tried 5.3.2:

particle update --target 5.3.2
Updating p2 0a10aced20219494xxxxxxxx to Device OS version 5.3.2
Downloaded Device OS 5.3.2
[█████████████████████████] 100% | Flash success!

And verified:

particle identify

Your device id is 0a10aced20219494xxxxxxxx
Your system firmware version is 5.3.2

So this actually worked. I thought maybe I was using an outdated version of the CLI:

particle update-cli
Updating CLI... no plugins to update.

And just to make sure:

particle --version
3.19.0

And after successfully updating to 5.3.2, I tried to go to 5.4.1:

particle update --target 5.4.1
Updating p2 0a10aced20219494xxxxxxxx to Device OS version 5.4.1
[█████████████████████████] 100% | Flash success!
Unable to flash device

Particle Identify still reports 5.3.2

I tried flashing 5.0.1, and it worked, but anything 5.4.0 or higher seems to fail.
I noticed that when flashing these versions (5.4 or higher), it takes a long time and in the middle of the blinking magenta while flashing, it blinks with blue two or three times, and then goes back to blinking magenta (as if the flashing was failing and it was retrying, maybe?).

particle serial wifi failed every time with the same timeout error

So this may be two different problems, as I remember trying to flash 5.5.0 on a brand new P2 and failing. So one problem would be that I can't set WiFi credentials and the other one that I can't flash anything 5.4.0 or later. I'm wondering if there are any pins that may have to be in a specific level (or unconnected) to flash 5.4.0 or later that are ignored on previous versions.

I'm wondering if it is possible that some area of the flash got damaged, and that area is used to store WiFi credentials and used by OS 5.4.0 and later

This seemed to have been caused by the file system being full (at least on the Argon).
I cleared the whole QPSI flash, as per the instructions in

Then rebuilt the keys with
particle keys doctor

Re-flashed the OS with
particle update --target 4.0.2

Then with
particle serial wifi
it was all good

1 Like

The Wi-Fi credentials on the Argon, P2, and Photon 2 are stored in a file on the flash file system, so it is not surprising that saving credentials would fail if the file system was full.