2024-10-17 06:11 AM
Currently I am using CuebMX version 6.12 and tried generating BSP and HAL code for STM32U535RBT6 controller.
But the generated code is not MISRA C 2012 compliant. How do I generate MISRA C 2012 compliance code?
2024-10-17 06:25 AM
2024-10-17 06:26 AM
Hello @Vishal58, welcome to ST Community,
According to UM2911 "Description of STM32U5 HAL and low-layer drivers", "It is compliant with MISRA C®:2012 standard."
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-10-17 06:29 AM
How do we know if STM32U535RBT6 fall under STM32 legacy products ?
2024-10-17 06:45 AM
But I get a lot of errors while running my static code analysis tool.
For example.
Header files are generated with __Filename_H__ and I get error as "MISRA C:2012 21.1 (Required) #define and #undef shall not be used on a reserved identifier or reserved macro name. The macro '__Filename_H__ ' shall not be defined."
Many HAL related macros start with __ which is not as per MISRA C 2012 standards.
I just checked the STM32CubeU5 code also there also I could see
__STM32U5xx_HAL_VERSION_MAIN macros defined and using __STM32U5xx_HAL_H header guards.
Not sure if the UM2911 is not correct or the way we generate code has to be changed for MISRA C 2012 compliance.
2024-10-17 07:06 AM
@Vishal58 wrote:#define and #undef shall not be used on a reserved identifier or reserved macro name.
The leading underscores are reserved to "The System".
I guess it could be argued that HAL is considered part of "The System" ... ?
2024-10-17 10:05 AM
>>How do I generate MISRA C 2012 compliance code?
You get to OWN the source, per the license, and get to audit it, and waiver the things you're unwilling to change, with reasoning.
Most of the people I know can't take the liability on any third-party code, and ST's going to have you indemnify them, not the other way around.
People dealing with highly critical code, develop it in house, from the ground up. They use compilers running $10K+/seat, not GNU/GCC flavour du-jour
2024-10-18 01:39 AM
@Sarra.S Can ST provide any update for this MISRA C 2012 compliance ?
2024-10-18 02:18 AM
This is a user-to-user forum; If you want direct support from ST, raise a case here: https://ols.st.com/s/
Or maybe contact your local Distributor:
https://www.st.com/content/st_com/en/support/support-home.html
2024-10-25 06:46 AM
Thank you @Andrew Neil , I have raised a case and it is still not yet resolved.