cancel
Showing results for 
Search instead for 
Did you mean: 

Compiler Warning onLL_CRC_FeedData16 and LL_SPI_TransmitData16

Kurt Alber
Associate III
Posted on February 22, 2018 at 09:49

Hi! When I compile LL code from STM32CubeMX I get following warnings:

In file included from ../Inc/main.h:45:0,

                 from ../Inc/stm32f0xx_it.h:46,

                 from ..\Src\stm32f0xx_it.c:35:

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_crc.h: In function 'LL_CRC_FeedData16':

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_crc.h:371:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

   *(uint16_t __IO *)(&CRCx->DR) = (uint16_t) InData;

   ^

In file included from ../Inc/main.h:55:0,

                 from ../Inc/stm32f0xx_it.h:46,

                 from ..\Src\stm32f0xx_it.c:35:

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_spi.h: In function 'LL_SPI_TransmitData16':

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_spi.h:1388:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

   *((__IO uint16_t *)&SPIx->DR) = TxData;

I don't use those functions therefore I comment them out, but should be fixed.

Tools:

STM32CubeMx 4.24.0 (STM32Cube V1.0)

TrueStudio V.9.0.0

Windows 7

Console Output:

**** Incremental Build of configuration Debug for project cameraApplication ****

Info: Internal Builder is used for build

arm-atollic-eabi-gcc -c -mthumb -mcpu=cortex-m0 -std=gnu11 -DUSE_FULL_LL_DRIVER -D__weak=__attribute__((weak)) -D__packed=__attribute__((__packed__)) -DSTM32F030x6 -I../Inc -IInc -ISrc -I../Drivers/STM32F0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../Drivers/CMSIS/Include -Os -ffunction-sections -fdata-sections -g -fstack-usage -Wall -specs=nano.specs -o Src\hal.o ..\Src\hal.c

arm-atollic-eabi-gcc -c -mthumb -mcpu=cortex-m0 -std=gnu11 -DUSE_FULL_LL_DRIVER -D__weak=__attribute__((weak)) -D__packed=__attribute__((__packed__)) -DSTM32F030x6 -I../Inc -IInc -ISrc -I../Drivers/STM32F0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../Drivers/CMSIS/Include -Os -ffunction-sections -fdata-sections -g -fstack-usage -Wall -specs=nano.specs -o Src\stm32f0xx_it.o ..\Src\stm32f0xx_it.c

In file included from ../Inc/main.h:45:0,

                 from ..\Src\hal.c:2:

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_crc.h: In function 'LL_CRC_FeedData16':

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_crc.h:371:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

   *(uint16_t __IO *)(&CRCx->DR) = (uint16_t) InData;

   ^

arm-atollic-eabi-gcc -c -mthumb -mcpu=cortex-m0 -std=gnu11 -DUSE_FULL_LL_DRIVER -D__weak=__attribute__((weak)) -D__packed=__attribute__((__packed__)) -DSTM32F030x6 -I../Inc -IInc -ISrc -I../Drivers/STM32F0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Device/ST/STM32F0xx/Include -I../Drivers/CMSIS/Include -Os -ffunction-sections -fdata-sections -g -fstack-usage -Wall -specs=nano.specs -o Src\epc611.o ..\Src\epc611.c

In file included from ../Inc/main.h:55:0,

                 from ..\Src\hal.c:2:

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_spi.h: In function 'LL_SPI_TransmitData16':

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_spi.h:1388:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

   *((__IO uint16_t *)&SPIx->DR) = TxData;

   ^

In file included from ../Inc/main.h:45:0,

                 from ../Inc/stm32f0xx_it.h:46,

                 from ..\Src\stm32f0xx_it.c:35:

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_crc.h: In function 'LL_CRC_FeedData16':

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_crc.h:371:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

   *(uint16_t __IO *)(&CRCx->DR) = (uint16_t) InData;

   ^

In file included from ../Inc/main.h:55:0,

                 from ../Inc/stm32f0xx_it.h:46,

                 from ..\Src\stm32f0xx_it.c:35:

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_spi.h: In function 'LL_SPI_TransmitData16':

../Drivers/STM32F0xx_HAL_Driver/Inc/stm32f0xx_ll_spi.h:1388:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

   *((__IO uint16_t *)&SPIx->DR) = TxData;

   ^

arm-atollic-eabi-gcc -o cameraApplication.elf Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_crc.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_dma.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_exti.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_gpio.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_pwr.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_rcc.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_spi.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_tim.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_usart.o Drivers\STM32F0xx_HAL_Driver\Src\stm32f0xx_ll_utils.o Src\epc611.o Src\fsm.o Src\hal.o Src\main.o Src\spi.o Src\stm32f0xx_it.o Src\system_stm32f0xx.o Src\uart.o startup\startup_stm32f030x6.o -mthumb -mcpu=cortex-m0 -T../STM32F030F4_FLASH.ld -specs=nosys.specs -static -Wl,-Map=cameraApplication.map -Wl,--gc-sections -Wl,--defsym=malloc_getpagesize_P=0x80 -Wl,--start-group -lc -lm -Wl,--end-group -specs=nano.specs

C:\TrueSTUDIO for STM32 9.0.0\ide\jre\bin\java -jar C:\TrueSTUDIO for STM32 9.0.0\Tools\arm-atollic-reports.jar sizeinfo list cameraApplication.elf

Generate build reports...

Print size information

   text       data        bss        dec        hex    filename

   5560         16       2688       8264       2048    cameraApplication.elf

Print size information done

Generate listing file

Output sent to: cameraApplication.list

Generate listing file done

Generate build reports done

Info: Parallel threads used: 3
2 REPLIES 2
Posted on February 23, 2018 at 14:11

GNU is being overly fussy, it is explicitly casting an otherwise 32-bit access on the memory to a 16-bit one (CRC depends on width of bus transaction). I remember another thread on this.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Imen.D
ST Employee
Posted on February 23, 2018 at 14:25

Hello,

Please refer to this discussion that can be helpful for you:

https://community.st.com/0D50X00009XkXPESA3

 

Best Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen