Skip to main content
AKhor.1
Associate II
Question

HAL and MISRA C compliance problem

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.

    8 replies

    Amira
    Visitor II

    Hello @AKhor.1​ 

    Which STM32 series you are using?

    Regards,

    Amira

    AKhor.1
    AKhor.1Author
    Associate II

    stm32f030 model

    Associate II

    I have the same issue with STM32U535, Is this also not MISRA C2012 compliant ?
    Any plan to support it ?

     

    https://community.st.com/t5/stm32cubemx-mcus/how-to-generate-misra-c-2012-compliance-bsp-and-hal-using-cuebmx/td-p/732387

    Pavel A.

    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