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

STM32F3 - Add low power timer #2650

Merged
merged 2 commits into from
Sep 22, 2016
Merged

STM32F3 - Add low power timer #2650

merged 2 commits into from
Sep 22, 2016

Conversation

svastm
Copy link
Contributor

@svastm svastm commented Sep 8, 2016

This PR add a low power timer implementation for STM32F3 targets. It also protect hal_tick from multiple init. (it was reset after a wake up from deepsleep)

Concern:

  • NUCLEO_F302R8
  • NUCLEO_F303K8
  • NUCLEO_F303R8
  • NUCLEO_F334R8
  • DISCO_F334C8
  • DISCO_F303VC

Results

  • The 1s lp_ticker deepsleep tests do not pass because on ST targets the us_timer is stopped during deepsleep but I manually checked the timing with a oscilloscope and I measured 1.00104s (at least with the NUCLEO_F303RE).

    Even if it can give us some false positives, we could change the test to use lp_ticker_read() instead of us_ticker_read(). The lp_ticker_read() and lp_ticker_set_interrupt() are already tested by the other tests.
    @bulislaw I can add a commit, just let me now if you agree.

  • This is failing on GCC due to this issue GCC - hardfault in mktime with irq disabled #2647


Tests

  • ARM
 +-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target            | platform_name | test suite                            | test case                           | passed | failed | result | elapsed_time (sec) |
+-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.05               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from deepsleep | 0      | 1      | FAIL   | 0.0                |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.06               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 500us LowPowerTimeout               | 1      | 0      | OK     | 0.05               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 5sec LowPowerTimeout                | 1      | 0      | OK     | 5.05               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1ms lp_ticker                       | 1      | 0      | OK     | 0.04               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker                        | 1      | 0      | OK     | 1.05               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker deepsleep              | 0      | 1      | FAIL   | 0.0                |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker sleep                  | 1      | 0      | OK     | 1.04               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 500us lp_ticker                     | 1      | 0      | OK     | 0.04               |
| NUCLEO_F303RE-ARM | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 5s lp_ticker                        | 1      | 0      | OK     | 5.04               |
+-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
+-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target            | platform_name | test suite                            | test case                           | passed | failed | result | elapsed_time (sec) |
+-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.04               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from deepsleep | 0      | 1      | FAIL   | 0.0                |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.05               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 500us LowPowerTimeout               | 1      | 0      | OK     | 0.05               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 5sec LowPowerTimeout                | 1      | 0      | OK     | 5.01               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1ms lp_ticker                       | 1      | 0      | OK     | 0.04               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker                        | 1      | 0      | OK     | 1.03               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker deepsleep              | 0      | 1      | FAIL   | 0.0                |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker sleep                  | 1      | 0      | OK     | 1.04               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 500us lp_ticker                     | 1      | 0      | OK     | 0.04               |
| NUCLEO_F303K8-ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 5s lp_ticker                        | 1      | 0      | OK     | 5.0                |
+-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
  • GCC_ARM
 +-----------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+---------+--------------------+
| target                | platform_name | test suite                            | test case                           | passed | failed | result  | elapsed_time (sec) |
+-----------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+---------+--------------------+
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1ms LowPowerTimeout                 | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout                | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from deepsleep | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from sleep     | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 500us LowPowerTimeout               | 0      | 0      | ERROR   | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_drivers-lp_timeout | 5sec LowPowerTimeout                | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1ms lp_ticker                       | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker                        | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker deepsleep              | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker sleep                  | 0      | 0      | SKIPPED | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 500us lp_ticker                     | 0      | 0      | ERROR   | 0.0                |
| NUCLEO_F303K8-GCC_ARM | NUCLEO_F303K8 | mbed-os-tests-mbed_hal-lp_ticker      | 5s lp_ticker                        | 0      | 0      | SKIPPED | 0.0                |
+-----------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+---------+--------------------+
  • IAR
 +-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| target            | platform_name | test suite                            | test case                           | passed | failed | result | elapsed_time (sec) |
+-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1ms LowPowerTimeout                 | 1      | 0      | OK     | 0.05               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout                | 1      | 0      | OK     | 1.05               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from deepsleep | 0      | 1      | FAIL   | 0.0                |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 1sec LowPowerTimeout from sleep     | 1      | 0      | OK     | 1.06               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 500us LowPowerTimeout               | 1      | 0      | OK     | 0.05               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_drivers-lp_timeout | 5sec LowPowerTimeout                | 1      | 0      | OK     | 5.05               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1ms lp_ticker                       | 1      | 0      | OK     | 0.03               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker                        | 1      | 0      | OK     | 1.03               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker deepsleep              | 0      | 1      | FAIL   | 0.0                |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 1s lp_ticker sleep                  | 1      | 0      | OK     | 1.05               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 500us lp_ticker                     | 1      | 0      | OK     | 0.04               |
| NUCLEO_F303RE-IAR | NUCLEO_F303RE | mbed-os-tests-mbed_hal-lp_ticker      | 5s lp_ticker                        | 1      | 0      | OK     | 5.04               |
+-------------------+---------------+---------------------------------------+-------------------------------------+--------+--------+--------+--------------------+

