Skip to content

Commit 5a56062

Browse files
stm32cube: remove HAL Legacy definitions header from build files
Remove the HAL Legacy definitions header from most series using a dummy replacement (shared by all series!) to ensure proper compilation despite the missing file, and update the README of affected series to remove entry documenting patches to the HAL Legacy definitions header. While it at, get rid of all other legacy headers (can_legacy / eth_legacy) which Zephyr never uses. This is purely cosmectic as these headers are only used if the corresponding HAL module is enabled but Zephyr has never enabled (and will never enable!) the CAN_LEGACY or ETH_LEGACY modules. The STM32F7 and STM32U5 series are not modified and will continue to use their current (patched) HAL Legacy definitions header: some drivers have not been updated(!) and require legacy definitions to build... Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
1 parent 8025363 commit 5a56062

File tree

63 files changed

+55
-120723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+55
-120723
lines changed

stm32cube/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ foreach(series ${supported_series})
129129
)
130130

131131
add_subdirectory(${cube_dir})
132+
133+
# Remember the series' name for next steps
134+
# (in the format of CONFIG_SOC_SERIES_<xxx>)
135+
set(TARGET_SERIES ${series_to_upper})
132136
endif()
133137
endforeach()
134138

@@ -139,3 +143,45 @@ endif()
139143

140144
# Add the series-agnostic LL headers to include directories
141145
zephyr_include_directories(common_ll/include)
146+
147+
# Add placeholder for STM32Cube HAL Legacy definitions header
148+
#
149+
# The STM32Cube packages contain header "stm32_hal_legacy.h"
150+
# which provides aliases of old definitions that have been
151+
# changed/renamed for backwards compatibility. This is not
152+
# useful to Zephyr since the STM32 drivers are maintained
153+
# and never use "legacy" STM32Cube APIs or definitions.
154+
# More annoyingly, some definitions provided by the legacy
155+
# header alias with ones provided by Zephyr which results
156+
# in build failures. As such, we'd like to get rid of this
157+
# header whenever possible...
158+
#
159+
# Unfortunately, the "stm32XXXxx_hal_def.h" header contains:
160+
#
161+
# #include "Legacy/stm32_hal_legacy.h"
162+
#
163+
# To ensure this directive does not cause a build failure
164+
# due to the legacy header no longer existing, we add a
165+
# carefully crafted directory to the include path such
166+
# that an empty header file is included by this directive.
167+
# We can then get rid of the legacy header entirely!
168+
#
169+
# ...except that HAL drivers of some series are using the
170+
# legacy definitions, so we keep an escape hatch for such
171+
# series even though their drivers are in the wrong.
172+
set(series_with_legacy_header
173+
# Please provide a comment next to series name indicating
174+
# which driver(s) are faulty and the ST Internal Reference
175+
# used to track the issue.
176+
177+
STM32F7X # HAL RCC (ST Internal Reference: 220413)
178+
STM32U5X # HAL PCD + LL USB
179+
)
180+
181+
list(FIND series_with_legacy_header ${TARGET_SERIES} index)
182+
if(${index} EQUAL -1)
183+
# Series without legacy header: add placeholder to include path
184+
zephyr_include_directories(legacy_placeholder)
185+
else()
186+
# Series with legacy header: it's already in the include path!
187+
endif()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* Dummy replacement for HAL Legacy definitions header (c.f. CMakeLists.txt) */

stm32cube/stm32c0xx/README

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,4 @@ Patch List:
4040
-Added stm32cube/stm32c0xx/drivers/include/stm32_assert.h
4141
-Removed unused stm32cube/stm32c0xx/drivers/include/stm32_assert_template.h
4242

43-
*Fix to remove PAGESIZE definition which conflicts with POSIX
44-
Impacted files:
45-
drivers/include/Legacy/stm32_hal_legacy.h
46-
4743
See release_note.html from STM32Cube

0 commit comments

Comments
 (0)