I am having some kind of basic problem with my new Photon trying to run the “Blink An Led” sample code.
I’m on a Windows 10 platform, with the photon connected via USB cable. I load the “Blink An LED” code with the CLI command “particle flash --serial firmware.bin” and it returns success and the photon soon is breathing cyan. However, no LED starts blinking.
Using the Tinker app, I’m able to toggle D7 and see the LED go on and off. I’m also able to toggle the LED on/off with the CLI command: “particle call digitalwrite D7,HIGH”.
In Device Manager of Windows 10, I can see my Photon on COM3.
Because I had some trouble installing and tried a few things, I don’t know if I messed up the Photon firmware in some way, but it seems to behave normally in all other ways. It just doesn’t seem to run the “Blink An Led” program.
Does the “Blink An Led” compile and load the same for an Electron and a Photon? Or is there some platform switch I’m missing?
I’m at a loss as to how to troubleshoot this. Is there any info I can provide to help debug?
Try flashing via DFU Mode (particle flash --usb firmware.bin -v).
If that doesn’t work (or give you more info about the issue) you may have an old bootloader. To check that put your device in Listening Mode, run particle serial inspect and post the output here.
Thanks. By the way, where is the "-v" parameter documented, I haven't seen it in the docs yet?
Below is the output from the flash. I'm suspecting Moors7 comment about platform may be the issue, but using the Web IDE I don't see where the platform is specified.
Blockquote
Error writing firmware: Incorrect platform id (expected 6, parsed 0), use --force to override
VError: Error writing firmware: Incorrect platform id (expected 6, parsed 0), use --force to override
at Promise.resolve.then.then.then.then.then.catch.err (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\dist\cmd\flash.js:206:13)
at
at process._tickCallback (internal/process/next_tick.js:189:7)
caused by: Error: Incorrect platform id (expected 6, parsed 0), use --force to override
at parser.parseFile.catch.then.info (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\dist\cmd\flash.js:149:17)
at tryCatchReject (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\node_modules\when\lib\makePromise.js:845:30)
at runContinuation1 (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\node_modules\when\lib\makePromise.js:804:4)
at Fulfilled.when (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\node_modules\when\lib\makePromise.js:592:4)
at Pending.run (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\node_modules\when\lib\makePromise.js:483:13)
at Scheduler._drain (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\node_modules\when\lib\Scheduler.js:62:19)
at Scheduler.drain (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\node_modules\when\lib\Scheduler.js:27:9)
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickCallback (internal/process/next_tick.js:181:9)
Thanks, that sounds like maybe the problem. I don’t know yet how to do that, I’m using Web IDE. I originally set up my account and developed on an Electron, but I don’t see any association with the Web IDE and a particular device.
Messing around and trying things without understanding, I now have my Photon in a state where it blinks blue on power up instead of breathing cyan as it used to (I’m guessing it was running Tinker before because I could use the Tinker app on my smart phone).
Here is what I tried:
D:\Data\Projects\Particle.io\DadPhoton>particle compile photon blink-an-led.ino
Compiling code for photon
Including:
blink-an-led.ino
attempting to compile firmware
downloading binary from: /v1/binaries/5d90a9b7f4a91000018e5eb0
saving to: photon_firmware_1569761713579.bin
Memory use:
text data bss dec hex filename
5084 112 1424 6620 19dc /workspace/target/workspace.elf
Compile succeeded.
Saved firmware to: D:\Data\Projects\Particle.io\DadPhoton\photon_firmware_1569761713579.bin
D:\Data\Projects\Particle.io\DadPhoton>particle flash --serial photon_firmware.bin
! PROTIP: Hold the SETUP button on your device until it blinks blue!
? Press ENTER when your device is blinking BLUE
sending file: photon_firmware.bin
Flash success!
Flash success!
D:\Data\Projects\Particle.io\DadPhoton>particle flash --serial photon_firmware.bin
! PROTIP: Hold the SETUP button on your device until it blinks blue!
? Press ENTER when your device is blinking BLUE
sending file: photon_firmware.bin
Flash success!
Flash success!
D:\Data\Projects\Particle.io\DadPhoton>particle flash -- serial tinker
? Which type of device? Photon
attempting to flash firmware to your device serial
Flash device failed: I didn't recognize that device name or ID, try opening https://api.particle.io/v1/devices?access_token=3467b6146ddb8eb039cc3b7cd2e6c6cd90b61234
When you enter particle --help you'll see that this activates verbose mode.
In older versions of CLI this was the default setting and hence was not documented. Now when you run some commands you only get very limited output, hence adding -v is advisable when you get unexpected results.
BTW, particle flash --serial even reports success when you try to flash a incompatible binary or not even a binary file - hence my advice to use --usb
Thanks, this all helps. But still some ways to go it seems. I went to the Web IDE and selected the correct device and then tried to flash the Photon. It failed. The Web IDE did not say what mode to put the Photon in, but at the moment my Photon boots up with flashing blue so that is what I used.
For my next experiment, I tried the “particle device doctor” command. It all seemed to go well until the end where it failed to scan for available wifi signals, asking if I had permission. I tried again starting the command window with “run as administrator”, but same problem. I believe I correctly put the Photon in the dfu mode as it was flashing yellow. Here is the session output.
C:\WINDOWS\system32>particle device doctor
The Device Doctor will put your device back into a healthy state
It will:
- Upgrade system firmware
- Flash the default Tinker app
- Reset the device and server keys
- Clear the Wi-Fi settings
The Doctor will operate on your Photon connected over USB
You'll be asked to put your device in DFU mode several times to reset different settings.
Updating system firmware
Put the device in DFU mode
Tap RESET/RST while holding MODE/SETUP until the device blinks yellow.
? Select Continue when ready Continue
> Your device is ready for a system update.
> This process should take about 30 seconds. Here it goes!
! System firmware update successfully completed!
> Your device should now restart automatically.
Flashing the Device Doctor app
This app allows changing more settings on your device
Put the device in DFU mode
Tap RESET/RST while holding MODE/SETUP until the device blinks yellow.
? Select Continue when ready Continue
Select antenna
? Select the antenna to use to connect to Wi-Fi Internal
Switched antenna to Internal
Configure IP address
? Select how the device will be assigned an IP address Dynamic IP
Switched to dynamic IP
Reset Wi-Fi hotspot name in listening mode
? Select Continue when ready Continue
Switched SoftAP prefix to default
Clear all data in EEPROM storage
? Select Continue when ready Continue
Cleared EEPROM data
Clearing and setting up Wi-Fi settings
? Select Continue when ready Continue
Cleared Wi-Fi credentials
Entering listen mode
? Should I scan for nearby Wi-Fi networks? Yes
The Doctor didn't complete successfully. Unable to scan for Wi-Fi networks. Do you have permission to do that on this system?
> Please visit our community forums for help with this error:
https://community.particle.io/
C:\WINDOWS\system32>
Update - I see now from the link you provided that the Photon should be breathing cyan when flashing from the Web IDE, so that would be the apparent reason I was unsuccessful with that route, since my Photon seems only capable of other modes such as blinking blue, magenta, yellow, etc.
It’s interesting that the command “particle help” no longer seems to be documented in the CLI COMMAND REFERENCE, although I was aware of it from an older version of the documentation I have.
I bit the bullet and tried “particle setup”. It also balked at the wifi setup stage. I wonder if the wifi is turned off on my photon, I have seen the LED white at various times during my experiments. I’ll look for how to turn it on.
Output from “particle setup” session:
C:\WINDOWS\system32>particle setup
_ __ _ _ _
| '_ \ __ _ _ __| |_(_) ___| | ___
| |_) |/ _` | '__| __| |/ __| |/ _ \
| __/| (_| | | | |_| | (__| | __/
|_| \__,_|_| \__|_|\___|_|\___|
https://particle.io
> Setup is easy! Let's get started...
> It appears as though you are already logged in as simonbaker4@hotmail.com
? Would you like to use this account? Yes
! PROTIP: Hold the MODE/SETUP button on your device until it blinks blue!
! PROTIP: Please make sure you are connected to the internet.
> I have detected a Photon connected via USB.
? Would you like to continue with this one? Yes
! The device supports setup via serial.
setting up device 190047000b51373331333230
> Obtained magical secure claim code.
Claim code set. Now setting up Wi-Fi
? Should I scan for nearby Wi-Fi networks? Yes
(node:404) UnhandledPromiseRejectionWarning: VError: Unable to scan for Wi-Fi networks. Do you have permission to do that on this system?
at wifiScan (C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\dist\cmd\serial.js:487:25)
at C:\Users\Randy\AppData\Local\particle\node_modules\particle-cli\node_modules\node-wifiscanner2\lib\netsh.js:60:13
at ChildProcess.exithandler (child_process.js:288:5)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:915:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:404) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:404) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
C:\WINDOWS\system32>
It finally dawned on me that the step “scanning for wifi” is probably trying to use my computer to scan for wifi networks rather than the Photon, and I am on a desktop computer with no wifi, just ethernet. So I went through the “particle setup” procedure again but skipped the wifi scanning step and it prompted me for manual information - wish I’d known that was an option. I entered my wifi credentials and now my Photon is breathing cyan again. So I appear to be back where I started, I hope I did not inadvertently mess up the device name because I pressed a wrong key trying to skip the naming step.
…
Now I just flashed my Photon using the Web IDE (because I didn’t want to risk changing modes from breathing cyan) with the “Flash An LED” program, it is is working as expected. In other words, problem seems solved.
So it seems the original problem has gone away, whatever it was. The original problem may have been I was compiling to the wrong platform. Then through comedy of errors, Photon firmware was crippled and Photon wifi disabled. Then because on desktop pc with no wifi, all my setup/doctor attempts failed at the “Scan for wifi” step.
Always hard to troubleshoot a system as an outsider guessing at what stuff means and how the system works. But glad to get at least to this point. Now to continue with other programs, probably will have more questions up ahead.
That's why I always refuse any offer of these tools to do anything for me automagically.
I'd rather do things manually because then I know what is done how and when
And whenever I can I advise others to do the same thing.
I guess there was a [Y,n] part which I would have opted of No