Automatically enable used HAL driver modules#315
Automatically enable used HAL driver modules#315shoftmadder wants to merge 3 commits intoObKo:masterfrom
Conversation
|
Hello @shoftmadder, That's a nice catch ! I never noticed that! Can you change the exemples, in particular blinky, so it uses your change ? |
|
Yep, I can modify the examples -- something along the lines of this in the various And then comment out all of the As an aside, I could never work out exactly what needed including in what order to use the hal drivers as individual headers, which is probably why I noticed this! |
936ecf8 to
23d1996
Compare
|
Cool I think that's good now If it matters, I'm assigning all rights to the authors of this project |
examples/blinky/CMakeLists.txt
Outdated
| target_link_libraries(stm32-blinky-f4 | ||
| HAL::STM32::F4::RCC | ||
| HAL::STM32::F4::GPIO | ||
| HAL::STM32::F4::FLASH |
There was a problem hiding this comment.
I believe there is a slight difference as now flash.c is compiled.
Before your change, only flash.h was included but flash.c not built.
There was a problem hiding this comment.
Ooh, good catch. Not sure how best to address this?
There was a problem hiding this comment.
It's not an issue from my point of view we can live with it. Will see with @Hish15
However, have a look at workflow failure
There was a problem hiding this comment.
The root cause is that:
- The STM32 modules depend on each others' headers, but
- The modules only include
stm32fxx_hal.h(rather than the headers they actually need), and stm32fxx_hal.honly includes headers (viastm32fxx_hal_conf.h) for enabled modules (HAL_XYZ_MODULE_ENABLED)
Having thought about it, the options I can see are:
- Explicitly encode the dependencies somewhere, so that each driver module sets
HAL_XYZ_MODULE_ENABLEDfor both itself and also its dependencies.- A lot of work, and potentially a bit fragile, but not impossible.
- Could test by enabling only one driver module at a time, and checking it builds -- but this wouldn't test that the dependencies are minimal
- Add an "enable only" target (e.g.
HAL::STM32::F4::ENABLE_FLASH) so that the user can enable the headers for any modules that are depended upon, without needing to build the corresponding.cfile - Leave it like this -- the driver module
.cfiles don't take that long to compile anyway
2 and 3 have the downside of leaving the header dependencies up to the user, but this is currently the case with stm32fxx_hal_conf.h anyway
|
@shoftmadder #317 workflow builds fine. You will have to find out why test fails on MP1 and G0 families with your change. |
23d1996 to
5a3620f
Compare
Problems are due to modules being enabled ( G0The HCD module is broken in older versions of These tests work on Obviously, on this branch, The HCD module is fixed in Recommended solution -- move to a non-broken version of STM32CubeG0 in the test environment MP1For MP1, the MDIOS module is the broken in varied and interesting ways. There doesn't appear to be a working version.
I've modified |
It's not only for test environment. You must update lines 47-49 from utilities.cmake for doing that About MP1: having Thinking out loud: user is asking for specific (sometimes all) components in |
Currently, to add a driver module to a project, you have to: - Add the driver module in `CMakeLists.txt` - Set the driver module enabled (e.g. in a HAL config file, such as `stm32f4xx_hal_conf.h`) by defining `HAL_<DRIVER>_MODULE_ENABLED` (e.g. `HAL_GPIO_MODULE_ENABLED`) This change: - Adds `<DRIVER>_ENABLE` targets for each driver, which define `HAL_<DRIVER>_MODULE_ENABLED` - Makes each `<DRIVER>` target depend on the `DRIVER_<ENABLE>` target (so that used modules are automatically enabled) This means that enabling drivers is done directly in `CMakeLists.txt`, rather than needing to be done in two locations (both `CMakeLists.txt` and `stm32f4xx_hal_conf.h`)
By default, the list of drivers available for a family is deduced from
the `.c` files which are present. However, some drivers appear to have
been included by accident and are broken (e.g. the `MDIOS` drivers for
the MP1 family
Add:
- Exclude lists for drivers (`EXCLUDED_HAL_DRIVERS_<FAMILY>`)
- The ability for users to override this exclude list if required
(through `EXCLUDED_HAL_DRIVERS_<FAMILY>_OVERRIDE`)
- Seting `EXCLUDED_HAL_DRIVERS_<FAMILY>_OVERRIDE` to the empty
string will force all modules to be enabled.
Also, exclude the `MDIOS` drivers for STM32 MP1 by default. The HAL
driver for this IP is broken in the current release (1.6.0)
5a3620f to
a20e6ec
Compare
|
I've added The I've also added the ability to exclude drivers from autodetection -- this means that the (broken) MDIOS driver can be excluded for the MP1 family. Finally, I bumped the I think, with these changes, the tests should pass |
|
I'm a bit mitigated, this is not exactly what I meant. |
The HCD driver is broken in: - `STM32CubeG0 < 1.5.0` - `stm32g0xx_hal_driver < 1.4.2`
a20e6ec to
aee1213
Compare
|
I didn't like the solution of enabling all searched-for HAL modules by default -- I am approaching as "doing in cmake what you are doing in And, manually enabling modules in |
|
@shoftmadder Thanks for the changes, I will discuss this with @atsju. I think I understand your thought process, but I'm not sure about the Cya |
|
I would like to add that if you use a tool like STM32 CubeMX it automatically does that for you: changing the |
Currently, to add a driver module to a project, you have to:
CMakeLists.txtstm32f4xx_hal_conf.h)This change automatically sets the driver module enable definition when a module is included in
CMakeLists.txt, meaning that you don't also have to edit a header file to enable the module.