avrdude: stk500v2_ReceiveMessage(): timeout Error for Arduino UNO - avr

I am compiling and uploading sketch through command line. I have built a .CPP file as under:
#include< WProgram.h>
int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
digitalWrite(led, HIGH);
delay(10000);
digitalWrite(led, LOW);
delay(1000);
}
Now i compiled using command: make TARGET=file_1402814559284 and it compiled fine. When i uploaded using command: make upload TARGET=file_1402814559284
avrdude -F -p atmega328p -P \\.\COM121 -c stk500 -b 115200 -C"avrdude.conf" -U
flash:w:file_1402814559284.hex
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_command(): failed miserably to execute command 0x10
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
Please suggest me how to resolve the problem. Code is easily uploaded using arduino IDE but through command line its a problem. I am using Arduino UNO atmega328p and no wiring is done. I am just checking the uploading part.
Make file i am using:
# Arduino makefile
# $Id$
SHELL=C:/Windows/System32/cmd.exe
PORT = \\.\COM121
#/dev/tty.USB*
ARDUINO = arduino
SRC = $(ARDUINO)/buffer.c $(ARDUINO)/pins_arduino.c \
$(ARDUINO)/Serial.c $(ARDUINO)/uart.c $(ARDUINO)/wiring.c
CXXSRC = $(TARGET).cpp $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp
MCU = atmega328p
F_CPU = 16000000
FORMAT = ihex
UPLOAD_RATE = 115200
# Name of this Makefile (used for "make depend").
MAKEFILE = Makefile
# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
DEBUG = stabs
OPT = s
# Place -D or -U options here
CDEFS = -DF_CPU=$(F_CPU)
CXXDEFS = -DF_CPU=$(F_CPU)
# Place -I options here
CINCS = -I$(ARDUINO)
CXXINCS = -I$(ARDUINO)
# Compiler flag to set the C Standard level.
# c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99 - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99
CDEBUG = -g$(DEBUG)
CWARN = -Wall -Wstrict-prototypes
CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA)
CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT)
#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
LDFLAGS =
# Programming support using avrdude. Settings and variables.
AVRDUDE_PROGRAMMER = stk500
AVRDUDE_PORT = $(PORT)
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
AVRDUDE_FLAGS =-F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
-b $(UPLOAD_RATE) -C"avrdude.conf"
# Program settings
# Program settings
CC = avr-gcc
CXX = avr-g++
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
NM = avr-nm
AVRDUDE = avrdude
REMOVE = rm -f
MV = mv -f
# Define all object files.
OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: build
build: elf hex eep
elf: $(TARGET).elf
hex: $(TARGET).hex
eep: $(TARGET).eep
lss: $(TARGET).lss
sym: $(TARGET).sym
# Program the device.
upload: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
coff: $(TARGET).elf
$(COFFCONVERT) -O coff-avr $(TARGET).elf $(TARGET).cof
extcoff: $(TARGET).elf
$(COFFCONVERT) -O coff-ext-avr $(TARGET).elf $(TARGET).cof
.SUFFIXES: .elf .hex .eep .lss .sym
.elf.hex:
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $#
.elf.eep:
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $#
# Create extended listing file from ELF output file.
.elf.lss:
$(OBJDUMP) -h -S $< > $#
# Create a symbol table from ELF output file.
.elf.sym:
$(NM) -n $< > $#
# Link: create ELF output file from object files.
$(TARGET).elf: $(OBJ)
$(CC) $(ALL_CFLAGS) $(OBJ) --output $# $(LDFLAGS)
# Compile: create object files from C++ source files.
.cpp.o:
$(CXX) -c $(ALL_CXXFLAGS) $< -o $#
# Compile: create object files from C source files.
.c.o:
$(CC) -c $(ALL_CFLAGS) $< -o $#
# Compile: create assembler files from C source files.
.c.s:
$(CC) -S $(ALL_CFLAGS) $< -o $#
# Assemble: create object files from assembler source files.
.S.o:
$(CC) -c $(ALL_ASFLAGS) $< -o $#
# Target: clean project.
clean:
$(REMOVE) $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).elf \
$(TARGET).map $(TARGET).sym $(TARGET).lss \
$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
depend:
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
then \
sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
$(MAKEFILE).$$$$ && \
$(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
fi
echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
>> $(MAKEFILE); \
$(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend

Related

makefile, gcc, arm-cortex collect2.exe: error: ld returned 1 exit status

This makefile is autogenerated by STM32CubeMX. I am getting this linker error when I am using the arm-gnu-toolchain version > 9.2.1. I need to solve this problem. I cannot use the version in which the make is working fine because the openocd debugger is not compatible with arm-gnu-toolchain version 9.2.1
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.13.0-B3] date: [Thu Mar 11 18:44:56 IST 2021]
##########################################################################################################################
# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
# 2017-02-10 - Several enhancements + project update mode
# 2015-07-22 - first version
# ------------------------------------------------
######################################
# target
######################################
TARGET = Testing_fes_bms
######################################
# building variables
######################################
# debug build?
DEBUG = 1
# optimization
OPT = -Og
#######################################
# paths
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
# C sources
C_SOURCES = \
Core/Src/main.c \
Core/Src/freertos.c \
Core/Src/stm32l4xx_it.c \
Core/Src/stm32l4xx_hal_msp.c \
Core/Src/stm32l4xx_hal_timebase_tim.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \
/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_can.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \
Core/Src/system_stm32l4xx.c \
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
Middlewares/Third_Party/FreeRTOS/Source/list.c \
Middlewares/Third_Party/FreeRTOS/Source/queue.c \
Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \
Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
Middlewares/Third_Party/FreeRTOS/Source/timers.c \
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
BMS_OPERATION/BMS_OPERATION.c \
EXTERNAL_COMMUNICATION/USART_OPERATION.c \
AFE_OPERATION/AFE_OPERATION.c \
CAN_OPERATION/can.c
#===============================================#
# ASM CONFIG #
#===============================================#
# 433
#ASM_SOURCES = \
#startup_stm32l433rctxp.s
# 431
ASM_SOURCES = \
startup_stm32l431xx.s
#===============================================#
#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m4
# fpu
FPU = -mfpu=fpv4-sp-d16
# float-abi
FLOAT-ABI = -mfloat-abi=hard
# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# macros for gcc
# AS defines
AS_DEFS =
#===============================================#
# C DEFINE #
#===============================================#
# 433
#C_DEFS = \
#-DUSE_HAL_DRIVER \
#-DSTM32L433xx
# 431
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32L431xx
#===============================================#
# AS includes
AS_INCLUDES = \
-ICore/Inc
# C includes
C_INCLUDES = \
-ICore/Inc \
-IDrivers/STM32L4xx_HAL_Driver/Inc \
-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
-IMiddlewares/Third_Party/FreeRTOS/Source/include \
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
-IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
-IDrivers/CMSIS/Include \
-IAFE_OPERATION \
-IBMS_OPERATION \
-IEXTERNAL_COMMUNICATION \
-ICAN_OPERATION
# compile gcc flags
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -MMD -MP -MF"$(#:%.o=%.d)"
#===============================================#
# LINKER CONFIG #
#===============================================#
# 433
#LDSCRIPT = STM32L433RCTXP_FLASH.ld
# 431
LDSCRIPT = STM32L431CBTx_FLASH.ld
#===============================================#
# libraries
LIBS = -lc -lm -lnosys
LIBDIR =
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $#
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $#
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $#
$(SZ) $#
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $#
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $#
$(BUILD_DIR):
mkdir $#
#flash: build/Testing_fes_bms.bin
# st-flash write build/Testing_fes_bms.bin 0x8000000
# python3 reader_python.py
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)
# *** EOF ***
This is the error I am getting
PS C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN> make
arm-none-eabi-gcc build/main.o build/freertos.o build/stm32l4xx_it.o build/stm32l4xx_hal_msp.o build/stm32l4xx_hal_timebase_tim.o build/stm32l4xx_hal_adc.o build/stm32l4xx_hal_adc_ex.o build/stm32l4xx_hal_can.o build/stm32l4xx_hal.o build/stm32l4xx_hal_i2c.o build/stm32l4xx_hal_i2c_ex.o build/stm32l4xx_hal_rcc.o build/stm32l4xx_hal_rcc_ex.o build/stm32l4xx_hal_flash.o build/stm32l4xx_hal_flash_ex.o build/stm32l4xx_hal_flash_ramfunc.o build/stm32l4xx_hal_gpio.o build/stm32l4xx_hal_dma.o build/stm32l4xx_hal_dma_ex.o build/stm32l4xx_hal_pwr.o build/stm32l4xx_hal_pwr_ex.o build/stm32l4xx_hal_cortex.o build/stm32l4xx_hal_exti.o build/stm32l4xx_hal_tim.o build/stm32l4xx_hal_tim_ex.o build/stm32l4xx_hal_uart.o build/stm32l4xx_hal_uart_ex.o build/system_stm32l4xx.o build/croutine.o build/event_groups.o build/list.o build/queue.o build/stream_buffer.o build/tasks.o build/timers.o build/cmsis_os2.o build/heap_4.o build/port.o build/BMS_OPERATION.o build/USART_OPERATION.o build/AFE_OPERATION.o build/can.o build/startup_stm32l431xx.o -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nano.specs -TSTM32L431CBTx_FLASH.ld -lc -lm -lnosys -Wl,-Map=build/Testing_fes_bms.map,--cref -Wl,--gc-sections -o build/Testing_fes_bms.elf
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/stm32l4xx_it.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: multiple definition of `QUEUE_bmsqueue_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/BMS_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: multiple definition of `QUEUE_bmsqueue_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: multiple definition of `QUEUE_bmsqueue_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:65: multiple definition of `USART_RX_Queue_Data'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:65: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:64: multiple definition of `USART_TASK_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:64: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:59: multiple definition of `USART_RX_st_tag_Obj'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:59: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/AFE_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: multiple definition of `QUEUE_bmsqueue_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: first defined here
/11.3.1/thumb/v7e-m+fp/hard\libc_nano.a(libc_a-writer.o): in function `_write_r':/data/jenkins/workspace/GNU-toolchain/arm-11/src/newlib-cygwin/newlib/libc/reent/writer.c:49: warning: _write is not implemented and will always fail
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:225: build/Testing_fes_bms.elf] Error 1
This is line 225 where the error is occuring
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
$(CC) $(OBJECTS) $(LDFLAGS) -o $#
$(SZ) $#
At last, after a month I was able to resolve this issue. The error was resolved once I solved the following errors
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/stm32l4xx_it.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: multiple definition of `QUEUE_bmsqueue_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/BMS_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: multiple definition of `QUEUE_bmsqueue_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: multiple definition of `QUEUE_bmsqueue_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/BMS_OPERATION/BMS_OPERATION.h:136: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:65: multiple definition of `USART_RX_Queue_Data'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:65: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:64: multiple definition of `USART_TASK_handler'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:64: first defined here
c:/users/syedk/downloads/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/arm-gnu-toolchain-11.3.rel1-mingw-w64-i686-arm-none-eabi/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: build/USART_OPERATION.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:59: multiple definition of `USART_RX_st_tag_Obj'; build/main.o:C:\Users\syedk\Downloads\FES_BMS-v1.5.3_CAN\FES_BMS-v1.5.2_CAN/EXTERNAL_COMMUNICATION/USART_OPERATION.h:59: first defined here
The issue seems to be that the variables defined in header files need the extern keyword. If the header is included by several files it results in multiple definitions of the same variable. In previous GCC versions, this error is ignored. From GCC 10 a linker error will be reported. Hence the reason why the code was not getting compiled in arm toolchain version > 9

Fortran Makefile with 2 executables

I'm trying to compile 2 F90 files and to execute each one separately using a Makefile. The language used is fortran. I am not used to this so I need your help.
The first file is called HECESE_avec_modif.f90 and the second one is called hecese_seq.f90.
The makefile is below :
# Define dependance for suffix .FFREE
# -----------------------------------
.SUFFIXES: .exe .out .o .f .f90
#
# Compilation options for ifort
# ---------------------------------
# ---------------------------------
#FLAGS_fred = -free -O2 -traceback -mcmodel=large\
# -check overflow -check bounds
#FLAGS_fred = -FR -free -ftz -O3 -fPIC
#F90_COMPILER = /opt/intel/bin/ifort
#---------------------------------------------------------
#
# Compilation options for G95
#
#FLAGS_fred = -C -O3 -ffree-form -ffree-line-length-huge -fzero
#FLAGS_fred = -O5 -ffree-form -ffree-line-length-huge -fzero
#F90_COMPILER = g95
#
# Compilation options for GFortran
FLAGS_fred = -ffree-form -ffree-line-length-none -O3 #-march=native
F90_COMPILER = gfortran -m64
F90_COMPILER7 = gfortran-7 -m64
#FLAGS_fred = -O3
#F90_COMPILER = gfortran
#FLAGS_CPPFOR = -L/usr/local/gfortran/lib/x86_64/
#
#
#FLAGS_fred = -free -O4
#
#
# ***************************************************
# ***************************************************
# ** **
# ** definition of file groups for F. Waymel **
# ** **
# ***************************************************
# ***************************************************
#
# 0.) group of all modules containing common variables
# for multiblocs initialisation
# ----------------------------------------------------
#
MAIN = HECESE_avec_modif.f90
MAIN2 = hecese_seq.f90
#
# Compilation of object files :
# -----------------------------
#
MAIN_OBJ =$(MAIN:.f90=.o)
MAIN_OBJ2 =$(MAIN2:.f90=.o)
# Creation of executable:
# ---------------------------------
#
#DEST1 = ~/bin
EXEC = hecesevfinale.out
EXEC2 = heceseseq.out
all : $(EXEC) $(EXEC2)
$(EXEC):$(MAIN_OBJ)
$(F90_COMPILER) -g $(FLAGS_fred) -o $(EXEC) $(MAIN_OBJ)
$(EXEC2):$(MAIN_OBJ2)
$(F90_COMPILER) -g $(FLAGS_fred) -o $(EXEC2) $(MAIN_OBJ2)
#
%.o : %.mod
.f90.o:
$(F90_COMPILER) -g $(FLAGS_fred) -c $<
# $(F90_COMPILER) -g $(FLAGS_fred) -c $<
%.o : %.mod
.f90.o:
$(F90_COMPILER) -g $(FLAGS_fred) -c $<
# $(F90_COMPILER) -g $(FLAGS_fred) -c $<
clean:
rm -f *.o *.mod *.out
#depend .depend:
# makedepf90 metas.f90 $(SOURCES90_fred1) $(SOURCES90_fred2) $(SOURCES90_mwl) $(SOURCES90_mwl2) > .depend
#include .depend
I think that I made a mistake related to the second file.
The message I get when I execute this makefile is :
gfortran -m64 -g -ffree-form -ffree-line-length-none -O3 -o hecesevfinale.out HECESE_avec_modif.o
make: *** No rule to make target 'hecese_seq.o', needed by 'heceseseq.out'. Stop.
I have another problem when I try to execute make clean.
I get :
makefile:82: warning: overriding recipe for target '.f90.o'
makefile:76: warning: ignoring old recipe for target '.f90.o'
Can you help me, please ?

Undefined reference to `compress2' and other functions in the HDF5 library

