-
Notifications
You must be signed in to change notification settings - Fork 8k
Allow device-tree compiler know SoC and CPU used #96310
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
Allow device-tree compiler know SoC and CPU used #96310
Conversation
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.
Pull Request Overview
This pull request adds automatic extraction of SOC and CPU information from the BOARD_QUALIFIERS
CMake variable to provide preprocessor definitions for device tree compilation. The change enables conditional compilation in device tree files using SOC and CPU-specific preprocessor directives.
- Parses
BOARD_QUALIFIERS
when it matches the pattern "SOC/CPU" format - Extracts and converts SOC and CPU names to uppercase for preprocessor flags
- Appends
-DDTS_SOC_<name>
and-DDTS_CPU_<name>
flags toDTS_EXTRA_CPPFLAGS
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
list(GET BOARD_QUALIFIERS_LIST 1 SOC_NAME) | ||
list(GET BOARD_QUALIFIERS_LIST 2 CPU_NAME) |
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.
Incorrect list indices used for extracting SOC and CPU names. For a string 'SOC/CPU' split by '/', the SOC should be at index 0 and CPU at index 1, not indices 1 and 2.
list(GET BOARD_QUALIFIERS_LIST 1 SOC_NAME) | |
list(GET BOARD_QUALIFIERS_LIST 2 CPU_NAME) | |
list(GET BOARD_QUALIFIERS_LIST 0 SOC_NAME) | |
list(GET BOARD_QUALIFIERS_LIST 1 CPU_NAME) |
Copilot uses AI. Check for mistakes.
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 am not sure this is needed, it seems like a messy bandaid for some platform that has a bad #include hierarchy. You shouldn't need to know the target with macros because your base DTS should only be pulling in DTSI that are valid for that target, and those should only pull in valid ones, etc. This is going to make a giant incomprehensible mess of DTS files if people start #ifdef'ing includes instead of properly #include'ing the right things in the first place. If you need help fixing your platform #includes see my suggestion on #95577 and another example on dba69f3
@decsny Thank you for your comment. |
And I am saying, what you are proposing is a vehicle to add technical debt of confusing DTSI configuring and include paths. I think this would also make things very difficult on tools that a lot of people have for IDEs and DT shells and whatnot to figure out the correct configurations, because adding #ifdef around #includes will cause just exponential complications is my bet. I don't know, but I just don't want to see #ifdef around including DTSI files. If somebody needs to rework their DTSI because they did it improperly, then that's what they have to do, I don't want to add a mechanism to keep piling on that debt, it's not the right solution. |
Thank you. I understand your opinion and also agree - making less technical debt is always the best choice. I just had the idea I see best match between implementation time and yield it brings. |
maybe @dottspina can comment about how this might affect toolings since he is the author and maintainer of DTSH |
cd52abe
to
f0809cd
Compare
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 is not at all how things are meant to work and is going to completely break in future e.g. if SIP support is merged, a dts file should have no knowledge of the soc
make dts see SoC and CPU used during device tree compiler runtime Signed-off-by: Alexander Kozhinov <[email protected]>
f0809cd
to
c9d4a24
Compare
|
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 just had the idea I see best match between implementation time and yield it brings.
which is a reasonable goal.
But the problem with this PR is that it will set a precedence and allow new SoCs / boards to use a broken pattern, thus it will add to our tech debt and not help us reduce it.
Plus, once introduced, then it will be harder to deprecate and remove again when users, especially downstream, will be depending on this possibility.
This pull request introduces logic to automatically extract and use board qualifiers from the
BOARD_QUALIFIERS
variable in CMake. IfBOARD_QUALIFIERS
matches a specific pattern, it splits the value and sets preprocessor flags for the SOC and CPU, making the build process more dynamic and configurable.Enhancements to board qualifier handling:
BOARD_QUALIFIERS
contains both SOC and CPU information (in the formatSOC/CPU
), splits them, converts them to uppercase, and appends corresponding preprocessor flags toDTS_EXTRA_CPPFLAGS
.Allow device-tree compiler know SoC and CPU used.With this change device-tree compiler will become information about SoC variant and CPU being used during generation of defines from device-tree.
This change is advantageous, because it shall allow usage of C-preprocessor directives within .dts/.dtsi files s.t. following form of includes becomes possible:
Testing could be done with similiar patch: