Photon not flashing correctly, or always flashing with tinker

I’m having this same issue. I have a release Photon that I got a few days ago, and I am unable to flash any new code. Everything works exactly like it should with no error messages, but the code does not run. I can still use Tinker. I’ve done multiple factory resets and upgraded the firmware via DFU (using the comand above) multiple times.

When I flash I get the standard magenta, then flashing green and then breathing cyan. The only clue I have is that doing a system reset or wifi reset doesn’t actually erase the wifi settings. It is always able to reconnect to my WIFI immediately after a factory or wifi reset. Any ideas?

Can you put the photon in Setup mode, then connect to serial, and press ‘s’ - please paste the output here. Thanks!

Another thing to try is to download the produced binary from the WebIDE. For a small app on the photon, it should be only a few Kilobytes in size. If it’s around 70-80k then you have a binary for the Core.

The flashing green indicates that the downloaded app was invalid, and that the system did a factory reset to known good firmware. This can happen if the data is not downloaded correctly or if it is an image for the Core.

Here’s the info from the serial interface:

"p":6,"m":[{"s":16384,"l":"m","vc":30,"vv":28,"f":"b","n":"0","v":2,"d":[]},{"s":262144,"l":"m","vc":30,"vv":0,"d":[]},{"s":262144,"l":"m","vc":30,"vv":30,"f":"s","n":"2","v":1,"d":[{"f":"s","n":"1","v":1,"_":""}]},{"s":131072,"l":"m","vc":30,"vv":30,"u":"2BA4E71E840F596B812003882AAE7CA6496F1590CA4A049310AF76EAF11C943A","f":"u","n":"1","v":2,"d":[{"f":"s","n":"2","v":1,"_":""}]},{"s":131072,"l":"f","vc":30,"vv":0,"d":[]}]

I tried downloading the blink an led firmware from the web IDE and it’s 77k. So I guess the Web IDE thinks my Photon is a Core?

If you mean Alpha photon, someone from the Particle team will need to tag it as Photon to target a photon build :wink:

I am having the same issue. My OSX setup is documented [here]
(Photon OSX local build setup notes on 20150531).

I reflashed system_pad_BM-09.bin from the releases page using the command above from mdma@, that did not solve the problem.

I’m able to successfully compile and flash the blink LED example via the Web IDE. I downloaded the blink binary from the Web IDE. I flashed that file using

$ particle flash --usb blink.bin

That succeeded: the led blinked.

What doesn’t work is putting the blink source code file into firmware/main/applications/blink/blink.cpp, then compiling/flashing using

$ make v=1 APP=blink PLATFORM=photon program-dfu

Note that the build/module.mk has Core-specific DFU commands, so I had to change those to:

in bootloader mode before invoking ‘make program-dfu’

program-dfu: $(TARGET_BASE).dfu
        @echo Flashing using dfu:
        $(DFU) -d 2b04:d006 -a 0 -s 0x080A0000:leave -D $<

But it equivalently fails with

$ touch applications/blink/blink.cpp
$ make v=1 APP=blink PLATFORM=photon
$ particle flash --usb ../build/target/main/platform-0/applications/blink/blink.dfu

Complete output here.

Again, the result is that the Photon restarts with Tinker the rather than the expected blinking LED.

BTW, how is the address used in the -s part of the dfu-utils command chosen?

Thanks!

@DrPhoton,

are you trying to work with a Photon or Core?

Be sure to use the develop branch to compile for the Photon

The DFU-address is based on the memory map where each segment is programmed.

Memory map for core is here: http://docs.particle.io/core/hardware/#spark-core-datasheet-memory-mapping

Memory map for photon has not be added to the docs yet.

This won’t build the firmware without also adding all

make v=1 APP=blink PLATFORM=photon all program-dfu

So that explains why it didn’t flash.

1 Like

Thanks, Kenneth and Matthew. Following your suggestions, I git cloned the develop branch, cd’d to main, put the Photon in yellow blinking mode, then did a

make v=1 APP=tinker PLATFORM=photon all program-dfu

The flash appeared to succeed, but the Photon did not show the tinker commands with ‘particle list’ nor responded to tinker calls.

I can flash the ‘blink led’ code from the Web IDE and see the Photon blink D7. Downloading it from the Web IDE, I can also successfully flash it with

particle flash --usb blink.bin

and see the led blink.

But if I add the code to

firmware/user/applications/blink/blink.cpp

then do

make v=1 APP=blink PLATFORM=photon all program-dfu

