Skip to main content
Visitor II
July 12, 2021
Question

HAL and MISRA C compliance problem

  • July 12, 2021
  • 2 replies
  • 4367 views

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?

    This topic has been closed for replies.

    2 replies

    Visitor II
    July 12, 2021

    Hello @AKhor.1​ 

    Which STM32 series you are using?

    Regards,

    Amira

    AKhor.1Author
    Visitor II
    July 12, 2021

    stm32f030 model

    Visitor II
    July 12, 2021

    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

    Super User
    July 13, 2021

    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