Upgrading and downgrading Particle Device OS

More information than you ever wanted to know about upgrading and downgrading Particle Device OS (system firmware).

Automatic updates

In many cases, system firmware updates occur automatically; you don’t need to do anything special. The Safe Mode Healer takes care of doing the update for you.

Web IDE (Particle build)

In Particle Web IDE, click on the Devices icon (circle with 4 lines), and open up the device by clicking on the > and then change the system firmware target to the appropriate version:

build

In this example, the device has 0.7.0, and it will be upgraded to 0.8.0-rc.8.

Your firmware is flashed to the device over-the-air, and if it requires a newer system firmware version, the device will blink magenta while the system firmware upgrades. It will reboot a few times.

Note that this is the minimum system version. If, for example, you have 0.7.0 installed and subsequently flash firmware that requires system firmware 0.6.3, the device will not be downgraded. However, a binary that requires 0.6.3 can still run on 0.7.0 so it will still work properly.

Particle Dev (Atom IDE)

At the bottom of the Particle Dev screen, click on the version number to change to a different version.

dev

Particle CLI

In the CLI, you use a command like:

particle compile photon project.ino --target 0.8.0-rc.8

That will build project.ino and target system firmware 0.8.0-rc.8.

The list of valid versions can be found at the release site.

Automatic updates - Electron and E Series

Automatic updates work for the Electron and E series as well. However, because your data usage is metered, you may want to use USB instead. System firmware 0.7.0 is approximately 288 Kbytes.

Whenever you upgrade from a version prior to 0.5.3, to a version after 0.5.3, there will always be an intermediate upgrade to 0.5.3. For example, if you upgrade from 0.4.8 (older factory default) to 0.6.2, there will be one upgrade to 0.5.3, then another to 0.6.2. The reason is that in 0.6.0 Electron system firmware changed from 2 to 3 parts. The intermediate upgrade is necessary as 0.5.3 has 2 parts, but knows how to install 3 parts. This happens automatically, but will use nearly twice the data and take twice as long, so that’s something to keep in mind.

Electrons ship with 0.5.3 now, so the second update is not necessary.

Automatic updates - Spark Core

The older Spark Core uses monolithic firmware. Each firmware binary contains both the system firmware and the user firmware. This there is no need to update the system firmware as every firmware binary contains the appropriate system firmware as well.

This isn’t done on the Photon because a user firmware that’s 10 Kbytes on the Photon might be 480 Kbytes on the Spark Core, and it takes way longer to download the larger binaries.

Particle CLI (recommended)

The fastest and most reliable way to update system firmware is using the Particle CLI.

Connect the device by USB and put the device in DFU mode (blinking yellow) by holding down RESET and SETUP (or MODE), releasing RESET and continuing to hold down SETUP (or MODE) while the main LED blinks magenta until it blinks yellow, then release.

Then enter this command in a Command Prompt or Terminal window:

particle update

Note that the CLI does not automatically update to the latest system firmware version, it updates to the version associated with that version of the CLI.

For example, if you have CLI version 1.17.0 installed, you get system firmware 0.5.3, not the latest version.

To update the Particle CLI installed by the installer, use:

particle update-cli

dfu-util not found

The dfu-util program should be installed by the Particle CLI installer. If you get an error that it’s not found the instructions are here may be helpful in fixing the problem.

Exception: Windows 7 64-bit and DFU mode

The Particle CLI system firmware update uses the DFU mode (blinking yellow). DFU requires a device driver under Windows, and the device driver does not work on Windows 7 64-bit. It works on Windows 7 32-bit, and Windows 8 and later 32-bit and 64-bit, just not Windows 7 64-bit.

As it may be useful to be able to use DFU for other reasons, you may want to find another computer you can use for this purpose.

You can the instructions for manual upgrades using USB and CLI, below, however.

Firmware Manager

The Firmware Manager for Windows and Mac OS is no longer supported. It can be used to upgrade only to 0.6.0, it is not built for later versions.

Manual upgrades and downgrades

The first step is to download the binaries. Go the the release site and pick the version you want to use, then click the Download link next to the cloud icon.

Download the necessary parts:

  • For Photon: system-part1-xxx-photon.bin, system-part2-xxx-photon.bin
  • For P1: system-part1-xxx-p1, system-part2-xxx-p1.bin
  • For Electron/E Series: system-part1-xxx-electron.bin, system-part2-xxx-electron.bin, system-part3-xxx-electron.bin

