-
Notifications
You must be signed in to change notification settings - Fork 2k
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
cpu/fe310: rtc depend on the rtt feature and hifive1 update #10062
Conversation
It is the role of boards based on 'cpu/fe310' to give the configuration for the rtc/rtt. The fe310/periph/rtc implementation depends on having periph/rtt configured by the board so depends on the board 'providing' the periph_rtt feature and declaring the required macros. It should not simply depend of the 'periph_rtt' module as this does not enforce having a configuration for the module in the board. In practice, when compiling, it would result in undefined 'RTT' symbols, instead of the build system detecting it.
Remove duplicate handling of `periph_rtc` dependency to `periph_rtt` now declared in the cpu. Also the makefiles should not parse FEATURES_REQUIRED as it does not guarantee anything as features could also be requested by FEATURES_OPTIONAL. In practice it should parse it using `USEMODULE`.
@kenrabold some cleanup for your board/cpu |
this whole periph_rtt feature is handled differently for most boards right now, from the approach here. The closest is the |
tough I understand that this fixes a bug for the hifive1 board and fe310 cpu combination |
Correct me if I am wrong it is really something I am not really good with. From what I understood from with discussions with @kYc0o . The configuration of the So even if the implementation can be done by the If this is wrong, I can change to another direction you tell me. |
If for any reason, one board does not provide |
@gebart I think you would have a better knowledge on this and if it would apply to kinetis boards. |
When I implemented the code for RISC-V CPU and HiFive1 board, I struggled with understanding the feature dependency make rules and getting them to work. In my opinion, all of the FEATURES_PROVIDED that are listed in the Makefile.features for the hifive1 board really should be in the CPU Makefile.features under cpu\fe310. Those "features" are provided by the SoC, not the board, and it should be the board that identifies which of those features it wants to turn on using a FEATURES_REQUIRED setting. However, I could not get the build to work with that setup (it could be fixed now?) Also, neither the FE310 CPU nor the HiFive1 board have an RTC, so I used the same RTC on top of the RTT implementation that I saw in the kinetis board. But you need a dependency linking the selection of the RTC feature by requiring the RTT for the FE310 CPU. Again, I could not get the compilation to work. I'm open to suggestions on ways to make the configuration of the RISC-V CPU and board files more flexible |
@kenrabold thank you for your feedback. I will try to explain a bit more with my words. There is also still somehow a mix between using
In fact, it is not the board that identifies which one to turn on or not but the application, or its dependencies. The Why ? because there is:
In your case:
Because of this requirement that the board provides the configuration and an external crystal it is the responsibility of the board to declare the An example that @kYc0o gave me, a cpu could have 4 uarts, but the board manufacturer decided to not wire them. There are there in the cpu, there is code to handle them, but they are not connected. Should there be somewhere documented in the cpu that there are these 4 uarts that could be used if configured ? Yes. But maybe more in the documentation than in a build system dependency resolution file. There could be a comment in
Even if currently
That is what I described by saying that the With this, does it makes my changes understandable or did I leave something unclear in my explanation? Feedback will help summarizing this later in documentation. I still have many things I could add but prefer not put too much details first if they are not helping. |
@cladmi I think your changes are perfectly fine. Thanks for clarifying the use of the various features and modules defines |
@kenrabold thank you for your feedback and for forcing me to explain this. I used your request to try writing something that could act as a base for a documentation ;) |
The case with software-emulated features is something I cannot figure out how to handle. If the implementation is generic (works with any board that provides RTT) then there should not be any need for the board to declare the RTC feature explicitly. This also applies to any other sw-emulated features. For now I think it is good to migrate features out of the CPU, but we have to start thinking how to sort this out. |
Thank you for reviewing.
@smlng I should check these, thank you. |
@jcarrano I would say that is an api choice from the Here we are already at the point where there are But definitely these are the refinements I am still missing on how to define what should and what should not be described as a feature. |
Contribution description
It is the role of boards based on 'cpu/fe310' to give the configuration
for the rtc/rtt.
The fe310/periph/rtc implementation depends on having periph/rtt configured
by the board so depends on the board 'providing' the periph_rtt feature
and declaring the required macros.
It should not simply depend of the 'periph_rtt' module as this does not
enforce having a configuration for the module in the board.
In practice, when compiling, it would result in undefined 'RTT' symbols,
instead of the build system detecting it.
This also updates
board/hifive1
as it does not need to handle this anymore.Testing procedure
To test this, you can modify the
hifive1
board as if it did not supportperiph_rtt
:And when compiling you get
error RTT_ undeclared
errorsWith this PR and the diff you correctly get the missing features error
Issues/PRs references
This is part of #10060 and was found while working on #9913