I know this question has been asked several times (here for example) but so far none of the replies I've found seems to apply to my situation.
On Debian stretch, gcc version 6.3.0, gcc-arm-none-eabi version 5.4.1, trying to build for a STM32L072.
Here is the Makefile I am using:
TARGET=main
TOOL_PATH=/usr/lib/gcc/arm-none-eabi/5.4.1
BLDDIR = ./src/
BINDIR = ./build
VECT_TBL = $(BLDDIR)startup.s
AS_SRC = $(BLDDIR)core.s
C_SRC = $(BLDDIR)main.c
OBJS = $(VECT_TBL:.s=.o)
OBJS += $(AS_SRC:.s=.o)
OBJS += $(C_SRC:.c=.o)
TOOL=arm-none-eabi-
CC=$(TOOL)gcc
CXX=$(TOOL)g++
LD=$(TOOL)ld
AS=$(TOOL)as
OC=$(TOOL)objcopy
OD=$(TOOL)objdump
OS=$(TOOL)size
ARCH = -mcpu=cortex-m0plus -mlittle-endian -march=armv6s-m -mthumb
COMMON_OPTS = -c -Wall
CC_OPTS = -mlong-calls -ffunction-sections --specs=nosys.specs
DBG_OPTS = -O0 -g
CCFLAGS = $(ARCH) $(COMMON_OPTS) $(CC_OPTS) $(DBG_OPTS) -DSTM32L072xx
ASFLAGS = $(ARCH) $(COMMON_OPTS)
LDFLAGS = -nostdlib
LDFLAGS += -L $(TOOL_PATH)/ -lgcc
.PHONY: all
all: $(BINDIR)/$(TARGET).bin
%.o: %.s
$(AS) $(ASFLAGS) $< -o $@
%.o: %.c
$(CC) $(CCFLAGS) $(INCLUDE) $< -o $@
$(BINDIR)/$(TARGET).elf: $(OBJS)
$(LD) $(LDFLAGS) -T $(BLDDIR)/link.ld $^ -o $@
$(BINDIR)/$(TARGET).bin: $(BINDIR)/$(TARGET).elf
$(OC) -S -O binary $< $@
$(OS) $<
.PHONY: clean
clean:
rm $(OBJS)
rm $(BINDIR)/$(TARGET).elf
I have double checked that libgcc.a exists at that path and contains the symbol with nm
, and verified with make -d
, but can't find a clue why the symbol is still not defined.
I have noticed that there are other folders containing the file libgcc.a that could match the architecture I am using:
- thumb
- armv6-m (not exactly the same name as used in
-march
but close enough to be worth a try)
but no luck so far.
Any idea about how to fix that, or to at least find some tracks?