It appears to flash correctly, but then doesn’t blink the LED.

I tried it with a second Photon. Same result.

Curious, no? Given that the Web IDE bin files work, whether flashed via the Web IDE or locally with ‘particle --usb’, it seems like a problem with the build chain bin/dfu files…

When you build locally, you should also ensure you build and flash the latest system firmware so that the versions match.

Locally, system firmware is at version 2, so the user app you build will also be at version 2. Yet your photon only has version 1 system firmware, so the user app will not run. (The system version has to be at least that of the user version in order to be sure it is compatible.)

To build system firmware, put your photon in DFU mode and run:

cd modules
make PLATFORM=photon clean all program-dfu

This will build everything and flash it to your device, and ensure system and user firmware versions are consistent.

5 Likes

Success!

I switched to modules and flashed that, then switched to main and flashed my ‘blink’ program. It worked.

Thanks, mdma@, for your help!

@mdma can the ‘system firmware’ be built locally and flashed OTA? or does this have to be done via dfu?

What’s the relationship of the ‘system firmware’ and its versions (1,2) that you’re talking about here and the build components mentioned here? Is there a document somewhere that describes the ‘system firmware’?

Thanks :smile:

I’ve had a chance to try building the modules, but am getting errors.

with photon attached in dfu mode, on OSX, in repo “firmware” branch “develop”, in folder “modules” as above. I ran:

make PLATFORM=photon clean all program-dfu

and got the following errors:

<path>/firmware-develop/modules > make PLATFORM=photon clean all program-dfu
`free' referenced in section `.text.mpi_grow' of /var/folders/c1/dt61zfs90816tqlxt_9s76m40000gn/T//ccmwYdRi.ltrans1.ltrans.o: defined in discarded section `.text' of ../../../build/target/system-part1/platform-6-m-lto/../../../modules/photon/system-part1/src/import_rt.o (symbol from plugin)
`free' referenced in section `.text.mpi_free' of /var/folders/c1/dt61zfs90816tqlxt_9s76m40000gn/T//ccmwYdRi.ltrans2.ltrans.o: defined in discarded section `.text' of ../../../build/target/system-part1/platform-6-m-lto/../../../modules/photon/system-part1/src/import_rt.o (symbol from plugin)
`free' referenced in section `.text._ZNSt14_Function_base13_Base_managerIZN13SparkProtocol20handle_function_callERNS1_3msgEEUlPKvN15SparkReturnType4EnumEE_E10_M_managerERSt9_Any_dataRKSA_St18_Manager_operation.5345' of /var/folders/c1/dt61zfs90816tqlxt_9s76m40000gn/T//ccmwYdRi.ltrans3.ltrans.o: defined in discarded section `.text' of ../../../build/target/system-part1/platform-6-m-lto/../../../modules/photon/system-part1/src/import_rt.o (symbol from plugin)
collect2: error: ld returned 1 exit status
make[1]: *** [../../../build/target/system-part1/platform-6-m-lto/system-part1.elf] Error 1
make: *** [<path>/firmware-develop/modules/photon/system-part1/makefile] Error 2

this is with a fresh copy of the repo.

@mdma I did the dfu-util flash, went baclk to the android, gave the WPA2 pass but I have the message that setup process couldn’t configure wifi.

Please check you are using version 4.9.x of gcc - the firmware docs have the details.

1 Like

Could you try to configure WiFi using particle CLI - http://docs.particle.io/core/cli/#running-from-source-advanced-particle-setup-wifi

Thanks! That did the trick. BTW, in the documentation it says:

OS X:

brew install gcc-arm-none-eabi-49

homebrew doesn’t have that formula in its index, but I used this one with success.

I’m still wondering about the relationship of “system firmware” to “build components” and whether there’s any way to flash system firmware OTA rather than just by dfu. This doesn’t seem to be well described in the firmware docs.

There’s some info here: https://github.com/spark/firmware/releases/tag/v0.4.1

I think the OTA sequence for a system firmware upgrade is:

  • system part-1
  • system part-2
1 Like

The PC I’m using has no Wifi… went this way too…

Thanks @kennethlimcp, that’s super helpful. The files included here are just v1 of the firmware? @mdma suggested that we need v2. I assume that I’m building system parts 1 and 2 for v2 when I run ‘make’ in the modules folder locally, is that right?

In any case, even though this can be flashed OTA, we need physical access to the photon to put it into safe mode. So my current understanding is that flashing v2 of system firmware in order to allow local compilation to work needs to be done with each photon physically in hand, for now (possibly forever?).