If you are upgrading from a version before 0.7.0 to 0.7.0 or later, you may also want to download the bootloader file.

Manual over-the-air (OTA) upgrades using the CLI

The easiest way to do a manual OTA upgrade (or downgrade, below) is using the Particle CLI.

When doing this process, you need to wait for the device to reboot after each step. If the device is not in front of you, the best way to monitor this is to open the console Events tab, and watch for the online events.

Also, there is a good possibility that after you flash system part 1, the safe mode healer will take over and finish the remainder of the parts automatically for you.

For example, to flash system part 1 of 0.7.0 for Photon OTA, you’d use a command like:

particle flash DEVICE_NAME system-part1-0.7.0-photon.bin

Replace DEVICE_NAME with the name of your device, of course.

Repeat this process for the other system parts if necessary.

Manual over-the-air (OTA) downgrades using the CLI

It is possible to do a downgrade of system firmware OTA. There may be additional caveats based on the system version, so be sure to check the release notes for the version you are downgrading from and the Downgrade Chart, below, for more information.

The important thing is that you must flash the parts in the reverse order, for example: 2 then 1 for Photon or 3, then 2, then 1 for Electron.

When doing this process, you need to wait for the device to reboot after each step. If the device is not in front of you, the best way to monitor this is to open the console Events tab, and watch for the online events.

Make sure you flash user firmware that requires only the earlier system firmware version before downgrading the system firmware. Otherwise your downgrade will be immediately followed by a safe mode healer upgrade!

Also note that for example you can run a binary that targets 0.5.3 on a device that is running 0.6.2. This is fully supported and you don’t have to downgrade the system firmware version.

Electron 0.4.8 OTA upgrade warning

Whenever you upgrade from a version prior to 0.5.3, to a version after 0.5.3, you must always do an intermediate upgrade through 0.5.3. For example, if you upgrade from 0.4.8 (factory default) to 0.6.2, you need to upgrade first to 0.5.3, then upgrade again 0.6.2.

The reason is that in 0.6.0 Electron system firmware changed from 2 to 3 parts. The intermediate upgrade is necessary as 0.5.3 has 2 parts, but knows how to install 3 parts.

The Safe Mode Healer knows how to do this, but if you upgrade OTA manually you need to do the intermediate upgrade yourself.

Manual OTA updates of product devices

The particle flash command cannot be used with product devices. You’ll need to write a simple script or use a curl command directly to flash a product device.

  • You’ll need an access token for your product. The easiest way to get one is to open the console, your product, Events, then click view in console. It will print an access token which looks something like 970cead6d403b6e7af4ab43ab1358b599fa94082.
  • Be sure to change 1234 to your actual numeric product ID, which is displayed next to the key icon in the console.
  • And substitute the actual device ID for 0468136beae1556af72d3230.
curl -X PUT "https://api.particle.io/v1/products/1234/devices/0468136beae1556af72d3230?access_token=970cead6d403b6e7af4ab43ab1358b599fa94082" \
       -F file=@system-part1-0.7.0-electron.bin \
       -F file_type=binary

Using USB DFU mode (blinking yellow)

USB DFU mode (blinking yellow) is the most reliable way to upgrade or downgrade system firmware.

Hold down RESET and SETUP (or MODE) at the same time. Release RESET and continue to hold down SETUP (or MODE) while the status LED blinks magenta (red and blue at the same time) until it blinks yellow, then release.

For example, to flash system part 1 of 0.7.0 for Photon by USB serial, you’d use a command like:

particle flash --usb system-part1-0.7.0-photon.bin

You cannot flash the bootloader file in --usb mode. See --serial, below.

Using USB serial mode (listening mode)

Whenever possible you should use DFU mode, but if you are using Windows 7 64-bit, or other situations where DFU mode is not working, you can use listening mode (blinking dark blue). This mode is also necessary for flashing the bootloader by USB.

Hold down the SETUP (or MODE) button until the status LED blinks dark blue.

For example, to flash system part 1 of 0.7.0 for Photon by USB serial in listening mode you’d use a command like:

particle flash --serial system-part1-0.7.0-photon.bin

The bootloader can only be flashed OTA or in listening mode. The bootloader cannot be flashed in DFU mode.

particle flash --serial bootloader-0.7.0-photon.bin

Upgrade and downgrade chart

