Output state changes while flashing

Hi all,

I designed a circuit that control some relays and now i notice that when im flashing new code into the photon, some of the outputs go high and low, turning on and off some of the light bulbs i have conected through the relays.

Is that something happening because of my code or does it always happen?
If is it always, then which are these outputs so i can change my circuit. I dont want to install this in a customer´s house and have the lights flashing every time i update the firmware.


Which pins are you using now? This might be caused by the fact that pins D3 through D7 are used for JTAG (check out the Photon data sheet for the details). After reset, D3, D5, and D7 are pulled high for a short period, while D6 is pulled low, and D4 is floating. Try using D0-D2 or any of the A pins to see if that fixes the problem.


Thanks @Ric. It was D3 the pin giving me problems. I{ll move it to A0.

1 Like

Sorry for reviving this thread but more sensible to keep the topic together.

The “solution” helped to answer my initial question. However, I’m using most of the pins on my Photon and don’t have the luxury to not use D3 - D7. I could possibly move less sensitive outputs around.

For over the air flashing, is there really any absolute necessity for the updater to mess with the JTAG pins? I’m guessing no for OTA, but that maybe for simplicity for other programming options it was included?

Like @alexgrauer my concern is customer experience when OTA updates occur. For commercial projects, they will typically only be programmed once with JTAG/USB, and forever afterward be updated via OTA.

I couldn’t find anything in the datasheet about JTAG that informs anything about OTA process. And I don’t know what a “short period” is (I would have thought something less than 10ms), but in my testing the relevant outputs go high for the entire update cycle, turning on relays etc.

It’s not the OTA update process that changes the pins. When the device boots, the bootloader briefly sets it up the device so it can be taken over by JTAG for programming. That’s what changes the pins. Then booting proceeds normally.

You could probably build a custom bootloader that doesn’t enable JTAG, but it would be a pain to maintain.

Thanks. I think I misdiagnosed the issue I’m seeing.

Does the current firmware continue to run, and for a few seconds after the update before resetting and starting up with the latest flashed firmware? For example, inputs that are HIGH, remain HIGH after and while the update starts to flash to the device. On reboot I notice the very brief D7 flashing HIGH which is what you’re referring to, I believe.

The behavior during OTA update depends on SYSTEM_THREAD.

If disabled (the default if you don’t set it), your firmware will stop running during the update. The pins should stay in whatever state they were in before stopping.

With SYSTEM_THREAD(ENABLED) your firmware continues to run, though somewhat erratically. loop won’t be called with the normal frequency, for example.

And, yes, the brief dim flash of D7 at boot is because that pin is used for JTAG and gets a weak pull-up. Since it’s also connected to the blue D7 status LED, the LED will light dimly, then goes off when system firmware boots because the pin is set to INPUT.


Thanks @rickkas7! Now I understand the whole process.