Edit: I use the wake up timer (instead of alarm in the current F0 implementation) because it make the handle of timestamp overflow easier and the accuracy is equivalent.

@bulislaw
Copy link
Member

bulislaw commented Sep 8, 2016

Even if it can give us some false positives, we could change the test to use lp_ticker_read() instead of us_ticker_read(). The lp_ticker_read() and lp_ticker_set_interrupt() are already tested by the other tests.
@bulislaw I can add a commit, just let me now if you agree.

Can we do it just for the deepsleep tests (with comment that us_ticker may be switched off), just so we don't test lp_ticker using lp_ticker for all cases.

@svastm
Copy link
Contributor Author

svastm commented Sep 8, 2016

That is the idea. I tried this option but I still have some trouble with the automatic test because there is no check of the end of serial transmit before entering in deepsleep mode.

[1473350134.37][CONN][RXD] >>> '1sec LowPowerTimeout from sleep': 1 passed, 0 failed
[1473350134.43][CONN][RXD] >>> Running case #6: '1sec LowPowerTimeout from deepsleep'...
[1473350135.56][CONN][RXD] {{__testcase_start;1sec LowPowerTimeout from deepsleep} _í»»§Eò═Ðìà═ò}ÖÑ╣Ñ═íÝ1sec LowPowerTimeout from deepsleep;1;0}}
[1473350135.62][CONN][RXD] >>> '1sec LowPowerTimeout from deepsleep': 1 passed, 0 failed
[1473350135.66][CONN][RXD] >>> Test cases: 6 passed, 0 failed
[1473350135.68][CONN][RXD] {{max_heap_usage;0}}
[1473350135.68][CONN][INF] found KV pair in stream: {{max_heap_usage;0}}, queued...
[1473350135.68][HTST][ERR] orphan event in main phase: {{max_heap_usage;0}}, timestamp=1473350135.683000
[1473350135.71][CONN][RXD] {{__testcase_summary;6;0}}
[1473350135.71][CONN][INF] found KV pair in stream: {{__testcase_summary;6;0}}, queued...
[1473350135.72][CONN][RXD] {{end;success}}
[1473350135.72][CONN][INF] found KV pair in stream: {{end;success}}, queued...
[1473350135.73][HTST][INF] __notify_complete(True)
[1473350135.73][HTST][INF] test suite run finished after 9.73 sec...
[1473350135.73][CONN][INF] received special even '__host_test_finished' value='True', finishing
[1473350135.73][HTST][INF] CONN exited with code: 0
[1473350135.73][HTST][INF] No events in queue
[1473350135.73][HTST][INF] stopped consuming events
[1473350135.73][HTST][INF] host test result() call skipped, received: True
[1473350135.73][HTST][WRN] missing __exit event from DUT
[1473350135.73][HTST][INF] calling blocking teardown()
[1473350135.73][HTST][INF] teardown() finished
[1473350135.73][HTST][INF] {{result;success}}
mbedgt: checking for GCOV data...
mbedgt: mbed-host-test-runner: stopped and returned 'OK'
mbedgt: test on hardware with target id: 0745020000668E303F031848
mbedgt: test suite 'mbed-os-tests-mbed_drivers-lp_timeout' ........................................... OK in 18.90 sec
        test case: '1ms LowPowerTimeout' ............................................................. OK in 0.05 sec
        test case: '1sec LowPowerTimeout' ............................................................ OK in 1.04 sec
        test case: '1sec LowPowerTimeout from deepsleep' ............................................. SKIPPED in 0.00 sec
        test case: '1sec LowPowerTimeout from sleep' ................................................. OK in 1.06 sec
        test case: '500us LowPowerTimeout' ........................................................... OK in 0.05 sec
        test case: '5sec LowPowerTimeout' ............................................................ OK in 5.05 sec
mbedgt: test case summary: 6 passes, 0 failures
mbedgt: utest test case summary mismatch: utest reported passes and failures miscount!
        reported by utest: passes = 6, failures 0)
        test case result count: passes = 5, failures 1)
mbedgt: all tests finished!

So the test pass but the dummy characters make it fail. However, I opened a PR for that #2651.

@bogdanm
Copy link
Contributor

bogdanm commented Sep 9, 2016

I'd wait for #2651 to be merged first.

@sg-
Copy link
Contributor

sg- commented Sep 9, 2016

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@sg- sg- added needs: work and removed needs: CI labels Sep 9, 2016
@sg-
Copy link
Contributor

sg- commented Sep 9, 2016

@svastm needs a rebase

@mbed-bot
Copy link

[Build 900]
FAILURE: Something went wrong when building and testing.

@svastm
Copy link
Contributor Author

svastm commented Sep 12, 2016

rebased

@bogdanm
Copy link
Contributor

bogdanm commented Sep 12, 2016

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@mbed-bot
Copy link

[Build 908]
FAILURE: Something went wrong when building and testing.

@sg-
Copy link
Contributor

sg- commented Sep 12, 2016

/morph test