Upgrade Chart - Photon/P1

  • You should be able to upgrade any 0.4.6 or later directly to any version for Photon/P1.

There is one important caveat, however: If you are upgrading from a version prior to 0.7.0 to 0.7.0 or later, on the Photon/P1 the device must have cloud access unless you flash the bootloader manually.

The reason is that 0.7.0 requires a bootloader upgrade. In versions prior to 0.7.0 the bootloader was embedded in the system firmware parts, but there wasn’t enough room in 0.7.0 to do that.

If you’re upgrading OTA (including safe mode healer), you’ll notice four reboots or more, for user part, for system part 1, system part 2, and bootloader.

The bootloader should be updated by safe mode healer, unless you have a device that is not configured for Wi-Fi, then you should manually flash the bootloader in serial mode or JTAG/SWD. The bootloader cannot be flashed in DFU mode.

The particle update command knows how to flash both the system parts and bootloader in one step.

Photons running monolithic firmware (built using the local gcc-arm build chain, or prior to 0.4.1) can only be switched to normal modular firmware by USB. They cannot be upgraded OTA.

Downgrade Chart - Photon/P1

  • Any version 0.7.0 or later to 0.6.x, you must downgrade to 0.6.3 first. (Reason: only this version downgrades the bootloader.) After you downgrade to 0.6.3 you can downgrade further if necessary. OTA you must flash part2, then part 1.

  • Any version 0.7.0 or later to 0.5.x, you must downgrade to 0.5.5 first. (Reason: only this version downgrades the bootloader.) After you downgrade to 0.5.5 you can downgrade further if necessary. OTA you must flash part2, then part 1.

Upgrade Chart - Electron

Any version prior to 0.5.3, including the old factory default of 0.4.8, you must upgrade to 0.5.3, 0.5.4, or 0.5.5 before upgrading to any higher version. (Reason: support for 3 system parts.)

Downgrade Chart - Electron

  • Any version 0.7.0 or later to 0.6.x, you must downgrade to 0.6.4 first. (Reason: only this version downgrades the bootloader.) After you downgrade to 0.6.4 you can downgrade further if necessary. OTA you must flash part3, part2, then part 1.

  • Any version 0.7.0 or later to 0.5.x, you must downgrade to 0.5.5 first. (Reason: only this version downgrades the bootloader, and downgrade to 2 system parts). OTA you must flash part 2, then part 1.

  • 0.6.x to 0.5.2 or earlier: You must downgrade to 0.5.3, 0.5.4, or 0.5.5 first. (Reason: downgrade to 2 system parts). OTA you must flash part2, then part 1.

I’m stuck in safe mode

If you’re not sure why you’re stuck in safe mode, it’s best to use the particle serial inspect command. The device must be connected by USB and in listening mode (blinking dark blue). Hold down the SETUP or MODE button to enter listening mode.

$ particle serial inspect
Platform: 6 - Photon
Modules
  Bootloader module #0 - version 101, main location, 16384 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
  System module #1 - version 207, main location, 262144 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
  System module #2 - version 207, main location, 262144 bytes max size
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      System module #1 - version 207
      Bootloader module #0 - version 7
  User module #1 - version 2, main location, 131072 bytes max size
    UUID: 2BA4E71E840F596B812003882AAE7CA6496F1590CA4A049310AF76EAF11C943A
    Integrity: PASS
    Address Range: PASS
    Platform: PASS
    Dependencies: PASS
      System module #2 - version 1
  empty - factory location, 131072 bytes max size

The main thing you need is is the semantic version (207) to system version (0.7.0) mapping table.

That table also lists the bootloader required for each system version, which is helpful.

The output above is normal for 0.7.0, system version and bootloader version are correct, which is why everything passes.

User module is always version 4, that’s an internal version number, not related to PRODUCT_VERSION for product firmware. The factory location is always empty on a Photon.

Integrity is the check of the CRC included in every firmware binary.

SD Card

It’s possible to upgrade system firmware via SD card, if you’ve added the appropriate hardware and software. There is a proof-of-concept project that does that.

14 Likes

Awesome post!

Thanks Rick!

I’m having a lot of problems with downgrading firmware. My code is written for 1.0.1 so I need to downgrade to that. It seems like each photon in my product batch acts differently. Often I can try repeatedly and eventually it works. Today I’m stuck on one.

Part 1 flashes alright.

