Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LTE/Electron] Fixes software Timer()'s halting after millis() overflows (every 49.7 days) #1688

Merged
merged 1 commit into from Feb 4, 2019

Conversation

@monkbroc
Copy link
Member

commented Feb 1, 2019

Problem

The Particle software timers aka Timer use the FreeRTOS timer feature. FreeRTOS version 8.2.2 used on the Electron introduced a bug where timers stop triggering after an overflow of the tick count, which happens after ~49 days.

Solution

Rather than upgrade the whole FreeRTOS this PR backports the bugfix from cjlano/freertos@f780d64#diff-ed9ddddbc8c65ef44735bc5950056ef7R474

Steps to Test

Steps to validate the issue and fix:

  1. Modify to trigger the timer overflow soon after boot
		xTickCount = ( TickType_t ) 0xFFFFD000U;
  1. Add the example application below as ~Downloads/timer/timer.cpp
  2. Compile and flash with modules$ make clean all -s COMPILE_LTO=n PLATFORM=electron DEBUG_BUILD=y APPDIR=~/Downloads/timer program-dfu
  3. Connect to the USB serial port and see the printed numbers go from 1 to 11 then stop.
  4. Apply the changes in this PR
  5. Recompile (clean build important!) and flash
  6. Connect to the USB serial port and see the printed numbers go from 1 upwards without stopping.

Example App

#include "Particle.h"

SYSTEM_THREAD(ENABLED);

void print_every_second()
{
    static int count = 0;
    Serial.println(count++);
}

Timer timer(1000, print_every_second);

void setup()
{
    Serial.begin(9600);
    timer.start();
}

Completeness

  • User is totes amazing for contributing!
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • (N/A) Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

@monkbroc monkbroc requested a review from technobly Feb 1, 2019

@technobly technobly added the bug label Feb 4, 2019

@technobly technobly added this to the 1.0.1-rc.1 milestone Feb 4, 2019

@technobly technobly changed the title Backport the fix for the timer overflow bug introduced in FreeRTOS 8.2.2 [Photon/P1/Electron] Fixes software Timer()'s halting after millis() overflows (every 49.7 days) Feb 4, 2019

@technobly technobly changed the title [Photon/P1/Electron] Fixes software Timer()'s halting after millis() overflows (every 49.7 days) [LTE/Electron] Fixes software Timer()'s halting after millis() overflows (every 49.7 days) Feb 4, 2019

@technobly technobly force-pushed the feature/rtos-timer-overflow branch from 90e926a to 6f78c84 Feb 4, 2019

@technobly technobly merged commit 04688d4 into develop Feb 4, 2019

1 check passed

continuous-integration/travis-ci/push The Travis CI build passed
Details

@technobly technobly deleted the feature/rtos-timer-overflow branch Feb 4, 2019

@MrZANE42

This comment has been minimized.

Copy link

commented Feb 7, 2019

@technobly When did you start using FreeRTOS 8.2.2? Ie. What (electron) System OS versions are affected by this issue?

@hwestbrook

This comment has been minimized.

Copy link

commented Feb 25, 2019

@MrZANE42 -- This bug looks like it exists in 0.6.1. Not sure how much further back it might go.

@jlovinger-particle

This comment has been minimized.

Copy link

commented Feb 25, 2019

The version of FreeRTOS with this bug was introduced to the repo on 9/22/2015 in the following commit.

ba342c3

Based on the timing (didn't test personally) looks like everything from 0.4.6 onwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.