├── LICENSE ├── README.md ├── clear_claim.bin └── resetsettings.ino /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 rickkas7 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Restoring a Photon to factory clean state 2 | 3 | 4 | ## Resetting settings 5 | 6 | Run this program to reset the antenna, IP configuration, Wi-Fi credentials and EEPROM: 7 | 8 | ``` 9 | #include "Particle.h" 10 | 11 | STARTUP(WiFi.selectAntenna(ANT_INTERNAL)); 12 | 13 | void setup() { 14 | EEPROM.clear(); 15 | 16 | WiFi.useDynamicIP(); 17 | WiFi.clearCredentials(); 18 | 19 | // So you can tell the operations have completed 20 | pinMode(D7, OUTPUT); 21 | digitalWrite(D7, HIGH); 22 | } 23 | 24 | void loop() { 25 | } 26 | ``` 27 | 28 | One way to do this is to download the [resetsettings.ino](https://github.com/rickkas7/photonreset/blob/master/resetsettings.ino?raw=true) file. 29 | 30 | Put the Photon in DFU mode (blinking yellow), by pressing RESET and SETUP, releasing RESET and continuing to hold down SETUP while it blinks magenta until it blinks yellow, then release. 31 | 32 | Then run the commands: 33 | 34 | ``` 35 | particle compile photon --target 0.4.9 resetsettings.ino --saveTo resetsettings.bin 36 | particle flash --usb resetsettings.bin 37 | ``` 38 | 39 | In many cases, it's sufficient to just clear the Wi-Fi credentials by holding down SETUP until it blinks blue, then keep holding it down until it blinks blue rapidly, about 10 more seconds. 40 | 41 | ## Resetting firmware 42 | 43 | Put the device in DFU mode (blinking yellow) and flash Tinker. 44 | 45 | ``` 46 | particle flash --usb tinker 47 | ``` 48 | 49 | If you want to set the system firmware back to the factory default of 0.4.9 (optional): 50 | 51 | Download [system-part1-0.4.9-photon.bin](https://github.com/spark/firmware/releases/download/v0.4.9-rc.3/system-part1-0.4.9-photon.bin) and [system-part2-0.4.9-photon.bin](https://github.com/spark/firmware/releases/download/v0.4.9-rc.3/system-part2-0.4.9-photon.bin) from the [github release site](https://github.com/spark/firmware/releases/tag/v0.4.9-rc.3). 52 | 53 | Put the Photon in DFU mode and issue the commands: 54 | 55 | ``` 56 | particle flash --usb system-part1-0.4.9-photon.bin 57 | particle flash --usb system-part2-0.4.9-photon.bin 58 | ``` 59 | 60 | ## Resetting ownership (from your own account) 61 | 62 | Unclaim the device from your account. If the device is claimed to your account you can use the command line, the Particle Build (Web IDE). Here’s the command line version (insert your device ID): 63 | 64 | ``` 65 | particle device remove 0123456789abcdef123 66 | ``` 67 | 68 | If you don't know your device ID, hold down the SETUP button until it blinks blue (if not already blinking blue) and use the command: 69 | 70 | ``` 71 | particle identify 72 | ``` 73 | 74 | ## Resetting ownership (from another user) 75 | 76 | If the device was used in a classroom or hackathon situation, you may want to restore ownership without having to email the (temporary) owner. You can do this using the Particle phone apps. 77 | 78 | With Photons only (not Core or Electron), you have the ability to take ownership in close proximity, as long as the device was not part of a product creator product. If it was part of a product, it must first be removed from a product from the [product console](https://console.particle.io) for security reasons. 79 | 80 | Put the Photon in listening mode (blinking blue) if it is not already in that state. Hold down the SETUP button until the Photon blinks blue, then release. 81 | 82 | Now use the iOS or Android Particle app to add the device to your account. You will be prompted that it is owned by someone else, but you should be able to take ownership immediately if you say Yes. 83 | 84 | If you use the CLI instead of the phone app, a different process is used that sends an email to the owner. This is because the CLI method can be invoked from anywhere on the Internet, whereas the phone app in listening mode requires that you have the device in your possession and be able to press the SETUP button to enter listening mode. 85 | 86 | After successfully taking ownership of the device you can then unclaim it from your account. 87 | 88 | ## Resetting keys (optional) 89 | 90 | Reset server key in case it was changed to a local server: 91 | 92 | While still in DFU mode: 93 | 94 | ``` 95 | particle keys server 96 | ``` 97 | 98 | Generate new keys: 99 | 100 | ``` 101 | particle keys new 102 | particle keys load device.der 103 | ``` 104 | 105 | ## Resetting the claim code (optional) 106 | 107 | The part that is often missed is clearing the claim code. You need a file that’s 64 bytes long and consists of 0xff bytes, except for the first byte, which is 0x00, most easily done by downloading [clear_claim.bin](https://github.com/rickkas7/photonreset/blob/master/clear_claim.bin?raw=true). 108 | 109 | Then you flash this to the device in DFU mode: 110 | 111 | ``` 112 | dfu-util -d 2b04:d006 -a 1 -s 1762:64 -D clear_claim.bin 113 | ``` 114 | 115 | Be very careful with that command, typing one wrong number can cause massive headaches by corrupting the configuration! That’s the step that’s necessary to prevent the phone app from saying that the device has already been registered. 116 | 117 | If you skip this step, users can still claim the device, but they'll get a warning that it has been claimed, even though it's no longer claimed, when using the phone apps. 118 | 119 | Now reset your device and you should be able to claim it with a different user with no warnings, as if it was fresh from the factory. 120 | 121 | -------------------------------------------------------------------------------- /clear_claim.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rickkas7/photonreset/0d53357eeafe519a923a9da0152ab371b3f92a1b/clear_claim.bin -------------------------------------------------------------------------------- /resetsettings.ino: -------------------------------------------------------------------------------- 1 | #include "Particle.h" 2 | 3 | STARTUP(WiFi.selectAntenna(ANT_INTERNAL)); 4 | 5 | void setup() { 6 | EEPROM.clear(); 7 | 8 | WiFi.useDynamicIP(); 9 | WiFi.clearCredentials(); 10 | 11 | // So you can tell the operations have completed 12 | pinMode(D7, OUTPUT); 13 | digitalWrite(D7, HIGH); 14 | } 15 | 16 | void loop() { 17 | } 18 | --------------------------------------------------------------------------------