Skip to content

sys/ztimer: add 'ztimer_no_periph_rtt#17099

Closed
fjmolinas wants to merge 3 commits intoRIOT-OS:masterfrom
fjmolinas:pr_ztimer_no_periph_rt%
Closed

sys/ztimer: add 'ztimer_no_periph_rtt#17099
fjmolinas wants to merge 3 commits intoRIOT-OS:masterfrom
fjmolinas:pr_ztimer_no_periph_rt%

Conversation

@fjmolinas
Copy link
Copy Markdown
Contributor

@fjmolinas fjmolinas commented Nov 2, 2021

Contribution description

This is a temporary fix for Issue #17060. It allows disabling
auto inclusion of ztimer_periph_rt* in cases where another
module or application requires direct access.

Limitations:

  • as ifeq are involved order of inclusion matters, therefore
    these modules should be included early in the build at the application
    level and not in modules Makefile.dep
  • this does not disallow direct inclusions of ztimer_periph_rt*,
    since this only disables auto inclusion of these modules

This is a temporary solution since this is already possible with
Kconfig, but not in make.

This implements the easiest fix proposed in #17060 to be able to move forward with the migration.

Testing procedure

USEMODULE="ztimer_msec ztimer_no_periph_rtt" BOARD=samr21-xpro make -C tests/ztimer_msg/ info-modules  | grep periph_rtt
ztimer_no_periph_rtt
DISABLE_MODULES=ztimer_periph_rtt_auto_select BOARD=samr21-xpro make -C tests/ztimer_msg/ info-modules  | grep periph_rtt

Issues/PRs references

#17060

@github-actions github-actions bot added Area: Kconfig Area: Kconfig integration Area: sys Area: System Area: tests Area: tests and testing framework Area: timers Area: timer subsystems labels Nov 2, 2021
@kfessel
Copy link
Copy Markdown
Contributor

kfessel commented Nov 2, 2021

Why not just remove the automatic rtt rtc selection from makefile.dep?

periph_rtt is no good indicator for an rtt being able to power msec
periph_rtc does conflict with rtt on many devices

why did this change get merged with an KConfig PR #16909?

just revert 34259e1 and remove the Makefile.dep change in c80390f

@fjmolinas
Copy link
Copy Markdown
Contributor Author

periph_rtt is no good indicator for an rtt being able to power msec

Why not?

periph_rtc does conflict with rtt on many devices

There isl FEATURES_CONFLICTING for that

why did this change get merged with an KConfig PR #16909?

You are surely right about that, I should have asked for a split, at the time I though it was an issue with the Makefile not being inline with Kconfig, but thas was my bad.

just revert 34259e1 and remove the Makefile.dep change in c80390f

I won't revert the change in Makefile.dep but I'll provide a removal of the default rtc seleciton.

*
* If `periph_rtt` or `periph_rtc` is required with direct access by another
* MODULE or an application, `ztimer_no_periph_rtt` or `ztimer_no_periph_rtc`
* can be included to avoid automatic selection of either `ztimer_periph_rtc`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* can be included to avoid automatic selection of either `ztimer_periph_rtc`
* must be included to avoid automatic selection of either `ztimer_periph_rtc`

Copy link
Copy Markdown
Contributor

@kfessel kfessel Nov 2, 2021

Choose a reason for hiding this comment

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

i think there should also be a warning and link int the periph_rtt documentation about that automatic rtt selection of ztimer

kfessel
kfessel previously requested changes Nov 2, 2021
Copy link
Copy Markdown
Contributor

@kfessel kfessel left a comment

Choose a reason for hiding this comment

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

waiting for #17113
after that ztimer will not default to rtc

This no longer needs a Makefile.dep split

@fjmolinas
Copy link
Copy Markdown
Contributor Author

@benpicco also mentione that a build-system warning would be desirable, I'll take another look on the next sprint

