2026-04-18 10:46 PM
Hi there, I found several issues in the STM32CubeMP2 CMSIS headers as follows:
1. Missing opening parenthesis in bitmask macros
In stm32mp21*xx.h, _Msk macro definitions were missing the opening parenthesis, leaving a dangling closing parenthesis with no matching open:
// Before #define USB_OTG_GCCFG_FSVMINUS_Msk 0x1UL << USB_OTG_GCCFG_FSVMINUS_Pos) // After #define USB_OTG_GCCFG_FSVMINUS_Msk (0x1UL << USB_OTG_GCCFG_FSVMINUS_Pos)
While the C preprocessor performs simple text substitution and the shift operation may still evaluate correctly at the call site depending on context, the unbalanced parentheses break static analyzers, automated code-generation tools, and linters that parse these headers. Adding the opening parenthesis also makes operator precedence explicit and unambiguous.
2. Malformed comment delimiters
All of header files involves inline comments used *!< instead of the correct /*!< Doxygen-style comment opener, missing the leading forward slash:
// Before #define CA35SSC_LPI_TSGEN_NTS_CR_WC1_TS_CSYSREQ_Msk (0x1UL << ..._Pos) *!< 0x00000100 */ // After #define CA35SSC_LPI_TSGEN_NTS_CR_WC1_TS_CSYSREQ_Msk (0x1UL << ..._Pos) /*!< 0x00000100 */
Without the leading /, these are not valid comments and will be interpreted as a multiplication/dereference expression by the compiler, which is both syntactically incorrect and likely to produce unexpected behavior or compilation errors.
I've submitted PRs on Feb 17 for STM32MP2 and STM32N6. The N6 issue was solved internally, but the MP2 issue still didn't respond as of today. Are there any plans to solve it?
(PR: https://github.com/STMicroelectronics/STM32CubeMP2/pull/6.)