cancel
Showing results for 
Search instead for 
Did you mean: 

HAL and MISRA C compliance problem

AKhor.1
Associate II

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?

7 REPLIES 7
Amira
Associate III

Hello @AKhor.1​ 

Which STM32 series you are using?

Regards,

Amira

stm32f030 model

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

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."

Pavel A.
Evangelist III

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

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.

well, in PC-lint, you have the option to check according to misra c 2004 or 2012. Either one had the same error.