I am trying to make a code called iPIC3D and it has some prerequisite libraries such as HDF5, H5hut etc. I did everything as instructed. One has to install all the prerequisites and then run the "make" command. But while running the make command, I get a series of errors such as
/usr/local/hdf5/1.8.11-par/lib/libhdf5.a(H5Zdeflate.o): In function `H5Z_filter_deflate':
H5Zdeflate.c:(.text+0xf1): undefined reference to `compress2'
H5Zdeflate.c:(.text+0x1af): undefined reference to `inflateInit_'
H5Zdeflate.c:(.text+0x1c9): undefined reference to `inflate'
H5Zdeflate.c:(.text+0x27a): undefined reference to `inflateEnd'
H5Zdeflate.c:(.text+0x2dc): undefined reference to `inflateEnd'
H5Zdeflate.c:(.text+0x3de): undefined reference to `inflateEnd'
collect2: error: ld returned 1 exit status
make: *** [main] Error 1
Here is a copy of my makefile for reference
PIC_HOME = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
## SECTION THAT DEPENDS ON THE SYSTEM
# -- Modify this variables according
# -- to your system options.
# -- Possible flags:
# -DPARALLEL_IO Use parallel HDF5
# -DUSEH5HUT Use H5hut (must include also -DPARALLEL_IO)
# -DBATSRUS Coupling with BATS-R-US
CXX = mpicxx
HDF5_HOME = /usr/local/hdf5/1.8.11-par
H5HUT_HOME = /usr/local/H5hut/1.8.11
IPIC_FLAGS = "-DUSEH5HUT -DPARALLEL_IO"
## END OF SECTION
OPTIM = -O3
HDF5_LIB = $(HDF5_HOME)/lib/libhdf5_hl.a $(HDF5_HOME)/lib/libhdf5.a
H5HUT_LIB = $(H5HUT_HOME)/lib/libH5hut.a
H5HUTIO_LIB = $(IPIC_HOME)/H5hut-io/libH5hut-io.a
INC_DIR = ./include
INC_H5HUT = $(H5HUT_HOME)/include
INC_H5HUTIO = $(IPIC_HOME)/H5hut-io/include
INC_HDF5 = $(HDF5_HOME)/include
.SUFFIXES:
.SUFFIXES: .cpp .o .h
SRC = \
$(IPIC_HOME)/grids/Grid3DCU.cpp \
$(IPIC_HOME)/fields/BCStructure.cpp \
$(IPIC_HOME)/fields/EMfields3D.cpp \
$(IPIC_HOME)/inputoutput/phdf5.cpp \
$(IPIC_HOME)/inputoutput/Restart3D.cpp \
$(IPIC_HOME)/inputoutput/ParallelIO.cpp \
$(IPIC_HOME)/inputoutput/Collective.cpp \
$(IPIC_HOME)/performances/Timing.cpp \
$(IPIC_HOME)/PSKOutput3D/PSKhdf5adaptor.cpp \
$(IPIC_HOME)/bc/BcParticles.cpp \
$(IPIC_HOME)/bc/BcFields3D.cpp \
$(IPIC_HOME)/mathlib/EllipticF.cpp \
$(IPIC_HOME)/solvers/CG.cpp \
$(IPIC_HOME)/solvers/GMRES.cpp \
$(IPIC_HOME)/ConfigFile/src/ConfigFile.cpp \
$(IPIC_HOME)/main/iPic3Dlib.cpp \
$(IPIC_HOME)/particles/Particles3Dcomm.cpp \
$(IPIC_HOME)/particles/Particles3D.cpp \
$(IPIC_HOME)/communication/ComNodes3D.cpp \
$(IPIC_HOME)/communication/ComParser3D.cpp \
$(IPIC_HOME)/communication/ComInterpNodes3D.cpp \
$(IPIC_HOME)/communication/ComParticles3D.cpp \
ALLOBJ = $(subst .cpp,.o,$(SRC))
IPIC3D_EXE = $(IPIC_HOME)/iPic3D
IPIC3D_LIB = $(IPIC_HOME)/libiPic3Dlib.a
LDLIBS = $(IPIC3D_LIB) $(H5HUTIO_LIB) $(H5HUT_LIB) $(HDF5_LIB) -ldl
all : io lib main
io :
CXX=$(CXX) HDF5_HOME=$(HDF5_HOME) H5HUT_HOME=$(H5HUT_HOME) IPIC_FLAGS=$(IPIC_FLAGS) $(MAKE) -C $(IPIC_HOME)/H5hut-io
lib : $(ALLOBJ)
$(AR) sr $(IPIC3D_LIB) $(ALLOBJ)
ranlib $(IPIC3D_LIB)
main : iPic3D.o
$(CXX) $(LDFLAGS) -I$(INC_DIR) -I$(INC_HDF6) iPic3D.cpp -o $(IPIC3D_EXE) $(LDLIBS)
clean : cleanio
$(RM) $(ALLOBJ)
$(RM) $(IPIC3D_LIB)
$(RM) iPic3D.o
$(RM) $(IPIC3D_EXE)
cleanio :
$(MAKE) -C $(IPIC_HOME)/H5hut-io clean
%.o : %.cpp
echo " Compiling " $#
$(CXX) $(CXXFLAGS) $(OPTIM) $(IPIC_FLAGS) -I$(INC_DIR) -I$(INC_H5HUTIO) -I$(INC_H5HUT) -I$(INC_HDF5) -c $< -o $#
I am unable to understand what exactly is causing this problem.
I would say you are missing linking in the libz library as this is where the compress2 function should come from. Try adding -lz to your LDLIBS.

Gfortran compiling error after replacing with f77

QI need to compile some files using gfortran. I went to the makefile and replaced all the "f77" with "gfortran". However I get this error when I do "make"
gfortran -c verbal.f
gfortran -c trgl6_octa.f
gfortran -c trgl6_icos.f
gfortran -c gauss_trgl.f
gfortran -c gauss_leg.f
gfortran -c sgf_3d_fs.f
gfortran -c sgf_3d_w.f
f77 -c -o sgf_3d_2p_w.o sgf_3d_2p_w.f
make: f77: Command not found
make: *** [sgf_3d_2p_w.o] Error 127
I do not understand where in the make file (pasted below) there is a hidden f77 that did not get replaced. I checked all the sources files for "f77" and there was none. I am very confused.
#
# Objects
# -------
#
OBJ0 = verbal.o
OBJ1 = trgl6_octa.o trgl6_icos.o gauss_trgl.o gauss_leg.o
OBJ2 = sgf_3d_fs.o sgf_3d_w.o sgf_3d_2p_w.o
OBJ2A = sgf_3d_3p.o sgf_3d_3p_ewald.o sgf_3d_3p_qqq.o
OBJ3 = prtcl_3d_mob.o
OBJ30 = elm_geom.o abc.o interp_p.o printel.o
OBJ33 = slp_trgl6.o slp_trgl6_sing.o slp_trgl3_sing.o
OBJ4 = gel.o gel_inv.o
OBJ = $(OBJ0) $(OBJ1) $(OBJ2) $(OBJ2A) $(OBJ3) $(OBJ30) $(OBJ33) $(OBJ4)
#
# link
# ----
#
prtcl_3d_mob: $(OBJ)
gfortran -c prtcl_3d_mob $(OBJ)
#
# compile
# ------
#
prtcl_3d_mob.o: prtcl_3d_mob.f
gfortran -c prtcl_3d_mob.f
trgl6_octa.o: trgl6_octa.f
gfortran -c trgl6_octa.f
trgl6_icos.o: trgl6_icos.f
gfortran -c trgl6_icos.f
verbal.o: verbal.f
gfortran -c verbal.f
sgf_3d_fs.o: sgf_3d_fs.f
gfortran -c sgf_3d_fs.f
sgf_3d_w.o: sgf_3d_w.f
gfortran -c sgf_3d_w.f
sgf_3d_3p.o: sgf_3d_3p.f
gfortran -c sgf_3d_3p.f
sgf_3d_3p_ewald.o: sgf_3d_3p_ewald.f
gfortran -c sgf_3d_3p_ewald.f
sgf_3d_3p_qqq.o: sgf_3d_3p_qqq.f
gfortran -c sgf_3d_3p_qqq.f
gel.o: gel.f
gfortran -c gel.f
gel_inv.o: gel_inv.f
gfortran -c gel_inv.f
prtcl_3d_geo.o: prtcl_3d_geo.f
gfortran -c prtcl_3d_geo.f
interp_p.o: interp_p.f
gfortran -c interp_p.f
abc.o: abc.f
gfortran -c abc.f
printel.o: printel.f
gfortran -c printel.f
elm_geom.o: elm_geom.f
gfortran -c elm_geom.f
slp_trgl6.o: slp_trgl6.f
gfortran -c slp_trgl6.f
slp_trgl6_sing.o: slp_trgl6_sing.f
gfortran -c slp_trgl6_sing.f
slp_trgl3_sing.o: slp_trgl3_sing.f
gfortran -c slp_trgl3_sing.f
gauss_leg.o: gauss_leg.f
gfortran -c gauss_leg.f
gauss_trgl.o: gauss_trgl.f
gfortran -c gauss_trgl.f
#
# clean
# -----
#
clean:
rm -f core
rm -f $(OBJ) prtcl_3d_mob
rm -f prtcl_3d_mob.net prtcl_3d_mob.out
rm -f matrix_inverse.out
rm -f particle_elements.out
#
# purge
# ---
#
purge:
rm -f core
rm -f $(OBJ) prtcl_3d_mob
rm -f prtcl_3d_mob.net prtcl_3d_mob.out
rm -f matrix_inverse.out
rm -f particle_elements.out
#
# clobber
# ---
#
clobber:
rm *
#
# all
# ---
#
all:
make prtcl_3d_mob
GNU make has a number of implicit rules https://www.gnu.org/software/make/manual/make.html#Catalogue-of-Rules
By default, it will compile .f files with the rule $(FC) $(FFLAGS) -c where by default FC is set to f77 (see link above for all of this).
As an explicit rule ("from .f to .o") is not found for a file, make invokes the default rule.
Solutions: either one of the two
Set FC to gfortran
add an explicit rule for sgf_3d_2p_w.o
In general, I write the rule myself as
%.o: %.f90
$(FC) $(FFLAGS) -c $<
in the Makefile. It makes it obvious that I need to define FC and FFLAGS.
Also, you can then remove all of the individual rules for compiling your files.

running linker in bare-metal arm example and linker can't find the loader file which exists

I found a bare-metal example for a board different from mine so I will have to modify the loader script but for now I just want to be able to compile and link the example as it is.
I copied the arm-none-eabi cross-compiler to the directory just above c_blinky which is where the source files are.
(I have a diagram of the directory structure on a page on my website)
Here's the makefile:
ifeq ($(GNU_ARM),)
GNU_ARM = ../arm-none-eabi/bin
endif
CC := $(GNU_ARM)/arm-none-eabi-gcc
CPP := $(GNU_ARM)/arm-none-eabi-g++
ASM := $(GNU_ARM)/arm-none-eabi-as
LINK := $(GNU_ARM)/arm-none-eabi-gcc
BIN := $(GNU_ARM)/arm-none-eabi-objcopy
RM := rm -rf
MKDIR := mkdir
BLDDIR = .
CCINC = -I$(BLDDIR)
APP_DEP = $(BLDDIR)/bsp.h \
$(BLDDIR)/arm_exc.h \
$(BLDDIR)/isr.h
APP_NAME = blinky
ARM_CORE = arm7tdmi
ifeq (rel, $(CONF)) # Release configuration
BINDIR = rel
CCFLAGS = -c -mcpu=$(ARM_CORE) -mthumb-interwork -Os \
-mlong-calls -ffunction-sections -Wall -DNDBEBUG -o$#
ASMFLAGS = -mcpu=$(ARM_CORE) -mthumb-interwork -o$#
LINKFLAGS = -T .\$(APP_NAME).ld -o $(BINDIR)\$(APP_NAME).elf \
-Wl,-Map,$(BINDIR)\$(APP_NAME).map,--cref,--gc-sections
else # default Debug configuration
BINDIR = dbg
CCFLAGS = -g -c -mcpu=$(ARM_CORE) -mthumb-interwork -O \
-mlong-calls -ffunction-sections -Wall -o$#
ASMFLAGS = -g -mcpu=$(ARM_CORE) -mthumb-interwork -o$#
LINKFLAGS = -T .\$(APP_NAME).ld -o $(BINDIR)\$(APP_NAME).elf \
-Wl,-Map,$(BINDIR)\$(APP_NAME).map,--cref,--gc-sections
endif
all: $(BINDIR)/$(APP_NAME).bin
$(BINDIR)/$(APP_NAME).bin : $(BINDIR)/$(APP_NAME).elf
$(BIN) -O binary $(BINDIR)/$(APP_NAME).elf $(BINDIR)/$(APP_NAME).bin
$(BINDIR)/$(APP_NAME).elf : \
./$(APP_NAME).ld \
$(BINDIR)/startup.o \
$(BINDIR)/arm_exc.o \
$(BINDIR)/low_level_init.o \
$(BINDIR)/isr.o \
$(BINDIR)/bsp.o \
$(BINDIR)/blinky.o
$(LINK) \
$(BINDIR)/startup.o \
$(BINDIR)/arm_exc.o \
$(BINDIR)/low_level_init.o \
$(BINDIR)/isr.o \
$(BINDIR)/bsp.o \
$(BINDIR)/blinky.o \
$(LINKFLAGS)
$(BINDIR)/startup.o: $(BLDDIR)/startup.s
$(ASM) $(ASMFLAGS) $<
$(BINDIR)/arm_exc.o: $(BLDDIR)/arm_exc.s
$(ASM) $(ASMFLAGS) $<
# choose the ARM or THUMB compilation for each module...
$(BINDIR)/low_level_init.o: $(BLDDIR)/low_level_init.c $(APP_DEP)
$(CC) -marm $(CCFLAGS) $(CCINC) $<
$(BINDIR)/isr.o: $(BLDDIR)/isr.c $(APP_DEP)
$(CC) -marm $(CCFLAGS) $(CCINC) $<
$(BINDIR)/bsp.o: $(BLDDIR)/bsp.c $(APP_DEP)
$(CC) -mthumb $(CCFLAGS) $(CCINC) $<
$(BINDIR)/blinky.o: $(BLDDIR)/blinky.c $(APP_DEP)
$(CC) -mthumb $(CCFLAGS) $(CCINC) $<
I set GNU_ARM in the makefile to ../arm-none-eabi/bin and ran make and got the following error:
(the file blinky.ld does exist in the source directory)
../arm-none-eabi/bin/arm-none-eabi-gcc \
dbg/startup.o \
dbg/arm_exc.o \
dbg/low_level_init.o \
dbg/isr.o \
dbg/bsp.o \
dbg/blinky.o \
-T .\blinky.ld -o dbg\blinky.elf -Wl,-Map,dbg\blinky.map,--cref,--gc-sections
/home/dan/dev/compile/bare-metal/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: cannot open linker script file .blinky.ld: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [dbg/blinky.elf] Error 1
I thought the LINK assignment at the beginning should be:
LINK := $(GNU_ARM)/arm-none-eabi-ld
and not
LINK := $(GNU_ARM)/arm-none-eabi-gcc
and I got:
../arm-none-eabi/bin/arm-none-eabi-ld \
dbg/startup.o \
dbg/arm_exc.o \
dbg/low_level_init.o \
dbg/isr.o \
dbg/bsp.o \
dbg/blinky.o \
-T .\blinky.ld -o dbg\blinky.elf -Wl,-Map,dbg\blinky.map,--cref,--gc-sections
../arm-none-eabi/bin/arm-none-eabi-ld: cannot open linker script file .blinky.ld: No such file or directory
make: *** [dbg/blinky.elf] Error 1
It looks like arm-none-eabi-gcc is calling collect2 in lib/gcc/arm-none-eabi/4.9.3 which in turn calls ld which is not in the main bin directory:
/home/dan/dev/compile/bare-metal/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld:
I tried making a symbolic link to arm-none-eabi-ld as ld and got the same error.

Resources