When I try to change the firmware with dfu mode I get the error, “Failed to flash 25003a000447393035313138: Device not discoverable or is offline” when I try to flash part 2. The device is obviously plugged in via USB and in dfu mode.

I’ve had success earlier today flashing the same firmware files while the device is safe mode (part 2 then part 1). But it doesn’t work for this particular device. I get the same error - part 2 fails to flash.

Any suggestions are appreciated.

With this particular device, I notice that when it is in safe mode and I flash half the .bin it will boot, connect to the cloud and flash magenta a bunch. I associate this with updating the firmware or the “Safe Mode Healer”. Could it be that the Photon is “healing” itself after half of the flash, which is why it is unable to complete the flashing process? Maybe there is a way to turn off “Safe Mode Healer”?

When I try to use Listen mode to change the firmware the first half (part 1) loads and I get the “flash success” message. The second half does not load and reports “Request timed out”.

Even when your application is targeted at 1.0.1 it can still run under any device OS higher than that.
The target is only the minimum device OS version required to run the code.

In order to downgrade you need to have a application firmware on it that does not trigger Safe Mode healer to upgrade again.

Can you post the particle serial inspect output for that device?

When flashing over USB I’d always opt for DFU Mode and particle flash --usb <firmware.bin> -v to get most info about the flashing process.

Once you got a device in a “wonky” state you may want to start fresh from a known state like this

particle flash --usb tinker -v
particle update -v
particle flash --usb tinker -v

After that a particle serial inspect should give you all green PASS and a good base for a new attempt.

I get that in theory the code should run on newer versions of the firmware. But actually it causes a hard fault. Perhaps there is something wrong with my code, but damned if I can find it so I’ll just have to work around the issue and use the older firmware that works with it.

I was careful to compile the code to 1.0.1. I flashed it through the IDE.

Here is the output from particle serial inspect:

Platform: 6 - Photon
Modules
Bootloader module #0 - version 501, main location, 16384 bytes max size
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #1 - version 1406, main location, 262144 bytes max size
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #2 - version 207
System module #2 - version 1406, main location, 262144 bytes max size
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #1 - version 1406
Bootloader module #0 - version 400
User module #1 - version 6, main location, 131072 bytes max size
UUID: 49037BB773B6594AC69338F799A999C5F993CFC5DD9BF930FBCD52512531BA31
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #2 - version 1406

After flashing tinker and updating as you suggested the output from particle serial inspect is now:
Platform: 6 - Photon
Modules
Bootloader module #0 - version 1005, main location, 16384 bytes max size
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #1 - version 2011, main location, 262144 bytes max size
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #2 - version 207
System module #2 - version 2011, main location, 262144 bytes max size
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #1 - version 2011
Bootloader module #0 - version 1003
User module #1 - version 3, main location, 131072 bytes max size
UUID: B3A6DCD529BE70FBE24EE959C7305D58E3BC9A04ACDCE8F093C7A1F759097D09
Integrity: PASS
Address Range: PASS
Platform: PASS
Dependencies: PASS
System module #2 - version 6

I tried using particle flash --usb <firmware.bin> -v (part 2 first). That works. The device doesn’t change its firmware and seems stable.

Thank you for the help!

The most common cause for that behaviour after a device OS update seem to be the lack of a return statement in a Particle.function() callback.

Which IDE?
Unfortunately Web IDE does not give you a proper build log when it succeeds but often you'd want to see whether there are any warnings (the issue described above would turn up as such).
You can force a build log by introducing a minor build error (e.g. an extra curly brace at the bottom of your code) and then check the SHOW RAW log for any potential warnings and try to correct them.

Future visitors

Please take a look at the device restore tool.

@rickkas7 I am having an issue when attempting to downgrade a product device(p1) OS to 2.1.1 from 3.3.0. I have had success before using this exact curl command, but now when I try to use it it returns {"error":"Nothing to do?"} My exact command from the windows PowerShell is

"curl.exe -X PUT "https://api.particle.io/v1/products/9794/devices/**DeviceId**?access_token=**BearerToken**" -F file=p1-system-part2@2.1.0.bin -F file_type=binary".

These devices are in the field and I can not directly connect to them to downgrade them. I have not had any luck searching for additional documentation about the API endpoint for this action either. Any insight into what I am doing wrong or what may have changed would be greatly appreciated.

Curl requires file=@, note the at sign, in order to load the contents of a file instead of a literal string.

2 Likes

@rickkas7 That did it. You are the man! Thank you for your help!