Skip to content

Documentation update on tickless mode porting guide #1337

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
merged 5 commits into from
Jun 10, 2020

Conversation

rajkan01
Copy link
Contributor

@rajkan01 rajkan01 commented Jun 3, 2020

Updated tickless mode porting guide with missing information and done some cleanup.

This PR depends on ARMmbed/mbed-os#12988


When the tickless mode is enabled, the device suspends the kernel effectively disabling the systick and sets up the [low power ticker] through [mbed::internal::OsTimer].

If the target does not feature a low power ticker or has an excessively long wake-up time, you must also set the `tickless-from-us-ticker` to true in the target's section in the `targets.json` file. In such the device will only enter sleep rather than deepsleep.
Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't we just merge a PR that meant you didn't have to set this if you don't have a low power ticker at all? It's bright enough to realise that it has to use us-ticker now. So I think you only have to set this if you have it and it doesn't work well.

Copy link
Contributor

Choose a reason for hiding this comment

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

If that PR has been merged, the "if the target does not feature a low power ticker" condition is no longer true.

How about "By default, tickless mode uses the low-power ticker if available. If a target's low-power ticker has an excessively long wake-up time, or other performance issues, you must set tickless-from-us-ticker to true in the target's section in the targets.json file to make it use the microsecond ticker instead."

Then "If tickless mode uses the microsecond ticker, the device will only enter sleep rather than deepsleep, but will still avoid unnecessary tick calls."

Copy link
Contributor

Choose a reason for hiding this comment

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

Just checked, and the PR is still pending, but ready for merge:

ARMmbed/mbed-os#12988

@rajkan01 rajkan01 force-pushed the tickless_docs_update branch 2 times, most recently from 6a9ab05 to 0aea8cd Compare June 4, 2020 11:05
Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

The "tickless" diagram isn't quite right, because it shows "SysTick" being used as the timer. All the ticks are and wakeup from idle are actually coming from "lpticker" (or "usticker").

