I just built all of the included binaries on the release/v0.4.5 branch, at commit 72b855bc7c158c893c1166b57f5437e9032ddb32.
First, make sure the bootloader flash pages are unlocked by installing the unlocker application as well as the v0.4.5 system modules it requires. Run each of the commands below, one at a time, making sure the device is in DFU mode before running each command.
Photon:
dfu-util -d 2b04:d006 -a 0 -s 0x08020000 -D system-part1-v0.4.5-photon.bin
dfu-util -d 2b04:d006 -a 0 -s 0x08060000 -D system-part2-v0.4.5-photon.bin
dfu-util -d 2b04:d006 -a 0 -s 0x080a0000 -D unlocker-v0.4.5-photon.bin
P1:
dfu-util -d 2b04:d008 -a 0 -s 0x08020000 -D system-part1-v0.4.5-p1.bin
dfu-util -d 2b04:d008 -a 0 -s 0x08060000 -D system-part2-v0.4.5-p1.bin
dfu-util -d 2b04:d008 -a 0 -s 0x080a0000 -D unlocker-v0.4.5-p1.bin
After flashing the unlocker, be sure to wait for the RGB LED to turn solid green. It may be yellow at first. This only takes a second or two.
Second, erase the entire flash memory of the device. Be sure the device is attached to the STLINK programmer and in DFU mode before running this command. The command is the same for Photon and P1.
st-flash erase
The RGB LED should be unresponsive after erasure as no code is running.
Third, write the bootloader. After every st-flash write
command, make sure you see the "jolly good" response from the command line. If you don't, perform the write again.
Example "jolly good" response:
2015-09-29T18:07:22 INFO src/stlink-common.c: Starting verification of write complete
2015-09-29T18:07:22 INFO src/stlink-common.c: Flash written and verified! jolly good!
Photon:
st-flash write bootloader-v0.4.5-photon.bin 0x08000000
P1:
st-flash write bootloader-v0.4.5-p1.bin 0x08000000
After flashing the bootloader, the RGB LED should flash yellow, indicating DFU mode.
Fourth, flash the system modules. Before running each command make sure the device is in DFU mode, and after each command ensure your receive a "jolly good" response.
Photon:
st-flash write system-part1-v0.4.5-photon.bin 0x08020000
st-flash write system-part2-v0.4.5-photon.bin 0x08060000
P1:
st-flash write system-part1-v0.4.5-p1.bin 0x08020000
st-flash write system-part2-v0.4.5-p1.bin 0x08060000
After both modules are written, you should see the RGB LED go white for several seconds. During this period the device is generating an RSA key and a random SSID suffix.
Fifth, write the tinker application to two places, the application firmware location and the factory reset location. Before running each command make sure the device is in DFU mode, and after each command ensure your receive a "jolly good" response.
Photon:
st-flash write tinker-v0.4.5-photon.bin 0x080a0000
st-flash write tinker-v0.4.5-photon.bin 0x080e0000
P1:
st-flash write tinker-v0.4.5-p1.bin 0x080a0000
st-flash write tinker-v0.4.5-p1.bin 0x080e0000
Sixth, read the entire contents of flash off of two devices and save to disk. Be sure each device is in DFU mode before running each command. These commands are the same for Photon and P1.
st-flash read device-a.bin 0x08000000
st-flash read device-b.bin 0x08000000
In my case, with Photons, both files were 922424 bytes.
Seventh, convert the binary dumps to xxd
format so that we can compare them with diff
.
xxd device-a.bin > device-a.xxd
xxd device-b.bin > device-b.xxd
Eighth, save a difference file to compare the flash contents of the two devices.
diff device-a.xxd device-b.xxd > a-b.diff
The file a-b.diff
should be exactly 6976 bytes long, where the only differences are at the following locations, in diff section header format:
- 1482c1482
- 1499,1537c1499,1537
- 1576,1584c1576,1584
- 1612c1612
If that is true, then the devices should behave identically firmware-wise. Any differences in behavior at this point are most likely due to hardware differences.
Last, in order to connect to the Particle cloud, the devices will need the server's public key, and their newly generated private keys will need to be reprovisioned. Before each of the following commands, be sure the devices are in DFU mode.
Photon:
dfu-util -d 2b04:d006 -a 1 -s 2082 -D cloud_public.der
P1:
dfu-util -d 2b04:d008 -a 1 -s 2082 -D cloud_public.der
Then run particle keys doctor
with your device's ID, which you can obtain over serial when the device is in setup mode.