@mbed-bot
Copy link

Result: SUCCESS

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

/morph test

Output

mbed Build Number: 834

All builds and test passed!

@svastm
Copy link
Contributor Author

svastm commented Sep 14, 2016

I rebase because i forgot to include rtc_api_hal.h in sleep.c.
This should remove a warning.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 14, 2016

/morph test

@mbed-bot
Copy link

Result: SUCCESS

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

/morph test

Output

mbed Build Number: 864

All builds and test passed!

@svastm
Copy link
Contributor Author

svastm commented Sep 16, 2016

Rebase again. I remove the last commit which avoid multiple init of HAL_tick. This implementation could cause some errors if you need to call twice HAL_Osc_Init to init the clock. Also, for now the us_timer is reset if you enter in deepsleep.

@sg-
Copy link
Contributor

sg- commented Sep 16, 2016

@svastm could you rebase and resolve conflicts?

@svastm
Copy link
Contributor Author

svastm commented Sep 19, 2016

rebased

Enable the low power timer for the following targets:
 - NUCLEO_F302R8
 - NUCLEO_F303K8
 - NUCLEO_F303RE
 - NUCLEO_F334R8
 - DISCO_F334C8
 - DISCO_F303VC
@sg- sg- merged commit 28013dd into ARMmbed:master Sep 22, 2016
aisair pushed a commit to aisair/mbed that referenced this pull request Apr 30, 2024
Ports for Upcoming Targets

2669: Added u-blox C029 target ARMmbed/mbed-os#2669
2707: [EFM32] Add IAR support for remaining Silicon Labs targets ARMmbed/mbed-os#2707
2819: MultiTech xDot platform support - 09.26.2016 ARMmbed/mbed-os#2819
2827: include MultiTech xDot in mbed 5 releases ARMmbed/mbed-os#2827

Fixes and Changes

2522: Add CThunk for CM7 ARMmbed/mbed-os#2522
2518: Enable uvisor on Beetle ARMmbed/mbed-os#2518
2571: STM32F7 - Add asynchronous serial ARMmbed/mbed-os#2571
2616: STM32F3xx - Add Serial Flow Control pins + enable it ARMmbed/mbed-os#2616
2619: NUCLEO_L152RE - Add Serial Flow Control ARMmbed/mbed-os#2619
2620: NUCLEO_F429ZI - Add SERIAL_FC macro ARMmbed/mbed-os#2620
2666: [EFM32] Microsecond ticker optimization ARMmbed/mbed-os#2666
2681: STM32F0xx - Add support of ADC internal channels ARMmbed/mbed-os#2681
2687: [NRF5] Add fs_data symbol in data secton for gcc ARMmbed/mbed-os#2687
2696: Add device_has to all nrf51 devices ARMmbed/mbed-os#2696
2703: TARGET_NRF5: Changed 'serial_baud' implementation to support special baud rates. ARMmbed/mbed-os#2703
2704: DISCO_L476VG: add SPI nicknames ARMmbed/mbed-os#2704
2723: KSDK serial_api.c: Fix assertion error for ParityEven ARMmbed/mbed-os#2723
2463: [STM32L0] Add asynchronous serial ARMmbed/mbed-os#2463
2572: Fix STM32F407VG target name and LPC11U6X linker errors ARMmbed/mbed-os#2572
2698: DELTA_DFBM_NQ620 target ARMmbed/mbed-os#2698
2542: Dev spi asynch stm32f4 ARMmbed/mbed-os#2542
2650: STM32F3 - Add low power timer ARMmbed/mbed-os#2650
2415: [STM32F0] Add asynchronous serial ARMmbed/mbed-os#2415
2585: Added support for ADC only pins in LPC43xx ARMmbed/mbed-os#2585
2622: [STM32F4] Add asynchronous I2C ARMmbed/mbed-os#2622
2719: Updated ARM linker scripts for Kinetis platforms that use SDK 2.0 ARMmbed/mbed-os#2719
2728: Added ethernet and enabled IPV4 feature for the EVK-ODIN-W2/C029 target ARMmbed/mbed-os#2728
2747: [LPC11U68] Fix pin interrupt select offset ARMmbed/mbed-os#2747
2751: STM32L0xx - Add Serial Flow Control ARMmbed/mbed-os#2751
2753: [NUCLEO_F767ZI] Add CAN capability ARMmbed/mbed-os#2753
2759: STM32F0 - Add low power timer ARMmbed/mbed-os#2759
2763: STM32L1 - Add low power timer ARMmbed/mbed-os#2763
2764: STM32L4 - Add low power timer ARMmbed/mbed-os#2764
2771: STM32L4 - Update deepsleep implementation ARMmbed/mbed-os#2771
2775: Update KSDK SDHC driver for K64F & K66F ARMmbed/mbed-os#2775
2792: [NUCLEO_F303ZE] MBED-OS5 capability ARMmbed/mbed-os#2792
2762: STM32L0 - Add low power timer ARMmbed/mbed-os#2762
2761: STM32F7 - Add low power timer ARMmbed/mbed-os#2761
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.

6 participants