Skip to content

Conversation

fjmolinas
Copy link
Contributor

@fjmolinas fjmolinas commented Feb 28, 2020

Contribution description

Following up on #13089 this PR allows disabling periph_%auto initialization by adding explicit periph_init_% modules for each one of them.

Since they are not initlalized by the auto-init module I added a periph_init module that just handles enabling or disabling periph initialization.

Testing procedure

  • Normal build:
make -C tests/xtimer_usleep info-debug-variable-USEMODULE --no-print-directory
auto_init auto_init_xtimer board core core_init core_msg core_panic cpu div native-drivers periph periph_common periph_gpio periph_init periph_init_gpio periph_init_pm periph_init_timer periph_pm periph_timer periph_uart stdin stdio_native sys test_utils_interactive_sync xtimer
  • Disable one periph_init_%
DISABLE_MODULE+=periph_init_timer make -C tests/xtimer_usleep info-debug-variable-USEMODULE --no-print-directory
auto_init auto_init_xtimer board core core_init core_msg core_panic cpu div native-drivers periph periph_common periph_gpio periph_init periph_init_gpio periph_init_pm periph_pm periph_timer periph_uart stdin stdio_native sys test_utils_interactive_sync xtimer
  • Disable all periph_init
DISABLE_MODULE+=periph_init make -C tests/xtimer_usleep info-debug-variable-USEMODULE --no-print-directory
auto_init auto_init_xtimer board core core_init core_msg core_panic cpu div native-drivers periph periph_common periph_gpio periph_pm periph_timer periph_uart stdin stdio_native sys test_utils_interactive_sync xtimer

  • Murdock should run all tests.

Issues/PRs references

Fixes #11026
depends on #13401

@fjmolinas fjmolinas added Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers CI: disable test cache If set, CI will always run all tests regardless of whether they have been run successfully before CI: run tests If set, CI server will run tests on hardware for the labeled PR State: waiting for other PR State: The PR requires another PR to be merged first Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Feb 28, 2020
@fjmolinas fjmolinas changed the title drivers/periph_common: use auto_init_periph_% modules drivers/periph_common: add periph_init% modules Mar 5, 2020
@fjmolinas fjmolinas force-pushed the pr_auto_init_periph branch from 4508f48 to d4c3180 Compare March 5, 2020 18:14
@fjmolinas fjmolinas removed the State: waiting for other PR State: The PR requires another PR to be merged first label Mar 5, 2020
@fjmolinas fjmolinas requested a review from benpicco March 5, 2020 18:16
@fjmolinas
Copy link
Contributor Author

No longer waiting for another PR, I changed the name of all modules to periph_init to separate them from auto_init since they are not handled in the same place.

@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 Mar 5, 2020
@fjmolinas fjmolinas added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 5, 2020
@fjmolinas fjmolinas force-pushed the pr_auto_init_periph branch from d9d2d21 to c1e117c Compare March 6, 2020 08:00
@fjmolinas
Copy link
Contributor Author

Only the following failures:

    tests/netstats_l2/esp32-wroom-32:gnu
    examples/suit_update/nrf52dk:gnu

I believe they are unrelated.

@fjmolinas
Copy link
Contributor Author

@benpicco let me know if I should squash.

@benpicco
Copy link
Contributor

benpicco commented Mar 6, 2020

Yes, please squash!
Change looks good too.

@fjmolinas fjmolinas force-pushed the pr_auto_init_periph branch from c1e117c to 740a386 Compare March 6, 2020 10:21
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.

Murdock is happy and better control of what gets initialized automatically is always useful.
Now tests don't have to blanket disable auto_init (and break stdio_cdc_acm) anymore when in fact they just want to disable auto init of one module!

@benpicco benpicco removed the CI: disable test cache If set, CI will always run all tests regardless of whether they have been run successfully before label Mar 6, 2020
@benpicco benpicco merged commit 7877ffd into RIOT-OS:master Mar 6, 2020
@fjmolinas fjmolinas deleted the pr_auto_init_periph branch March 6, 2020 12:52
@fjmolinas
Copy link
Contributor Author

Thanks for the review!

@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Mar 13, 2020
@gschorcht
Copy link
Contributor

I am not really happy with this change. For example, until this change it was sufficient

USEMODULE=periph_rtc BOARD=... make -C tests/shell

to enable the RTC commands and use the RTC. With this change it is now necessary to use

USEMODULE='periph_rtc periph_init_rtc' BOARD=... make -C tests/shell

It took me some time to figure out the reason why the RTC commands didn't work anymore 😟 The reason is that periph_rtc is not included in the FEATURES_USED variable. Therefore, the periph_init_rtc module is not enabled.

The expected behavior is the following. If a periph_* module is used by an application and the board provides the periph_* feature, the peripheral should be initialized during the startup.

It seems to work if the periph_* module is added to the makefile of the application, but it doesn't work if it is defined in USEMODULE environment variable at the command line.

To be honest, I don't understand the necessity for this change. Peripherals are only initialized when the according modules are used. If the according modules are used, the application expects that the peripherals are initialized. There is probably no use case where the application might want to disable the initialization of peripherals using DISABLE_MODULE.

@fjmolinas
Copy link
Contributor Author

USEMODULE=periph_rtc BOARD=... make -C tests/shell

You can just as well do FEATURES_REQUIRED=periph_rtc BOARD=... make -C tests/shell, it could still change it to set the DEFAULT_MODULE based on USEMODULE instead.

From my understanding periph_% should not be added as USEMODULE but as FEATURES_REQUIRED in an application Makefile.

To be honest, I don't understand the necessity for this change. Peripherals are only initialized when the according modules are used. If the according modules are used, the application expects that the peripherals are initialized. There is probably no use case where the application might want to disable the initialization of peripherals using DISABLE_MODULE.

Well some users had a used case for this #11026. It seems that in some cases the user does want to handle initialization.

Anyway:

# set all USED periph_% init modules as DEFAULT_MODULE
ifneq (,$(filter periph_init, $(USEMODULE)))
  DEFAULT_MODULE += $(subst periph_,periph_init_,$(filter periph_%,$(USEMODULE)))
endif

would work for your use case, would you agree on that fix?

@fjmolinas
Copy link
Contributor Author

# set all USED periph_% init modules as DEFAULT_MODULE
ifneq (,$(filter periph_init, $(USEMODULE)))
  DEFAULT_MODULE += $(subst periph_,periph_init_,$(filter periph_%,$(USEMODULE)))
endif

would work for your use case, would you agree on that fix?

Hmm make doesn't like this.

@fjmolinas
Copy link
Contributor Author

Hmm make doesn't like this.

Anyway there are still ways of doing this so it checks USEMODULE and not FEATURES_USED.

@gschorcht
Copy link
Contributor

USEMODULE=periph_rtc BOARD=... make -C tests/shell

You can just as well do FEATURES_REQUIRED=periph_rtc BOARD=... make -C tests/shell

Unfortunately not 😟

FEATURES_REQUIRED=periph_rtc BOARD=... make -C tests/shell

doesn't do the trick. It enables module periph_rtc but not module periph_init_rtc.

@gschorcht
Copy link
Contributor

gschorcht commented Mar 15, 2020

Unfortunately not

FEATURES_REQUIRED=periph_rtc BOARD=... make -C tests/shell

doesn't do the trick. It enables module periph_rtc but not module periph_init_rtc.

@fjmolinas Sorry my fault, forget it, it works in that way. I had a typo in my command 😎 I can live with this approach, even if it differs from the usual way of activating functionalities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recent changes effectively killed modular board designs
4 participants