hal_sio_lld.c source directory confusion Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
resset
Posts: 32
Joined: Thu Dec 20, 2012 11:57 pm
Has thanked: 2 times
Been thanked: 1 time

hal_sio_lld.c source directory confusion

Post by resset »

Hi,

My setup:
- ChibiOS version or subversion revision number: 21.6.0
- Compiler: GCC 10.3.0
- Platform and board: STM32H743VI, but NUCLEO144 with STM32H743ZI is also affected

I am trying to use SIO with FIFO on H7 platform. os/hal/ports/STM32/STM32H7xx/platform.mk says that this MCU family uses USARTv3 and its driver.mk file is being indeed included. However, during the compilation I can see that hal_sio_lld.c from the USARTv2 version is compiled instead:

Code: Select all

arm-none-eabi-gcc -c -mcpu=cortex-m7 -mthumb -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -ffunction-sections -fdata-sections -fno-common -flto  -Wall -Wextra -Wundef -Wstrict-prototypes -Wa,-alms=./build/lst/hal_sio_lld.lst -DCORTEX_USE_FPU=FALSE -DSTM32_ENFORCE_H7_REV_XY     -MD -MP -MF ./.dep/hal_sio_lld.o.d -I. -I./cfg -I../../../os/license -I../../../os/common/portability/GCC -I../../../os/common/startup/ARMCMx/compilers/GCC -I../../../os/common/startup/ARMCMx/devices/STM32H7xx -I../../../os/common/ext/ARM/CMSIS/Core/Include -I../../../os/common/ext/ST/STM32H7xx -I../../../os/hal/include -I../../../os/hal/ports/common/ARMCMx -I../../../os/hal/ports/STM32/STM32H7xx -I../../../os/hal/ports/STM32/LLD/ADCv4 -I../../../os/hal/ports/STM32/LLD/BDMAv1 -I../../../os/hal/ports/STM32/LLD/CRYPv1 -I../../../os/hal/ports/STM32/LLD/DACv1 -I../../../os/hal/ports/STM32/LLD/DMAv2 -I../../../os/hal/ports/STM32/LLD/EXTIv1 -I../../../os/hal/ports/STM32/LLD/FDCANv1 -I../../../os/hal/ports/STM32/LLD/GPIOv2 -I../../../os/hal/ports/STM32/LLD/I2Cv3 -I../../../os/hal/ports/STM32/LLD/MACv2 -I../../../os/hal/ports/STM32/LLD/MDMAv1 -I../../../os/hal/ports/STM32/LLD/OTGv1 -I../../../os/hal/ports/STM32/LLD/QUADSPIv2 -I../../../os/hal/ports/STM32/LLD/SDMMCv2 -I../../../os/hal/ports/STM32/LLD/SPIv3 -I../../../os/hal/ports/STM32/LLD/RNGv1 -I../../../os/hal/ports/STM32/LLD/RTCv2 -I../../../os/hal/ports/STM32/LLD/SYSTICKv1 -I../../../os/hal/ports/STM32/LLD/TIMv1 -I../../../os/hal/ports/STM32/LLD/USART -I../../../os/hal/ports/STM32/LLD/USARTv3 -I../../../os/hal/ports/STM32/LLD/USARTv2 -I../../../os/hal/ports/STM32/LLD/xWDGv1 -I../../../os/hal/boards/ST_NUCLEO144_H743ZI -I../../../os/hal/osal/rt-nil -I../../../os/rt/include -I../../../os/oslib/include -I../../../os/common/portability/GCC -I../../../os/common/ports/ARM-common -I../../../os/common/ports/ARMv7-M -I../../../test/lib -I../../../test/rt/source/test -I../../../test/oslib/source/test ../../../os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c -o build/obj/hal_sio_lld.o


I think the reason is that hal_sio_lld.c has the same name in v3 and v2 and makefiles work in a particular way. SRCPATHS list is created in the os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk file using `sort` instruction. This places UARTv2 directory before UARTv3. SRCPATHS is then copied to VPATH variable. According to the make documentation, it is used to search source files in "order in which directories are listed". This is how I get v2 LLD instead of v3 pointed by its driver.mk.

How to reproduce:
Compile RT-STM32H743ZI_REV_XY-NUCLEO144 demo with HAL_USE_SIO == TRUE in cfg/halconf.h and e.g. STM32_SIO_USE_USART2 == TRUE in cfg/mcuconf.h. There is no need to change anything else. Expected error message:

Code: Select all

../../../os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c: In function 'sio_lld_serve_interrupt':
../../../os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c:759:14: error: 'USART_ISR_RXNE' undeclared (first use in this function); did you mean 'USART_ISR_NE'?
  759 |       (isr & USART_ISR_RXNE) != 0U) {
      |              ^~~~~~~~~~~~~~
      |              USART_ISR_NE
../../../os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c:759:14: note: each undeclared identifier is reported only once for each function it appears in
../../../os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c:787:14: error: 'USART_ISR_TXE' undeclared (first use in this function); did you mean 'USART_ISR_TXFE'?
  787 |       (isr & USART_ISR_TXE) != 0U) {
      |              ^~~~~~~~~~~~~
      |              USART_ISR_TXFE
make: *** [../../../os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:190: build/obj/hal_sio_lld.o] Error 1


I can think of three solutions here: to rename v3 SIO files, to change makefile sources directory list creation or to further divide v2 and v3 version to avoid mixup. I have not enough expertise to say what should be the final fix though.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: hal_sio_lld.c source directory confusion

Post by Giovanni »

Hi,

Thanks for finding, I think I will go for duplicating files and make v3 versions of everything.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: hal_sio_lld.c source directory confusion

Post by Giovanni »

Hi,

Fixed as bug #1177.

Giovanni
Post Reply