cancel
Showing results for 
Search instead for 
Did you mean: 

Uart Circular buffer , Error while building using Nucleo 429zi Just did what is in the video in the link https://controllerstech.com/ring-buffer-using-head-and-tail-in-stm32/ The error is as shown in the details

RKore.1
Associate II

arm-none-eabi-gcc -o "Uart_Ring_Buffer.elf" @"objects.list"  -mcpu=cortex-m4 -T"C:\Users\User\STM32CubeIDE\workspace_1.8.0\Uart_Ring_Buffer\STM32F429ZITX_FLASH.ld" --specs=nosys.specs -Wl,-Map="Uart_Ring_Buffer.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group

c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.0.202111181127\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/main.o:C:/Users/User/STM32CubeIDE/workspace_1.8.0/Uart_Ring_Buffer/Debug/../Core/Src/main.c:50: multiple definition of `huart2'; ./Core/Src/UartRingbuffer.o:C:/Users/User/STM32CubeIDE/workspace_1.8.0/Uart_Ring_Buffer/Debug/../Core/Src/UartRingbuffer.c:15: first defined here

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:64: Uart_Ring_Buffer.elf] Error 1

"make -j8 all" terminated with exit code 2. Build might be incomplete.

1 ACCEPTED SOLUTION

Accepted Solutions

Error says you defined a variable in two files. Need to not do that​.

Decide where you want it, and use extern elsewhere.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5

Error says you defined a variable in two files. Need to not do that​.

Decide where you want it, and use extern elsewhere.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
RKore.1
Associate II

After searching huart2 in my code as shown below , I use extern as you mention

Do you see any error (multiple definition of `huart2';) ?


_legacyfs_online_stmicro_images_0693W00000LwI2PQAV.png

Is it in an include file?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

> multiple definition of `huart2';

> ./Core/Src/UartRingbuffer.o:C:/Users/User/STM32CubeIDE/workspace_1.8.0/Uart_Ring_Buffer/Debug/../Core/Src/UartRingbuffer.c:15: first defined here

The error indicates that you've defined huart2 in UartRingbuffer.c on line 15. It shouldn't be defined there. Use extern. Would be easier to spot the error if you attached the relevant files.

If you feel a post has answered your question, please click "Accept as Solution".
RKore.1
Associate II

Thanks , Tesla & TDK

you are correct it was in UartRingBuffer.c