(In principle the ticks could be SysTick and the wake from idle lpticker, so it could be hybrid, but for now it's all lpticker).


When the tickless mode is enabled, the device suspends the kernel effectively disabling the systick and sets up the [low power ticker] through [mbed::internal::OsTimer].

If the target does not feature a low power ticker or has an excessively long wake-up time, you must also set the `tickless-from-us-ticker` to true in the target's section in the `targets.json` file. In such the device will only enter sleep rather than deepsleep.
Copy link
Contributor

Choose a reason for hiding this comment

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

If that PR has been merged, the "if the target does not feature a low power ticker" condition is no longer true.

How about "By default, tickless mode uses the low-power ticker if available. If a target's low-power ticker has an excessively long wake-up time, or other performance issues, you must set tickless-from-us-ticker to true in the target's section in the targets.json file to make it use the microsecond ticker instead."

Then "If tickless mode uses the microsecond ticker, the device will only enter sleep rather than deepsleep, but will still avoid unnecessary tick calls."

@rajkan01 rajkan01 force-pushed the tickless_docs_update branch from 0aea8cd to 1554e16 Compare June 4, 2020 12:03
Copy link
Contributor

@kjbracey kjbracey left a comment

Choose a reason for hiding this comment

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

Repeating my earlier comment:

All the ticks [...] and wakeup from idle are actually coming from "lpticker" (or "usticker")

Your diagram is still showing SysTick in use for tickless.

Another minor detail - don't think it's worth putting in the diagram, but for your benefit - it can actually use two lpticker interrupts to wake from a sleep. First one brings it out of deep sleep, and it's scheduled early enough to guarantee it's not late, then it goes back to shallow sleep scheduling wakeup for the exact requested time.


If tickless mode uses the microsecond ticker, the device will only enter sleep rather than deep sleep, but will still avoid unnecessary tick calls.

*Note that using the tickless mode prevents the user from using the associated timer.*
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, never spotted this sentence. Where did it come from?

It's not true in any meaningful sense for users. There is one HAL lpticker and one HAL usticker, yes, but they are always shared by the "ticker_api" framework. The OS timing uses that same sharing mechanism along with Ticker, LowPowerTimeout etc, and doesn't interfere with their use.

You couldn't use LowPowerTicker or MBED_TICKLESS at the same time as directly calling the HAL lpticker interrupt APIs yourself, but no-one would ever attempt that, I hope.


To enable tickless mode support in Mbed OS, you need to add the `MBED_TICKLESS` macro in the macros option of the target's section in the `targets.json` file.

When the tickless mode is enabled, the device suspends the kernel effectively disabling the systick and sets up either the [low power ticker](../mbed-os-api-doxy/group__hal__lp__ticker.html) or [microsecond ticker](../mbed-os-api-doxy/group__hal__us__ticker.html) through [mbed::internal::OsTimer](../mbed-os-api-doxy/structos__timer__def.html) based on target configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

Bit wary about mentioning mbed::internal:: anything in documentation, but I guess it's a potentially useful detail for anyone debugging/maintaining the code.

@rajkan01 rajkan01 force-pushed the tickless_docs_update branch from 1554e16 to 8917702 Compare June 5, 2020 10:56
@rajkan01 rajkan01 force-pushed the tickless_docs_update branch from 8917702 to 3a9ec86 Compare June 5, 2020 11:02
@rajkan01 rajkan01 requested a review from kjbracey June 5, 2020 13:13
@iriark01 iriark01 self-assigned this Jun 8, 2020
Copy link
Contributor

@evedon evedon left a comment

Choose a reason for hiding this comment

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

The tickless diagram is difficult to read. Please update it.

@rajkan01 rajkan01 force-pushed the tickless_docs_update branch 2 times, most recently from 1e84cfd to a970fa0 Compare June 9, 2020 16:02
@evedon
Copy link
Contributor

evedon commented Jun 9, 2020

It would be useful if the digrams show SysTick (and "lpticker" or "usticker") in (equal) periods of 1ms.

@rajkan01 rajkan01 force-pushed the tickless_docs_update branch 4 times, most recently from e0057e8 to 42c3b4a Compare June 10, 2020 10:43
@rajkan01 rajkan01 force-pushed the tickless_docs_update branch from 42c3b4a to 9d09e3c Compare June 10, 2020 10:51
]
```

When tickless mode is enabled, Mbed OS's default [OsTimer](../mbed-os-api-doxy/structos__timer__def.html) based on the [low power ticker](../mbed-os-api-doxy/group__hal__lp__ticker.html) replaces SysTick. If a target's low power ticker has an excessively long wake-up time or other performance issues, make it use the [microsecond ticker](../mbed-os-api-doxy/group__hal__us__ticker.html) instead by adding the below configuration in 'target.json' (in your target's section). And this configuration is not required for the target which does not have low power ticker as the default OsTimer based on the microsecond ticker.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
When tickless mode is enabled, Mbed OS's default [OsTimer](../mbed-os-api-doxy/structos__timer__def.html) based on the [low power ticker](../mbed-os-api-doxy/group__hal__lp__ticker.html) replaces SysTick. If a target's low power ticker has an excessively long wake-up time or other performance issues, make it use the [microsecond ticker](../mbed-os-api-doxy/group__hal__us__ticker.html) instead by adding the below configuration in 'target.json' (in your target's section). And this configuration is not required for the target which does not have low power ticker as the default OsTimer based on the microsecond ticker.
When tickless mode is enabled, Mbed OS's default [OsTimer](../mbed-os-api-doxy/structos__timer__def.html), based on the [low power ticker](../mbed-os-api-doxy/group__hal__lp__ticker.html), replaces SysTick. If a target's low power ticker has an excessively long wake-up time or other performance issues, make it use the [microsecond ticker](../mbed-os-api-doxy/group__hal__us__ticker.html) instead, by adding the `tickless-from-us-ticker` configuration in 'target.json' (in your target's section). This configuration is not required for a target that does not have low power ticker, because it will default to the microsecond ticker.

@iriark01
Copy link
Contributor

I'm happy to merge; just need to know if it's 6.1 only, or can join 6.0 as well

Copy link
Contributor

@evedon evedon left a comment

Choose a reason for hiding this comment

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

Thanks for the nice update on the diagrams.

@iriark01
Copy link
Contributor

To be honest, the next release is so close that it may as well go into development; it will be published in less than two weeks anyway

@iriark01 iriark01 merged commit b4c7caa into ARMmbed:development Jun 10, 2020
@iriark01
Copy link
Contributor

Anyway, need to do more work on the development branch, as this will not be visible - it's not in the JSON

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

Successfully merging this pull request may close these issues.

5 participants