-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Refactor CMSIS #19875
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
Refactor CMSIS #19875
Conversation
All checks passed. checkpatch (informational only, not a failure)
Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks ok to me.
I added a few comments for additional commits that are actually unrelated to the patch. So @stephanosio I am fine if you don't want to do the changes in this PR.
@galak could you take a look as well? |
bool | ||
select HAS_CMSIS_CORE_M if CPU_CORTEX_M |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, wonder if this is better as 'default if CPU_CORTEX_M' instead of a select.
@ulfalizer thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To elaborate, the idea here is that HAS_CMSIS_CORE
should automatically select an adequate CMSIS-Core type based on the CPU type.
For example, when CMSIS-Core(R) is added in the next PR, it would look something like this:
config HAS_CMSIS_CORE
bool
select HAS_CMSIS_CORE_M if CPU_CORTEX_M
select HAS_CMSIS_CORE_R if CPU_CORTEX_R
The rationale for using select
instead of default
is as follows:
-
Since CMSIS-Core is a "driver" for CPU core, it makes very little sense to select a type that does not match the CPU type. For instance, if you have
CPU_CORTEX_M
selected, you would always want to selectHAS_CMSIS_CORE_M
which enables CMSIS-Core(M). For this reason, other config files should never need to override this. -
Once
HAS_CMSIS_CORE
is selected, the right type of CMSIS-Core must be enabled. For example, it makes no sense to selectHAS_CMSIS_CORE
and then doHAS_CMSIS_CORE_M=n
in another config file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This design solves another problem. Assume a vendor with all Cortex-A, Cortex-M and Cortex-R support. The vendor module will select HAS_CMSIS in the root module Kconfig file, without having to care about the different ARM variants. The right type will be selected based on the actual CPU variant.
So I like the solution by proposed here by @stephanosio .
Of course, these options must be used somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, one question about how to structure the Kconfig.
IMHO, HAS_CMSIS_CORE should not be selected by CPU_CORTEX_M. The option should signify that the vendor headers include the CMSIS headers. In theory, there could be ARM vendor HAL headers that do not include CMSIS and define own custom ARM headers. |
The problem with not selecting Lines 91 to 97 in f79fbac
Since |
But that's my point @stephanosio : arch/arm/ code requires some sort of CMSIS compilant headers/defines, but not necessarily the ARM-provided CMSIS; maybe we could have custom-defined. I thought that is the point of this Kconfig option (HAS_CMSIS): to signify that the vendor headers pull-in CMSIS headers and not own-defined. This is just my thought, however; it seems the option has not been actually used like this. @galak perhaps we could actually do as i propose, for the ARM SoCs that don't pull-in CMSIS: Now: if we accept that, by default, all ARM vendor headers must pull-in the |
I think that would be the safest approach (i.e. require all vendor HALs to use the CMSIS-Core that is included in the Zephyr repository). If the original HAL provided by a vendor includes a subset of ARM CMSIS-Core, just remove that portion in the imported HAL that and make the necessary changes to use the official CMSIS-Core instead. The rationale is as follows:
|
@@ -17,7 +17,7 @@ config CPU_CORTEX_M | |||
# Omit prompt to signify "hidden" option | |||
select CPU_CORTEX | |||
select ARCH_HAS_CUSTOM_SWAP_TO_MAIN | |||
select HAS_CMSIS | |||
select HAS_CMSIS_CORE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, now, this selects CMSIS_CORE. But CMSIS_CORE is also selected at the module Kconfig.
Can we change this to "implies"? @ulfalizer @galak ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make a slight tweak to the Kconfig
This commit relocates the CMSIS-Core(M) Include directory that currently resides directly under ext/hal/cmsis directory to its own directory, Core, in order to allow other CMSIS variants to be added. The name of CMSIS-Core(M) directory, Core, is following the original name used by the upstream CMSIS repository. For more details, see issue zephyrproject-rtos#19717. Signed-off-by: Stephanos Ioannidis <[email protected]>
The existing implementation used HAS_CMSIS configuration to specify that CMSIS-Core(M) is used; when, in fact, there are other CMSIS variants available such as CMSIS-Core(A) and CMSIS-DSP available. This commit replaces the existing HAS_CMSIS configuration with HAS_CMSIS_CORE to clarify that CMSIS-Core is used. It also introduces the CMSIS-Core variant configuration, HAS_CMSIS_CORE_M, that is automatically selected when HAS_CMSIS_CORE is enabled. For more details, see issue zephyrproject-rtos#19717. Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit updates all references to HAS_CMSIS to use HAS_CMSIS_CORE instead. With the changes introduced to allow multiple CMSIS variants to be specified, the latter is semantically equivalent to the former. For more details, see issue zephyrproject-rtos#19717. Signed-off-by: Stephanos Ioannidis <[email protected]>
This commit fixes the incorrect CMSIS version information in the README file. Signed-off-by: Stephanos Ioannidis <[email protected]>
For nordic_nrf, this commit relocates HAS_CMSIS_CORE selection from SoC Kconfig to the HAL module Kconfig, as done for other SoCs. For nxp_kinetis, remove redundant HAS_CMSIS_CORE selection in SoC Kconfig, as it is already selected by the HAL Kconfig. Signed-off-by: Stephanos Ioannidis <[email protected]>
ea3511b
to
ae05537
Compare
At the time of writing, the Zephyr repository only includes CMSIS-Core(M) variant under ext/hal/cmsis and assumes that the only form of "CMSIS" available is CMSIS-Core(M).
In order to facilitate the development of Cortex-A and Cortex-R ports, the CMSIS-to-Zephyr RTOS integration structure should be refactored to support multiple CMSIS-Core variants as well as other coprocessor and extension variants.
For more details, see the issue #19717.