@fjmolinas fjmolinas force-pushed the pr_ztimer_no_periph_rt% branch from f2419c3 to acc1b8e Compare November 9, 2021 09:33
@github-actions github-actions bot added the Area: drivers Area: Device drivers label Nov 9, 2021
@fjmolinas fjmolinas changed the title sys/ztimer: add 'ztimer_no_periph_rt*%' sys/ztimer: add 'ztimer_no_periph_rtt Nov 9, 2021
@github-actions github-actions bot added the Area: build system Area: Build system label Nov 9, 2021
@fjmolinas
Copy link
Copy Markdown
Contributor Author

@benpicco I added a warning in the periph/rtt.h header, in the ztimer.h header, and when building if both modules are included a warning is shown. Anything else you would suggest?

I also added in d336016 an alternative based on DEFAULT_MODULE

@benpicco
Copy link
Copy Markdown
Contributor

benpicco commented Nov 9, 2021

The DEFAULT_MODULE solution sounds ideal, then modules that make use of the RTT API can just DISABLE_MODULE += ztimer_periph_rtt

@fjmolinas
Copy link
Copy Markdown
Contributor Author

The DEFAULT_MODULE solution sounds ideal, then modules that make use of the RTT API can just DISABLE_MODULE += ztimer_periph_rtt

No, this is not the case. Rember that DEFAULT_MODULE only works if they are disabled before other dependencies are parsed, otherwise they will already be selected. It would need to be disabled in something included in makefiles/defaultmodules.inc.mk or in the application. DEFAULT_MODULE can not be disabled during dependency resolution because at that stage they were already converted to a USEMODULE

Copy link
Copy Markdown
Contributor

@kfessel kfessel left a comment

Choose a reason for hiding this comment

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

no need for sys/ztimer/Makefile.ztimer.rtt.dep

@kfessel kfessel dismissed their stale review November 9, 2021 13:26

important no rtc default is adressed

@fjmolinas fjmolinas added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 25, 2021
@fjmolinas fjmolinas force-pushed the pr_ztimer_no_periph_rt% branch from bda703d to abb6c1e Compare November 25, 2021 12:20
@github-actions github-actions bot removed the Area: build system Area: Build system label Nov 25, 2021
Copy link
Copy Markdown
Contributor

@kfessel kfessel left a comment

Choose a reason for hiding this comment

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

one (two) minor static-test-failures.

@fjmolinas fjmolinas removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 25, 2021
@fjmolinas
Copy link
Copy Markdown
Contributor Author

I'll squash if static tests pass.

@fjmolinas fjmolinas force-pushed the pr_ztimer_no_periph_rt% branch from a85a19c to b35229c Compare November 25, 2021 13:57
@fjmolinas fjmolinas added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 25, 2021

# If ztimer is used enable rtt autoselection for ztimer_msec, and ztimer_sec.
# This will enable inclusion of `ztimer_periph_rtt` if `periph_rtt` is supported.
DEFAULT_MODULE += ztimer_periph_rtt_auto_select
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this line is not yet evaluated when l 96 is reached -> no auto selection is done

@fjmolinas fjmolinas removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 25, 2021

# If ztimer is used enable rtt autoselection for ztimer_msec, and ztimer_sec.
# This will enable inclusion of `ztimer_periph_rtt` if `periph_rtt` is supported.
DEFAULT_MODULE += ztimer_periph_rtt_auto_select
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ajj true, that is why initially I had put in Makefile.default..., couldn't remember why and moved it out :/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't think of another solution than ae0bf90... it does mean that a ztimer module will show up even when ztimer is not used...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

make -C examples/hello-world/ clean info-modules 
auto_init
board
core
core_idle_thread
core_init
core_msg
core_panic
cpu
native_drivers
periph
periph_common
periph_gpio
periph_gpio_linux
periph_init
periph_init_gpio
periph_init_gpio_linux
periph_init_pm
periph_init_uart
periph_pm
periph_uart
stdio_native
sys
ztimer_periph_rtt_auto_select

