HAL and MISRA C compliance problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-12 12:32 AM
I've started a project with HAL library using stm32cubemx. I'm using keil for my programming and I've added PC-Lint (MISRAC checker) to check C standards. But when I run PC-lint to check MISRA C rules, I will receive lots of MISRA C 2012 violation rules that arises from HAL commands. Note, I have not entered any other codes but those which generated by stm32cube.
For example the generated files contains these two lines:
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
but I receive these errors consequently:
: Note 934: Taking address of near auto variable 'GPIO_InitStruct' (arg. no. 2) [MISRA 2012 Rule 1.3, required]
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
I also receive lots of more errors either. According to this , HAL is in compliance with MISRA C 2012. What is wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-12 01:25 AM
Hello @AKhor.1​
Which STM32 series you are using?
Regards,
Amira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-12 02:31 AM
stm32f030 model
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-12 03:36 AM
Hello,
STM32 Legacy products (STM32F0) are not 100% compliant with MISRAC 2012 and no plan to do it.
PS: Once your question is answered, please click on "Select as Best" for the comment containing the answer to your initial question.
Regards,
Amira
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-12 07:47 PM
well, could you please tell me that how are you saying that? based on which reference?
according to this , even stm32f0 series HAL is in compliance with misra c 2004.
"It is compliant with MISRA C®:2004 standard."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-13 01:20 AM
Taking a pointer of local or auto variable is of course legal.
As explained here the problem is that your linter thinks that the pointer is "near".
The ARM compiler of CubeIDE has no notion of "near" data pointers, so this diagnostic is false.
--pa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-13 02:19 AM
Yes, compliant MISRA-C 2004. But not 100% compliant with MISRAC 2012 so it's normal that you had MISRA C 2012 violation rules that arises from HAL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-07-13 08:13 PM
well, in PC-lint, you have the option to check according to misra c 2004 or 2012. Either one had the same error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-10-16 03:41 AM - last edited on ‎2024-10-17 06:33 AM by Andrew Neil
I have the same issue with STM32U535, Is this also not MISRA C2012 compliant ?
Any plan to support it ?