-
Notifications
You must be signed in to change notification settings - Fork 3k
Correct SysTimer absolute time calculations #12326
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
Conversation
`SysTimer::set_wake_time` incorrectly assumed that the `SysTimer`s tick count and the underlying HAL timer had the same zero base. This normally holds, at least approximately, in RTOS builds where the HAL timer starts from zero at the same time the SysTimer is initialised. But in bare metal builds, the HAL timer could be started some time before the SysTimer, giving a significant discrepancy. Beyond that, there's no requirement for HAL timers to start from zero in the spec. Record the HAL timer start time to get the conversion right.
|
@kjbracey-arm, thank you for your changes. |
mprse
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good. Thanks for helping with this one.
Tests in the bare metal mode now pass! Results can be found below:
$ mbed test -m K64F -t GCC_ARM --app-config TESTS/configs/baremetal.json -n tests-mbed_drivers-lp_ticker -v
| target | platform_name | test suite | result | elapsed_time (sec) | copy_method |
|--------------|---------------|------------------------------|--------|--------------------|-------------|
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | OK | 20.66 | default |
mbedgt: test suite results: 1 OK
mbedgt: test case report:
| target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) |
|--------------|---------------|------------------------------|-------------------------------------------|--------|--------|--------|--------------------|
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach for 0.001s and time measure | 1 | 0 | OK | 0.06 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach for 0.01s and time measure | 1 | 0 | OK | 0.08 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach for 0.1s and time measure | 1 | 0 | OK | 0.17 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach for 0.5s and time measure | 1 | 0 | OK | 0.55 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach_us for 100ms and time measure | 1 | 0 | OK | 0.16 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach_us for 10ms and time measure | 1 | 0 | OK | 0.07 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach_us for 1ms and time measure | 1 | 0 | OK | 0.08 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test attach_us for 500ms and time measure | 1 | 0 | OK | 0.58 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test detach | 1 | 0 | OK | 0.74 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test multi call and time measure | 1 | 0 | OK | 1.06 |
| K64F-GCC_ARM | K64F | tests-mbed_drivers-lp_ticker | Test multi ticker | 1 | 0 | OK | 0.27 |
mbedgt: test case results: 11 OK
$ mbed test -m K64F -t GCC_ARM --app-config TESTS/configs/baremetal.json -n tests-mbed_hal-rtc -v
| target | platform_name | test suite | result | elapsed_time (sec) | copy_method |
|--------------|---------------|--------------------|--------|--------------------|-------------|
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | OK | 56.87 | default |
mbedgt: test suite results: 1 OK
mbedgt: test case report:
| target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) |
|--------------|---------------|--------------------|------------------|--------|--------|--------|--------------------|
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - accuracy | 1 | 0 | OK | 9.73 |
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - enabled | 1 | 0 | OK | 0.04 |
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - glitch | 1 | 0 | OK | 3.65 |
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - init | 1 | 0 | OK | 0.03 |
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - persist | 1 | 0 | OK | 4.05 |
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - range | 1 | 0 | OK | 16.04 |
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - sleep | 1 | 0 | OK | 8.06 |
| K64F-GCC_ARM | K64F | tests-mbed_hal-rtc | RTC - write/read | 1 | 0 | OK | 0.06 |
mbedgt: test case results: 8 OK
$ mbed test -m NRF52840_DK -t GCC_ARM --app-config TESTS/configs/baremetal.json -n tests-mbed_drivers-lp_ticker -v
| target | platform_name | test suite | result | elapsed_time (sec) | copy_method |
|---------------------|---------------|------------------------------|--------|--------------------|-------------|
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | OK | 24.65 | default |
mbedgt: test suite results: 1 OK
mbedgt: test case report:
| target | platform_name | test suite | test case | passed | failed | result | elapsed_time (sec) |
|---------------------|---------------|------------------------------|-------------------------------------------|--------|--------|--------|--------------------|
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach for 0.001s and time measure | 1 | 0 | OK | 0.08 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach for 0.01s and time measure | 1 | 0 | OK | 0.09 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach for 0.1s and time measure | 1 | 0 | OK | 0.16 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach for 0.5s and time measure | 1 | 0 | OK | 0.57 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach_us for 100ms and time measure | 1 | 0 | OK | 0.16 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach_us for 10ms and time measure | 1 | 0 | OK | 0.07 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach_us for 1ms and time measure | 1 | 0 | OK | 0.06 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test attach_us for 500ms and time measure | 1 | 0 | OK | 0.57 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test detach | 1 | 0 | OK | 0.74 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test multi call and time measure | 1 | 0 | OK | 1.06 |
| NRF52840_DK-GCC_ARM | NRF52840_DK | tests-mbed_drivers-lp_ticker | Test multi ticker | 1 | 0 | OK | 0.28 |
mbedgt: test case results: 11 OK
Approved.
evedon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent! Thanks kevin.
|
CI started |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
|
This PR does not contain release version label after merging. |
|
I've fixed the version: Set to 6.0.0-alpha-2 |
Summary of changes
SysTimer::set_wake_timeincorrectly assumed that theSysTimers tick count and the underlying HAL timer had the same zero base. This normally holds, at least approximately, in RTOS builds where the HAL timer starts from zero at the same time the SysTimer is initialised.But in bare metal builds, the HAL timer could be started some time before the SysTimer, giving a significant discrepancy.
Beyond that, there's no requirement for HAL timers to start from zero in the spec.
Record the HAL timer start time to get the conversion right.
Fixes #12313
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results
Reviewers
@mprse