Skip to content

NANO130: Fix test failures with tickless from lp_ticker #12604

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

Merged

Conversation

ccli8
Copy link
Contributor

@ccli8 ccli8 commented Mar 10, 2020

Summary of changes

This PR tries to fix test failures, most related to tickless from lp_ticker mode:

  1. Fix events-queue test failure due to low CPU frequency and no cache on this target.
  2. Fix mbed_hal-stack_size_unification test failure due to inconsistent main stack size configuration.
  3. Fix watchdog and reset test failures due to too short timeout in BSP driver CLK_WaitClockReady(...).

Pull request type

[s] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

@ciarmcom ciarmcom requested review from Ronny-Liu and a team March 10, 2020 06:00
@ciarmcom
Copy link
Member

@ccli8, thank you for your changes.
@Ronny-Liu @ARMmbed/mbed-os-core @ARMmbed/mbed-os-test @ARMmbed/mbed-os-hal @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@0xc0170 0xc0170 left a comment

Choose a reason for hiding this comment

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

The rest looks fine, just that test fix should be made generic

@@ -283,7 +283,12 @@ int timeleft_events[2];
void check_time_left(EventQueue *queue, int index, int expected)
{
const int event_id = timeleft_events[index];
#if defined(TARGET_NANO100)
/* Enlarge tolerance due to low CPU frequency and no cache */
TEST_ASSERT_INT_WITHIN(4, expected, queue->time_left(event_id));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be based on sys clock rather? What is the value for NANO100 ? We should not have this ifdef target in tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NANO100 runs at 48MHz and has no cache. The tolerance is just empirical. Do you have idea to improve this code?

Copy link
Contributor

@0xc0170 0xc0170 Mar 19, 2020

Choose a reason for hiding this comment

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

using SystemCoreClock and make the tolerance based on its value

mbed_platform/atomic test does it for instance , or maybe better approach is to add tolerance. Like our flash tests do.

#define ALLOWED_DRIFT_PPM   (1000000/5000)    //0.5%

void flash_clock_and_cache_test()
{
    const int timer_diff_end = time_cpu_cycles(TEST_CYCLES);
    const int acceptable_range = timer_diff_start / (ALLOWED_DRIFT_PPM);
    TEST_ASSERT_UINT32_WITHIN(acceptable_range, timer_diff_start, timer_diff_end);
}

Copy link
Contributor Author

@ccli8 ccli8 Mar 20, 2020

Choose a reason for hiding this comment

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

@0xc0170 Thanks for your sample. Changed the tolerance policy: for higher CPU frequency (80MHz or above), tolerance is fixed to 2ms as original; for lower CPU frequency (below 80MHz), tolerance is enlarged to inversely proportional to CPU frequency.

ccli8 added 3 commits March 20, 2020 10:26
Most code doesn't check return code of CLK_WaitClockReady(...). Enlarge timeout to meet most cases.

lp_ticker initialization fails with this issue. Steps for reproducing:
1.  System runs in tickless from lp_ticker mode.
2.  Arm WDT reset.
3.  In next reset cycle, lp_ticker initialization fails (active flag doesn't become active).
NANO130 doesn't re-configure rtos.main-thread-stack-size, so keep EXPECTED_MAIN_THREAD_STACK_SIZE as normal.
@ccli8 ccli8 force-pushed the nuvoton_nano130_tickless_lpticker branch from 106ffd3 to c3473e4 Compare March 20, 2020 05:10
@mergify mergify bot dismissed 0xc0170’s stale review March 20, 2020 05:11

Pull request has been modified.

@mergify mergify bot added needs: CI and removed needs: review labels Mar 23, 2020
@0xc0170 0xc0170 removed request for a team March 23, 2020 19:05
@0xc0170
Copy link
Contributor

0xc0170 commented Mar 23, 2020

CI started

@ARMmbed/mbed-os-hal Can you review test change?

@mbed-ci
Copy link

mbed-ci commented Mar 24, 2020

Test run: FAILED

Summary: 1 of 6 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test

@mergify mergify bot added needs: work and removed needs: CI labels Mar 24, 2020
@adbridge
Copy link
Contributor

Failures look unrelated so restarting CI

@mergify mergify bot added needs: CI and removed needs: work labels Mar 27, 2020
@mbed-ci
Copy link

mbed-ci commented Mar 27, 2020

Test run: FAILED

Summary: 1 of 6 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 30, 2020

Test restarted

@0xc0170
Copy link
Contributor

0xc0170 commented Mar 31, 2020

CI restarted

@mbed-ci
Copy link

mbed-ci commented Apr 1, 2020

Test run: SUCCESS

Summary: 6 of 6 test jobs passed
Build number : 3
Build artifacts

@0xc0170 0xc0170 merged commit f03860a into ARMmbed:master Apr 1, 2020
@mergify mergify bot added release version missing When PR does not contain release version, bot should label it and we fix it afterwards and removed ready for merge labels Apr 1, 2020
@mergify
Copy link

mergify bot commented Apr 1, 2020

This PR does not contain release version label after merging.

@0xc0170 0xc0170 added release-version: 6.0.0 release-version: 6.0.0-beta-1 and removed release version missing When PR does not contain release version, bot should label it and we fix it afterwards release-version: 6.0.0 labels Aug 23, 2021
@cyliangtw cyliangtw deleted the nuvoton_nano130_tickless_lpticker branch March 9, 2023 06:54
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.

5 participants