We have device OS 0.6.3 running and we are trying to upgrade to 1.4.4 capable Firmware but we have observed that multiple devices (~10% of 800) simply ignore the flash request even though sending command receives positive acknowledgement.
I was wondering if particle can guide us and show us the path forward as to why this is happening and help us diagnose the problem.
Your application is most likley not giving enough time to DeviceOS. You probably have a tight loop that is not calling any DeviceOS functions that yield’s. In these areas of the code call Particle.process().
I hadn’t thought about network thread not being yielded to by the app thread, which is something I will take a look into right away, and report to you.
Meanwhile, i was wondering if you can comment on my current understanding of what is happening : currently, the device is showing online on particle’s dashboard and makes posts to our AWS back-end servers and yet ignoring the flash commands, because all of the functionalities are happening on app thread, and not yielding to network threads long enough to full fill its task? the reason posts/mqtt is working because message buffers are small and/or are able to cycle fast enough.
Just to confirm what I understand as we do have the threads decoupled as we have
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
and we manually call Particle.process(), we are getting caught up somewhere in the loop and NOT getting to particle.process() in due time (1ms - 10ms) to process the call?
I agree with @ScruffR, calling Particle.process() every two seconds is too slow.
From your comments, it sounds like you are a unsure as to what is happening timing wise. Suggest you log each call to process() and log each time loop() is entered.
If loop() is being called too slowly, this will explain why you need to manually call process() as well.
Beware! It is possible to call Particle.process() too quickly as well, this can cause buffer overflows I believe.
This is the first time I've heard about that
Also with SYSTEM_THREAD(ENABLED) there should be no need for Particle.process() at all (unless thread switching is blocked via code)
FreeRTOS will perform a thread switch every 1ms irrespective of the running code unless it’s explicitly blocked via SINGLE_THREADED_BLOCK, ATOMIC_BLOCK or noInterrupt() or some kind of dead lock situation.
BTW, you can have a while(1) Particle.process(); whithout any issue even with Particle.variable() still being serviced.
@amoghjain, I understand that you have manually checked the code to find… but, did you actually log the calls to see if what is actually happening is what you expect?
Am interested to see how often loop() is being called.
My understanding is that you can’t flash your code reliably, ie the problem still exists.
Sure, you could remove the calls to Particle.Process() - it is easier to perform the experiment than theorising what might happen!