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

Fixing lp ticker and sleep manager tests #5063

Merged
merged 7 commits into from
Sep 11, 2017

Conversation

0xc0170
Copy link
Contributor

@0xc0170 0xc0170 commented Sep 9, 2017

Couple of fixes here:

  • lp ticker - use Timer to wait (this will however need more investigation with wait_ms as it should work, I'll create a tracking issue for this, this should be the functionally same affect for this test)
  • sleep manager - decrease the stack for Threads as the default one is too big for the test purposes (out of memory for small targets)

See failures: #4987 (comment)

Whats left to do - nrf52 critical section - seems like the critical section does not work, look at sleep manager race condition. It fails. This is interesting as we have some race conditions tests, for instance also for threads. I'll review the test again, are we using it correctly, and the bug is in nordic implementation of critical section, as the rest of platforms are fine (using default implementation of critical section)
cc @nvlsianpu @anangl @pan- Any suggestions, fixes welcome !

This will require nightly as its fixing some tests.

@c1728p9 @bulislaw @sg-

@0xc0170
Copy link
Contributor Author

0xc0170 commented Sep 9, 2017

/morph test-nightly

@mbed-bot
Copy link

mbed-bot commented Sep 9, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1265

Build failed!

@0xc0170
Copy link
Contributor Author

0xc0170 commented Sep 9, 2017

/morph test-nightly

@@ -37,8 +39,8 @@ void sleep_manager_multithread_test()
{
{
Callback<void()> cb(sleep_manager_locking_thread_test);
Thread t1;
Thread t2;
Thread t1(osPriorityNormal, TEST_STACK_SIZE);
Copy link
Contributor Author

@0xc0170 0xc0170 Sep 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this multithreaded test should be guarded by MBED_RTOS_SINGLE_THREAD . I am looking at what this macro is changing, and found only tests that use it and then toolchains python files that define it. Pointers?

It seems to me that we removed this macro from rtos code base (even if this macro is set, you can create multiple threads?), as previously it set task count to 1 as I recall, or not?

@0xc0170
Copy link
Contributor Author

0xc0170 commented Sep 9, 2017

I pushed a small update

  • Ticker - callback invoke only if attached
  • drivers lp timer - use also Timer for waiting loop

@0xc0170
Copy link
Contributor Author

0xc0170 commented Sep 9, 2017

Whats left to do - nrf52 critical section - seems like the critical section does not work, look at sleep manager race condition. It fails. This is interesting as we have some race conditions tests, for instance also for threads. I'll review the test again, are we using it correctly, and the bug is in nordic implementation of critical section, as the rest of platforms are fine (using default implementation of critical section)
cc @nvlsianpu @anangl @pan- Any suggestions, fixes welcome !

This is now outdated, latest master test shows this OK :-) I am not certain what has happened previously in the CI :-) We will keep you updated if anything new with this.

@mbed-bot
Copy link

mbed-bot commented Sep 9, 2017

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1266

Test failed!

0xc0170 and others added 5 commits September 9, 2017 20:42
Decrease the default stack size as it's not needed for purposes of testing.
Lock deep sleep before calling sleep to prevent the device from
entering deep sleep mode.
Increase the Timeout period from 1ms to 10ms so interrupt latency has
1/10th the effect on the measurement. This prevents failures due to
interrupt latency causing a drift.
The NCS36510 is not suitable for tickless, since its LP ticker cannot
be scheduled fast enough. This is because it takes four 32KHz clock
cycles before these writes take effect - ~120us.
@c1728p9
Copy link
Contributor

c1728p9 commented Sep 10, 2017

/morph test-nightly

@c1728p9
Copy link
Contributor

c1728p9 commented Sep 10, 2017

I updated this PR by doing the following:

  • Removed the commit "lp ticker tests: fix timeout usage" since alternative fix was found - "Prevent deeps sleep in regular sleep test case"
  • Fixed Timeout test failure on nrf51
  • Turned off tickless for NCS36510 since this device doesn't meet the hardware requirements (at least with the RTC)

I also confirmed that the NRF52 was failing testing earlier due a task switch (SysTick) during a critical section. Additionally, I can confirm that the Tickless fixes this problem since SysTick never triggers an interrupt.

@0xc0170
Copy link
Contributor Author

0xc0170 commented Sep 10, 2017

👍 Changes look good to me, thanks for the update

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1268

Test failed!

c1728p9 and others added 2 commits September 10, 2017 17:06
The lp_ticker test overrides the default ticker handler for the
low power ticker. This stops all other low power TimerEvents in the
system, including the ones for tickless, from getting called. Because
of this devices with tickless enabled malfunction during this test.

This patch fixes this problem by passing all lp ticker events it did
not trigger on to the TimerEvent irq handler.
Add NOPs after deep sleep to prevent unexpected behavior. It appears
that the first one or two instructions after deep sleep do not get
executed properly.

Note - This is a temporary workaround. For a more robust solution
the NCS36510 needs to investigate the root cause of this issue.
@c1728p9
Copy link
Contributor

c1728p9 commented Sep 11, 2017

@c1728p9
Copy link
Contributor

c1728p9 commented Sep 11, 2017

/morph test-nightly

1 similar comment
@studavekar
Copy link
Contributor

/morph test-nightly

Copy link
Member

@bulislaw bulislaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adbridge
Copy link
Contributor

adbridge commented Sep 11, 2017

@c1728p9 @bulislaw
Nightly failed with:

03:12:10 [1505117522.10][CONN][RXD] >>> Running case #6: '1s lp_ticker deepsleep'...
03:12:10 [1505117522.15][CONN][INF] found KV pair in stream: {{__testcase_start;1s lp_ticker deepsleep}}, queued...
03:12:23 [1505117534.33][HTST][INF] test suite run finished after 20.45 sec...
03:12:23 [1505117534.33][CONN][INF] received special even '__host_test_finished' value='True', finishing
03:12:23 [1505117534.37][HTST][INF] CONN exited with code: 0
03:12:23 [1505117534.37][HTST][INF] No events in queue
03:12:23 [1505117534.37][HTST][INF] stopped consuming events
03:12:23 [1505117534.37][HTST][INF] host test result(): None
03:12:23 [1505117534.37][HTST][WRN] missing __exit event from DUT
03:12:23 [1505117534.37][HTST][WRN] missing __exit_event_queue event from host test
03:12:23 [1505117534.37][HTST][ERR] missing __exit_event_queue event from host test and no result from host test, timeout...
03:12:23 [1505117534.37][HTST][INF] calling blocking teardown()
03:12:23 [1505117534.37][HTST][INF] teardown() finished
03:12:23 [1505117534.37][HTST][INF] {{result;timeout}}

target=NCS36510,toolchain=IAR

Any ideas ?

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1275

Test failed!

@bulislaw
Copy link
Member

We don't have this board in Cambridge, but looking at the sleep code the deeplseep is switching off external oscillator and lp ticker is implemented using RTC, I'm guessing we are switching off our wake up source...

@betzw
Copy link
Contributor

betzw commented Sep 11, 2017

Maybe it's the same as issue #5067?!?

@c1728p9
Copy link
Contributor

c1728p9 commented Sep 11, 2017

/morph test-nightly

@bulislaw
Copy link
Member

looking at the sleep code the deeplseep is switching off external oscillator and lp ticker is implemented using RTC, I'm guessing we are switching off our wake up source...

That doesn't make sense as we use standard SysTick on this platform...

@nvlsianpu
Copy link
Contributor

I also confirmed that the NRF52 was failing testing earlier due a task switch (SysTick) during a critical section. Additionally, I can confirm that the Tickless fixes this problem since SysTick never triggers an interrupt.

@c1728p9 is this a bug, right? What mean Tickless fixes the problem - Will this been fixed for all Tick modes?

@c1728p9
Copy link
Contributor

c1728p9 commented Sep 11, 2017

Hi @nvlsianpu, tickless is on unconditionally for the nrf52, so this shouldn't be a problem. The nrf5x critical section customization makes me a bit nervous though. It doesn't mask core interrupts (like SysTick) and this was why it task switched in the middle of a critical section.

@c1728p9
Copy link
Contributor

c1728p9 commented Sep 11, 2017

I pushed a commit to fix the ncs36510 failures and triggered a nightly. I opened issue #5065 earlier to track this issue.

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test-nightly

Output

mbed Build Number: 1278

All builds and test passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants