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

drivers/periph/wdt: Expose configurations to Kconfig #13377

Merged

Conversation

leandrolanzieri
Copy link
Contributor

Contribution description

This moves WDT_WARNING_PERIOD configuration macro to CONFIG_ namespace and exposes it to Kconfig.

Testing procedure

Check that the value can be changed via menuconfig.

Issues/PRs references

Part of #12888

@leandrolanzieri leandrolanzieri added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: Kconfig Area: Kconfig integration labels Feb 13, 2020
@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Feb 13, 2020
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Currently WDT_WARNING_PERIOD is only supported on the sam0 platform.
If there is already a Kconfig symbol for that, we should make the option depend on that so it's not available when it would do nothing.

Also the range of this value will depend on the individual hardware implementation.
Maybe the option should rather live in cpu/$arch/periph

@leandrolanzieri
Copy link
Contributor Author

Currently WDT_WARNING_PERIOD is only supported on the sam0 platform.
If there is already a Kconfig symbol for that, we should make the option depend on that so it's not available when it would do nothing.

The problem here is, why this is in the documentation of a common peripheral interface when only one platform supports it? We can add a check to see if MODULE_PERIPH_WDT_CB is there (although nrf5x has it and does not use this option yet), as the documentation indicates.

Also the range of this value will depend on the individual hardware implementation.
Maybe the option should rather live in cpu/$arch/periph

I wouldn't move it to a CPU folder as this configuration, as it is documented, is part of the WDT API.

@fjmolinas
Copy link
Contributor

The problem here is, why this is in the documentation of a common peripheral interface when only one platform supports it?

Only one platform currently supports it, but when drafting out the API we saw that many platforms could support this, although not all, that is why it was in the public api.

The issue was that how each platform handles the wakeup varies a lot, in some cases is it configurable through some range, in others it only has a some discrete values, and in some cases these are just % of the timeout time, e.g. 50% of the timeout. For others its a fixed amount of time independent or dependent of the timeout.

I wouldn't move it to a CPU folder as this configuration, as it is documented, is part of the WDT API.

I think we should change the definition in the public to:

#if defined(DOXYGEN)
#define WDT_WARNING_PERIOD
#endif

And then as @benpicco suggested have the symbol definition in cpu/$arch/periph. That way each implementation can specify specific ranges or state that it is not configurable, or whatever the case.

What do you think @leandrolanzieri ?

@leandrolanzieri
Copy link
Contributor Author

And then as @benpicco suggested have the symbol definition in cpu/$arch/periph. That way each implementation can specify specific ranges or state that it is not configurable, or whatever the case.

What do you think @leandrolanzieri ?

Is the plan to have this option in most of the platforms? We could leave the definition on this common file and add a dependency to indicate that it's available. Then, every platform can extend the symbol to its needs. It could look like:

# drivers/periph_common/Kconfig

config HAS_WDT_WARNING_PERIOD
    bool
    help
        Indicates that a WDT peripheral driver implementation suppports the
        configuration of a warning period.

config WDT_WARNING_PERIOD
    int "Warning period (in ms)"
    depends on HAS_WDT_WARNING_PERIOD
    help
        Period in ms before reboot where wdt_cb() is executed.
# cpu/sam0_common/Kconfig

config HAS_WDT_WARNING_PERIOD
    default y

config WDT_WARNING_PERIOD
    default 1
    range 1 10

@fjmolinas thoughts?

@fjmolinas
Copy link
Contributor

@leandrolanzieri seems good!

@leandrolanzieri
Copy link
Contributor Author

@fjmolinas done. I had to replicate the dependencies in the CPU-specific Kconfig so they do not weaken.

@fjmolinas
Copy link
Contributor

@leandrolanzieri this one needs rebase!

@leandrolanzieri leandrolanzieri force-pushed the pr/kconfig_migrate/drivers/periph_wdt branch from e01936f to 90bbea7 Compare March 24, 2020 10:16
@leandrolanzieri
Copy link
Contributor Author

@fjmolinas rebased

@fjmolinas
Copy link
Contributor

This works for samd boards just fine, but other boards I get no configuration option, shouldn't I see a disabled feature? Otherwise I agree with the aproach.

@leandrolanzieri
Copy link
Contributor Author

I get no configuration option, shouldn't I see a disabled feature?

By default disabled options do not show up, you can toggle the show-all mode with a, you should see it.

Copy link
Contributor

@fjmolinas fjmolinas left a comment

Choose a reason for hiding this comment

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

ACK, please squash!

@leandrolanzieri leandrolanzieri force-pushed the pr/kconfig_migrate/drivers/periph_wdt branch from 90bbea7 to f69427f Compare March 31, 2020 11:41
@leandrolanzieri
Copy link
Contributor Author

@fjmolinas all green

@fjmolinas fjmolinas merged commit 1a8b35f into RIOT-OS:master Mar 31, 2020
@leandrolanzieri leandrolanzieri deleted the pr/kconfig_migrate/drivers/periph_wdt branch March 31, 2020 16:08
@leandrolanzieri
Copy link
Contributor Author

Thanks all for reviewing and testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Kconfig Area: Kconfig integration CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants