Skip to main content
RKore.1
Associate III
March 30, 2022
Solved

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

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.

This topic has been closed for replies.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
March 30, 2022

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..

5 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
March 30, 2022

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
RKore.1
RKore.1Author
Associate III
March 30, 2022

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

Tesla DeLorean
Guru
March 30, 2022

Is it in an include file?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
TDK
March 30, 2022

> 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
RKore.1Author
Associate III
March 30, 2022

Thanks , Tesla & TDK

you are correct it was in UartRingBuffer.c