-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
boards: creating a pinmux library for pinmux source files #38608
boards: creating a pinmux library for pinmux source files #38608
Conversation
With the driver library cleanup in zephyrproject-rtos#37512 all drivers are now placed in dedicated zephyr libraries and not directly in libzephyr.a. This commit follows up on this by placing all pinmux.c files in a dedicated pinmux zephyr library. Signed-off-by: Torsten Rasmussen <[email protected]>
this is continuation of: #38471 |
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 should probably be zephyr_library_named(board)
instead.
Extending zephyr_library_amend() to take an optional library name argument, like `zephyr_library_amend(foo)`. This allows the build system to amend to a zephyr library created elsewhere in the build tree in a consistent way. A use-case for such feature would be pinmux source files located both in the board folder but also with files under drivers/pinmux. By using `zephyr_library_amend(<name>)` such source files can now be placed together in the same library. Signed-off-by: Torsten Rasmussen <[email protected]>
Fixes: zephyrproject-rtos#38403 A board might already have created a pinmux driver library. If such library has already been created then amend to that library, else the zephyr library is created in the drivers/pinmux CMakeLists.txt file. This ensures that pinmux source files from the board and drivers/pinmux are placed in the same library. Furthermore this avoids empty pinmux driver libraries and thus avoids the following warning: > No SOURCES given to Zephyr library: drivers__pinmux > > Excluding target from build. Signed-off-by: Torsten Rasmussen <[email protected]>
@galak As I understand, all those When you viewed this PR initially, I had only taken a single commit from #38471 instead of current 3 commits. This PR ensures that all pinmux driver related files are always placed in a pinmux library.
Now, with this PR, what we will have instead is:
Thus pinmux always goes to a pinmux library. Such a cleanup is also valuable in IDEs that organize code according to the library in which they are located. |
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.
I'm not sure if this is the right solution, please check my comments.
@@ -1,6 +1,6 @@ | |||
# SPDX-License-Identifier: Apache-2.0 | |||
|
|||
if(CONFIG_PINMUX_SAM0) | |||
zephyr_library() | |||
zephyr_library_named(pinmux) |
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.
just one comment: why do we need to name the library in this case? Is name relevant? The board pinmux.c
files are not part of the pinmux driver/library, they are board related files that setup pinmux at system init.
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.
that depends on how we want to solve this issue.
If creating a common library for pinmux functionality, then the best is to have a known name so that we can refer to the same library when appending files to it from different folders.
@@ -1,6 +1,11 @@ | |||
# SPDX-License-Identifier: Apache-2.0 | |||
|
|||
zephyr_library() |
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 CMakeLists is only included if CONFIG_PINMUX=y
, so if this library gets no sources, it means that there must be an issue somewhere else.
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.
yes, and that issue is because several boards are defining CONFIG_PINMUX=y
, even when not selecting a driver from drivers/pinmux
.
Maybe because of this guide:
https://docs.zephyrproject.org/latest/guides/porting/board_porting.html?highlight=config_pinmux#create-your-board-directory
CMakeLists.txt: if you need to add additional source files to your build.
One common use for this file is to add a pinmux.c file in your board directory to the build, which configures pin > controllers at boot time. In that case, CMakeLists.txt usually looks like this:
if(CONFIG_PINMUX) zephyr_library() zephyr_library_sources(pinmux.c) endif()
so following that guide will in most cases result in the mess this PR is trying to clean up.
Now, one way of fixing that would be to avoid having CONFIG_PINMUX=y
just because you add pinmux.c
, and that would be identical to option 4 here:
#38608 (comment)
There is option 5 which is to call the library |
I'm not sure I follow here, the board code is using the pinmux driver so why shouldn't they select it in Kconfig? |
@galak no, because in that case you end up with the library defined here being empty: zephyr/drivers/pinmux/CMakeLists.txt Lines 3 to 19 in 2637c0e
thus generating the warning described in #38403. Today the board library you propose is autonamed
so the proposal 5 leads us nowhere when it comes to fixing #38403. |
if If I need to a library that provides me with certain functionality, like math, encryption, etc. I would link to a known library providing such functionality, like a math lib, or a security lib. Similar to a pinmux driver.
that sounds wrong to me. Note: I know the library structure and organization in Zephyr is messy. |
Another option we should consider is to leave |
Please see alternative fix: #38908 I'm fine with either solution, just not happy with a CMake warning in an LTS. |
Closed in favor of: #38908 |
With the driver library cleanup in #37512 all drivers are now placed in
dedicated zephyr libraries and not directly in libzephyr.a.
This commit follows up on this by placing all pinmux.c files in a
dedicated pinmux zephyr library.
Signed-off-by: Torsten Rasmussen [email protected]