Skip to content

Commit 76ff683

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 d1d3c0c commit 76ff683

64 files changed

Lines changed: 69 additions & 121235 deletions

File tree

Some content is hidden

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

stm32cube/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ foreach(series ${supported_series})
141141
endif()
142142

143143
add_subdirectory(${cube_dir})
144+
145+
# Remember the series' name for next steps
146+
# (in the format of CONFIG_SOC_SERIES_<xxx>)
147+
set(TARGET_SERIES ${series_to_upper})
144148
endif()
145149
endforeach()
146150

@@ -151,3 +155,27 @@ endif()
151155

152156
# Add the series-agnostic LL headers to include directories
153157
zephyr_include_directories(common_ll/include)
158+
159+
# Legacy definitions header placeholder
160+
# (HAL1 only - not needed on HAL2 series)
161+
if(NOT CONFIG_STM32_HAL2)
162+
# List of series containing buggy driver(s) which need some Legacy definitions.
163+
# These series use their real Legacy definitions header - no placeholder.
164+
#
165+
# In a comment next to each series' name, please indicate:
166+
# - which driver(s) are buggy and cause build issues
167+
# - in parentheses, ST Internal Reference(s) tracking the issue(s)
168+
set(legacy_dependent_series
169+
# N.B.: no issue will occur if this list is empty
170+
STM32F7X # HAL RCC (HAL1-19491)
171+
STM32U5X # HAL PCD + LL USB (HAL1-9776)
172+
)
173+
174+
list(FIND legacy_dependent_series ${TARGET_SERIES} index)
175+
if(${index} EQUAL -1)
176+
# Series not in exclude list: use the placeholder.
177+
add_subdirectory(hal1_legacy_placeholder)
178+
else()
179+
# Target series uses its real header - don't use placeholder.
180+
endif()
181+
endif()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 STMicroelectronics
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Adds the placeholder HAL1 Legacy definitions header to include path.
5+
#
6+
# Every HAL1 package contains a file "stm32_hal_legacy.h" filled
7+
# with aliases added whenever an HAL function or macro is renamed.
8+
# This is provided for backwards compatibility but we don't have
9+
# a need for it in Zephyr: the STM32-specific code is kept aligned
10+
# with the HAL's API even when it changes. In addition to being
11+
# useless, this header also contains `#define`s that conflict with
12+
# macros provided by Zephyr, causing build errors if unpatched.
13+
#
14+
# The Legacy definitions header is included as follows by one
15+
# of the HAL's most important headers ("stm32XXXxx_hal_def.h"):
16+
#
17+
# #include "Legacy/stm32_hal_legacy.h"
18+
#
19+
# By adding the current directory in the include path, this directive
20+
# will include the placeholder file `./Legacy/stm32_hal_legacy.h` and
21+
# we can safely dispose of the real Legacy definitions header.
22+
zephyr_include_directories(.)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* SPDX-FileCopyrightText: Copyright (c) 2026 STMicroelectronics
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Dummy replacement for the HAL1 Legacy definitions header.
6+
*
7+
* This file must be named `stm32_hal_legacy.h` and be inside a directory
8+
* named `Legacy` because it is included by `stm32XXXxx_hal_def.h` using
9+
* the following directive:
10+
*
11+
* #include "Legacy/stm32_hal_legacy.h"
12+
*
13+
* Refer to `stm32cube/hal1_legacy/CMakeLists.txt` for more details.
14+
*/

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)