Skip to content

cpu/riscv: model Kconfig #16909

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

Conversation

leandrolanzieri
Copy link
Contributor

Contribution description

This models the Kconfig modules for risc-v and adds two boards for the CI tests. For this I had to model libc modules, I'd like some feedback on those.

Testing procedure

  • CI should take care of comparing binaries.
  • Check list of modules compiled with and without Kconfig

Issues/PRs references

#16875

@leandrolanzieri leandrolanzieri added Type: new feature The issue requests / The PR implemements a new feature for RIOT Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms labels Sep 28, 2021
@github-actions github-actions bot added Area: CI Area: Continuous Integration of RIOT components Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration Area: sys Area: System labels Sep 28, 2021
@fjmolinas fjmolinas requested a review from bergzand September 28, 2021 14:53
Comment on lines 36 to 35
# TODO: this modules are actually just artifacts from the way periph_init_%
# modules are handled in Makefile. We need to define them to keep the list the
# same for now. We should be able to remove them later on.
config MODULE_PERIPH_INIT_CLIC
bool
default MODULE_PERIPH_CLIC

config MODULE_PERIPH_INIT_CORETIMER
bool
default MODULE_PERIPH_CORETIMER

config MODULE_PERIPH_INIT_PLIC
bool
default MODULE_PERIPH_PLIC

endif # MODULE_RISCV_COMMON_PERIPH
Copy link
Contributor

Choose a reason for hiding this comment

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

You could add them here as well

ifneq (,$(filter periph_init, $(USEMODULE)))
PERIPH_IGNORE_MODULES := \
periph_init% \
periph_common \
periph_rtc_rtt \
#

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, did not know that one

Copy link
Contributor

Choose a reason for hiding this comment

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

I ran into the same a decided against adding modules just for the sake of it hahaha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now added in c9dc338

@fjmolinas
Copy link
Contributor

Generally looks good, lets trigger the ci!

@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 Sep 28, 2021
sys/Kconfig Outdated
Comment on lines 36 to 40
choice LIBC_IMPLEMENTATION
bool "Libc implementation"
depends on TEST_KCONFIG
default MODULE_NEWLIB if USE_LIBC_NEWLIB
default MODULE_PICOLIBC if USE_LIBC_PICOLIBC
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have an alternative proposal for this one, which uses less symbols:

choice LIBC_IMPLEMENTATION
    bool "Libc implementation"
    depends on TEST_KCONFIG

config MODULE_NEWLIB
    bool "NewLib"

config MODULE_PICOLIBC
    bool "Picolibc"

endchoice

The default can be chosen in riscv_common/Kconfig as:

choice LIBC_IMPLEMENTATION
    default MODULE_NEWLIB

endchoice

Copy link
Contributor

Choose a reason for hiding this comment

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

This works this way only because there are no dependencies? Or would we be able to override it in any case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually depends on TEST_KCONFIG, and that does not seem to be weakened when I tested locally.

Copy link
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 find references to this behaviour in the official docs, but in Zephyr's docs they mention:

To change the default symbol of FOO to A, you would add the following definition to Kconfig.defconfig:

choice FOO
    default A
endchoice

The Kconfig.defconfig method should be used when the dependencies of the choice might not be satisfied. In that case, you’re setting the default selection whenever the user makes the choice visible.

@leandrolanzieri
Copy link
Contributor Author

Something seems to be wrong with newlib and native

Comment on lines +21 to +23
select MODULE_PERIPH_PLIC if TEST_KCONFIG
select MODULE_PERIPH_CORETIMER if MODULE_PERIPH_TIMER && HAS_PERIPH_CORETIMER
select MODULE_PERIPH_RTT if MODULE_PERIPH_RTC && HAS_PERIPH_RTT
Copy link
Contributor

Choose a reason for hiding this comment

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

Seem like ztimer_periph_rtc is not the default backend in Makefile.dep you could either force it in the application through Kconfig or add the following


ifneq (,$(filter ztimer_sec,$(USEMODULE)))
  USEMODULE += ztimer
  # native rtc is based on xtimer, no sense in using it and its actually buggy
  ifeq (,$(filter native,$(BOARD)))
    FEATURES_OPTIONAL += periph_rtc
  endif
  include $(RIOTMAKE)/features_check.inc.mk
  ifneq (,$(filter periph_rtc,$(FEATURES_USED)))
    USEMODULE += ztimer_periph_rtc
  else
    FEATURES_OPTIONAL += periph_rtt
    include $(RIOTMAKE)/features_check.inc.mk
    ifneq (,$(filter periph_rtt,$(FEATURES_USED)))
      USEMODULE += ztimer_periph_rtt
    else
      USEMODULE += ztimer_periph_timer
    endif
  endif
endif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Added

@github-actions github-actions bot added Area: timers Area: timer subsystems Area: build system Area: Build system labels Sep 29, 2021
select HAS_SSP

select MODULE_MALLOC_THREAD_SAFE if TEST_KCONFIG
imply MODULE_NEWLIB_NANO
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't TEST_KCONFIG missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Imply will not force it, if TEST_KCONFIG is not there (or some other dependency for that matter), the symbol is not enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's why this also works when picolibc is selected, newlib_nano would not be enabled in that case.

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.

One last comment, but please squash afterwards

@leandrolanzieri leandrolanzieri force-pushed the pr/cpu/riscv/model_kconfig branch from c9dc338 to 2d36f24 Compare September 29, 2021 09:11
@leandrolanzieri
Copy link
Contributor Author

Squashed!

@@ -108,3 +108,27 @@ ifneq (,$(filter ztimer_msec,$(USEMODULE)))
USEMODULE += ztimer_periph_timer
endif
endif

ifneq (,$(filter ztimer_sec,$(USEMODULE)))
Copy link
Contributor

Choose a reason for hiding this comment

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

@benpicco how would this affet your rtc_rtt concerns

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, this is already an issue in master... so this does not make the problem worse..

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll try to find a solution for this in a follow up

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 rebase and squash (

@leandrolanzieri leandrolanzieri force-pushed the pr/cpu/riscv/model_kconfig branch from 2d36f24 to bda69da Compare October 1, 2021 09:25
@benpicco benpicco 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 Oct 1, 2021
@fjmolinas fjmolinas merged commit 93bff48 into RIOT-OS:master Oct 5, 2021
@leandrolanzieri leandrolanzieri deleted the pr/cpu/riscv/model_kconfig branch October 5, 2021 15:04
@leandrolanzieri
Copy link
Contributor Author

Thanks for the review!

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: CI Area: Continuous Integration of RIOT components Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration Area: sys Area: System 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 Platform: RISC-V Platform: This PR/issue effects RISC-V-based platforms 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