-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Kconfig support for stm32 HAL/LL file selection #4646
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
Conversation
|
Understand what you're trying to do, but I have 3 concerns: Is there a way to split these files and distribute it in ext/hal/st/stm32cube/stm32yyxx/ folders? One last point is that LL headers could be used without any flags (as done for serial driver case for instance). Maybe some comment somewhere should make this clear (USE_LL flags are only valid for LL.c files). This is not new, but creation of USE_LL flags might be misleading in that regard. |
Is that really worse than having driver build logic in a completely different part of the Zephyr source tree like it is now? With this change the logic is all local to the driver. Also it will cause less commit "collisions" cause at the moment all HAL/LL users will need to edit the etx/hal/st/ kbuild files. Also when more than one driver (for example PWM and Counter) need the same hal files (tim.c) the current kbuild file will get more and more cluttered. If there are than also user applications, demo's or tests that need HAL/LL sources it will get even worse. Another thing is now the hal kbuid file has things like;
That doesn't give any information which serial driver actually needs the HAL. And if there is a serial driver that doesn't need the HAL it can not disable compiling of the HAL code. Same for CONFIG_PWM and CONFIG_I2C.
The "if SOC_SERIES_STM32F4X" already reduces that it seems. Splitting it up in one file per SOC-type will make the file more readable.
As long as no files are added or removed from the Cube HAL the kconfig/kbuild file should never be touched anymore. Maybe one could use some python script to auto generate the kbuild and kconfig files ? They are pretty much one to one with the *.c files. If it is hard to do that at build time, the cube maintainer could use the script to generate the files at "commit" time?
Maybe a different verb than USE? Something like LINK_TO__STM32F1XX_LL_I2C or NEED_STM32F1XX_LL_I2C _OBJ ? |
Ok, this is a fair point.
Splitting up files would be nice
Doing it at build time would require pretty good documentation, to make it understandable for user.
USE_STM32F1XX_LL_I2C _OBJ ? Not quite sure here.. |
bc94af3 to
82629c9
Compare
|
@erwango I split the Kconfig and Kbuild files up and put them in the cpu dirs, that really cleans up the code. To the name LINK_TO_STM32F1XX_LL_I2C, NEED_STM32F1XX_LL_I2C_OBJ, USE_STM32F1XX_LL_I2C, etc. I really don't know. Maybe someone else can comment on this ? |
|
@galak @erwango any ideas what to do with the Kconfig menu entry names ? Should I change it to USE_STM32F1XX_LL_I2C_OBJ ? And anything else I can do to get this patch accepted. @dbkinder there are README's in the st hal directories. But those don't end up in the official documentation, do they ? The maintainer notes will probably be of no use to normal users, but the how to use the HAL is of use to them. What would be the way to get that in the "official" documentation? (assuming this patch is accepted of course) |
|
The documentation gathering process only looks for RestructuredText-formatted .rst files, so no, the .txt files are ignored when creating our public documentation. If you separate the maintainer notes (in the .txt file) from the public/user notes (in a .rst file) we can get them included. |
|
@dbkinder thanks for the info, if I have a go from the code maintainers I will split up the documentation and make a rst file out of it. |
|
@lowlander : Let's keep USE_STM32YYXX_LL_FOO and document the fact that using LL headers don't require any flags activation. As a next step, would be good to get feedback from other frequent and active STM32 contributors like @mbolivar, @ydamigos , @superna9999 |
ext/hal/Kbuild
Outdated
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 header seems inaccurate !
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.
Probably just added headers to all open files in my editor that didn't have a header asuming they were new files.
Remove or change ?
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.
Remove please
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.
will do.
|
I'm ok with @erwango about the fact we can include headers without necessarily building the *.c files Except the unnecessary header on ext/hal/Kbuild I'm ok with this. |
ydamigos
left a comment
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 fine with the changes. Just a comment which probably is not relevant with this PR.
drivers/serial/Kconfig.stm32
Outdated
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.
Does the STM32F0 family use the HAL serial driver? I thought that all families use the LL serial api.
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.
F0 should use the same as all STM32 families
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.
Could we remove this line or should we do it in a separate PR?
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.
Should be a conversion of an oversight from F0 PR merged following merge of the PR that converted serial to full LL (Not quite clear, but you got my point).
To do it in a clean way, I propose an initial commit that remove culprit line in ext/hal/st/stm32cube/Kbuild.
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.
Acked
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 modeled the driver-kconfig files after the hal-Kconfig file that had;
obj-$(CONFIG_SERIAL_HAS_DRIVER) += stm32f0xx/drivers/src/stm32f0xx_hal_uart.o
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 was my point this line was an oversight following of F0 series introduction.
Migration from HAL to LL in serial driver has been merged during process of F0 review. It should have been detected at that point (my bad).
It would be nice if you could do a preliminary commit to your PR where you remove this line.
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.
@lowlander : Btw, just observed that initial Kbuild has been fixed with #4493.
So you could remove it safely after rebase
I think the overall approach is clever and have no problem with the changes. It'd be nice to have CMakeFiles.txt equivalents in cmake_migration 😉 |
|
ok seems that change has community approval! I'm thinking that @MaureenHelm, you could be interested too, it is a solution that could be interesting for other HALs in general. |
|
@erwango yes I noticed yesterday evening. I wanted to update the docu (readme.txt) before pushing an update to this PR. |
f6ed65b to
b0b954c
Compare
|
@superna9999 F0 I2C Will be in the next push. @galak do you have anything else like the I2C from @superna9999 or were you just revering to the "merge conflict" ? |
|
@galak : Before requesting a rebase to @lowlander, do you have any comments beforehand on this change? |
|
I haven't read the full thread, so sorry if this got discussed. Instead of having:
Can we just do: select USE_STM32_LL_UTILS (similar comment for config vars) |
|
@galak to be honest I didn't think about that, and it seems nobody else here :-) I changed it so they all have the same name for all cpu types. It makes things for the driver writer easier and cleaner. |
Codecov Report
@@ Coverage Diff @@
## master #4646 +/- ##
==========================================
+ Coverage 51.29% 51.29% +<.01%
==========================================
Files 441 441
Lines 42275 42275
Branches 8066 8066
==========================================
+ Hits 21685 21687 +2
+ Misses 20069 20067 -2
Partials 521 521
Continue to review full report at Codecov.
|
|
@lowlander : You need to add a comment to commit "ext: hal: stm32cube: update README". This is a new rule coming from TSC since last week. Then, last question: Following change proposed by @galak , is there something that prevent to factorize Kconfig from to stm32cube/stm32yyxx/Kconfig to stm32cube/Kconfig ? |
|
@erwango yeah I noticed that commits with just a title aren't enough anymore, I am sure others already have discussed the usefulness of that rule. To moving the Kconfig files to stm32cube, I think that should be possible. Some CPU's don't have all options, but I don't think that should be a problem. I'll try to cleanup the patch in the next couple of days. |
|
@lowlander any update on this patch series? |
|
recheck |
|
@galak I'll fix the patch tomorow, it is to late now. |
By providing USE_STM32_HAL_* and USE_STM32_LL_* menuconfig options drivers and user aplications can select parts of the HAL without needing to change the Zephyr source code. Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Use "select USE_STM32_LL_UTILS" to select the needed STM32 LL files, instead of editing ext/hal/st/stm32cube/CMakeLists.txt Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Use "select USE_STM32_HAL_ETH" to select the needed STM32 HAL files, instead of editing ext/hal/st/stm32cube/CMakeLists.txt Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Use "select USE_STM32_LL_I2C" to select the needed STM32 LL files, instead of editing ext/hal/st/stm32cube/CMakeLists.txt Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Use "select USE_STM32_HAL_TIM" to select the needed STM32 HAL files, instead of editing ext/hal/st/stm32cube/CMakeLists.txt Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Use "select USE_STM32_LL_RNG" to select the needed STM32 LL files, instead of editing ext/hal/st/stm32cube/CMakeLists.txt Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Use "select USE_STM32_LL_USB/USE_STM32_HAL_PCD/USE_STM32_HAL_PCD_EX" to select the needed STM32 HAL files, instead of editing ext/hal/st/stm32cube/CMakeLists.txt Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Use "select USE_STM32_LL_SPI" to select the needed STM32 LL files, instead of editing ext/hal/st/stm32cube/CMakeLists.txt Signed-off-by: Erwin Rol <erwin@erwinrol.com>
Update the README file to reflect the new Kconfig structure. Signed-off-by: Erwin Rol <erwin@erwinrol.com>
These commits add the possibility to select parts of the STM32 CUBE HAL/LL by simply adding a USE_STM32_xxXX_HAL_* entry to a Kconfig file. That way driver writers do not have to change the Kconfig/Kbuild files under ext/hal/. Also users can use the HAL without needing to change Zephyr code.