I am having a problem with the photon when using the develop branch. I am using that branch, because I want to flash locally. It works pretty well, except for two things: When the develop branch is used, then it does not startup after powering up. I have to reset the board using the reset button, then it works fine.
Most probably connected: The board does not wakeup from deep sleep mode, when using that branch. It works fine when I use a board which uses the official firmware as flashed when using the web IDE.
Also a question: After waking up from deep sleep it takes roughly 2-3 seconds in which the RGB led shines white, until the user program starts. This is wasteful, because at that time the LED is using energy and of course it takes time until the photon is in deep sleep again. What is done during that time? Can I somehow suppress this?
I am trying to do a battery powered device which wakes up every minute, makes a measurement, sends that through to a web server and then falls asleep again. It should run for a long time with a battery. So any overhead as described is waster.
I have seen this too and am trying to resolve the issue - more datapoints would be great. Does this happen on every power up, or just on a cold start (unpowered for more than 30s.)
We could perhaps make the default brightness for the LED persistent so that you can set the brightness setting before going to deep sleep. On wakeup from deep sleep the system goes through it's startup procedure, initializing memory, peripherals, initializing WICED libraries etc.
For now, you could try to turn the LED off early (before setup is called), by adding this code to your application:
I’ve added an issue to our backlog to make this configurable at runtime, since it’s mainly a development tool for quickly loading firmware via DFU/Serial without having to touch any buttons on the device.
Does seem to speed startup, but probably impossible for me to really tell. Commenting out this line has no other side effects than the elimination of buttonless flash?
@mdma I am running into this issue too but recloning the develop branch and commenting out the line in main.cpp does not fix it.
Here is the simple loop I am running
#include "application.h"
SYSTEM_MODE(MANUAL);
void setup()
{
}
void loop()
{
int i = 0;
while (i < 5)
{ //flash external led
pinMode(D5, OUTPUT);
digitalWrite(D5, HIGH);
delay(500);
pinMode(D5, INPUT);
delay(500);
i++;
}
System.sleep(SLEEP_MODE_DEEP, 2);
}
What I am seeing is the device never wakes from sleep. I though this was an only occasional cold restart problem but I find now it always happens after sleep.
I know I have tested deep sleep before with success. I think the testing must have been with a compile in the cloud
My guess is some register that is used with the wdt is set incorrectly?
Commenting out that line is a speed up, not a fix for deep sleep.
I'll try the code example and report back.
time passes
When I run the code I find it doesn't wake up automatically. The docs indicate this should be supported, although something in the back of my mind says Deep Sleep is woken up only by the WKP pin. @satishgn will be able to affirm the expected behavior.
I just rebuilt the latest develop branch and flashed all the modules and now the example above is working - the photon comes out of deep sleep after 2 seconds.
thanks for the very fast response. I just tried it as well and it works like a charm, now. Great work! The photon does wake up after a power up and it also wakes from the deep sleep. And yes, it was always after a cold start, that the problem appeared. I did not really expect a cold start to only happen after 30 seconds without power. Out of curiosity: what is still running more than 20 seconds without power???
With the code to turn off the LED, it turns off a second earlier, after about 1 second instead of 2-3. That’s a good improvement.
Turning off the auto firmware update does not really help. I could not really make out a difference. But in any case, being able to turn off the auto firmware update would also be a good feature, so that you cannot reprogram by just putting in a USB cable.
Still I am suprised that the startup is relatively slow even with the manual mode. Most other MCU start up faster. So I would think that looking into that would still be worthwhile.
Do you have figures for other wifi-enabled devices for comparison?
The WiFI module is initialized also on startup. 240k of data is transferred over the internal bus. In time we may be able to optimize this so that it's done lazily on demand when the wifi module is actually required, rather than doing it eagerly.
All the code is in hal/src/photon/wlan_hal.c if you want to have a go at doing this yourself.
Okay, that makes sense. I compared it to non-Wifi devices, assuming that the initialization is done lazily.
I must admit that I still have some difficulty navigating the code base, especially the division into Core, Photon, and Electron is not too clear for me - yet. So the pointer to the wlan_hal.c is appreciated. I will experiment a bit myself.
Then copied my application into my directory at user/applications/photon and set the device to DFU mode again and ran the following.
cd\spark\firmware\main
make clean all PLATFORM=photon APP=photon program-dfu
Still never exits sleep unless I press the reset button. The Photon is in a breadboard with no other circuit than power & gnd as well as the external led between D5 and gnd
This is very odd that it works for you guys and not me?
I see the problem. You aren’t updating the system modules with this approach. In modules, you need to run all program-dfu so the modules are flashed to the device. As is, you are only building them, not flashig them.
It’s also not necessary to have the core-common-lib and core-communication-lib repos. Please be sure to read the readme.md in the develop branch, and the build docs that are linked, particularly the section Updating system firmware.