@github-actions github-actions bot added the Area: build system Area: Build system label Nov 25, 2021
@fjmolinas fjmolinas force-pushed the pr_ztimer_no_periph_rt% branch from 11deff0 to 860addb Compare November 25, 2021 14:09
@fjmolinas
Copy link
Copy Markdown
Contributor Author

Rebased because of conflict with master

* If `periph_rtt` or is required with direct access by another MODULE or
* application, `ztimer_periph_rtt_auto_select` can be disabled to avoid automatic
* selection of `ztimer_periph_rtt` as a backend for ZTIMER_SEC and ZTIMER_MSEC.
* i.e.: `DISABLE_MODULE += ztimer_periph_rtt_auto_select`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we maybe invert the logic? Making a module that avoids the default selection if present in the application makefile? then we wouldn't have the issue of the default module always showing up, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That was the initial approach I had, I can go back to that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kfessel thoughts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think the was a problem that lead to abondoning that approach (like could not be kconfig model???)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I split into an alternative the old versio so its easier to compare #17284

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@leandrolanzieri @kfessel opinion on what option to prefer this one or #17284?

Copy link
Copy Markdown
Contributor

@kfessel kfessel left a comment

Choose a reason for hiding this comment

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

Please Squash and activate ci:ready..

tested with make configuration (using test/ztimer_xsec) ✔️
I also tested with kconfig ✔️

and squash right in:

while reviewing these line threw me in the wrong way would you please remove the S in the make variables (even though these lines are not part of this PR)

sys/ztimer/Makefile.dep
12:  # but RIOT's auto_init scheme expects "auto_init_ztimer" in DEFAULT_MODULES so
13:  # it can be disabled (by adding to DISABLE_MODULES).
please change to 
DEFAULT_MODULE
DISABLE_MODULE

* if if these are missing it will use same basic timer
* as ZTIMER_USEC does.
*
* If `periph_rtt` or is required with direct access by another MODULE or
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
* If `periph_rtt` or is required with direct access by another MODULE or
* If `periph_rtt` is required with direct access by another MODULE or

@fjmolinas
Copy link
Copy Markdown
Contributor Author

sys/ztimer/Makefile.dep
12: # but RIOT's auto_init scheme expects "auto_init_ztimer" in DEFAULT_MODULES so
13: # it can be disabled (by adding to DISABLE_MODULES).
please change to
DEFAULT_MODULE
DISABLE_MODULE

This was removed in another PR.

This is a temporary fix for Issue RIOT-OS#17060. It adds a module that
enables the auto-inclusion of 'ztimer_periph_rtt'. This module,
'ztimer_periph_rtt_auto_select' is set as a DEFAULT_MODULE and can therefore
be deselect at application level of in CPU/BOARDs 'Makefile.default'.

Limitations:
- This does not allow for modules to disable the auto-selection, e.g.:
  there can't be a depency where 'rtt_rtc' disables
  'ztimer_periph_rtt_auto_select'
- This does not disallow direct inclusions of `ztimer_periph_rt*`,
  since this only disables auto inclusion of these modules

This is a temporary solution since this is already possible with
Kconfig, but not in make.
@fjmolinas fjmolinas force-pushed the pr_ztimer_no_periph_rt% branch from 860addb to 08d5b9e Compare November 29, 2021 08:26
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 30, 2021
@kaspar030 kaspar030 removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 30, 2021
@kfessel kfessel added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 1, 2021
@fjmolinas
Copy link
Copy Markdown
Contributor Author

Superseeded by #17284

@fjmolinas fjmolinas closed this Dec 6, 2021
@emmanuelsearch emmanuelsearch removed this from the Release 2022.01 milestone Jan 27, 2022
@fjmolinas fjmolinas deleted the pr_ztimer_no_periph_rt% branch June 9, 2022 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: drivers Area: Device drivers Area: Kconfig Area: Kconfig integration Area: sys Area: System Area: tests Area: tests and testing framework Area: timers Area: timer subsystems CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants