This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

No binary output from objcopy

Hello!

I am trying to make a bin image of my application for me to flash it into my ARM Cortex M0 processor. I have succeeded in outputting an elf  image, but failed with converting it to a bin with the arm-none-eabi-objcopy tool. Here is the line from the makefile:

%.$(TARGET).bin: %.$(TARGET).elf
	$(TRACE_OBJCOPY)
	$(Q)$(OBJCOPY) -O binary $< $@

Here is all of my Makefile.

#Set the toolchain program names.
CC = arm-none-eabi-gcc
AR = arm-none-eabi-ar
AS = arm-none-eabi-as
LD = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy


#Set the processor related flags (common to C code and linker).
CPUFLAGS += -mcpu=cortex-m0plus -mthumb -mfloat-abi=soft
CPUFLAGS += -specs=nano.specs -specs=nosys.specs


#Set common C code flags.
CFLAGS += -D__SAMD21G18A__=1
CFLAGS += -Wall -g -ffunction-sections -fdata-sections -O2
CFLAGS += $(CPUFLAGS)



#Set the linker flags.
LDFLAGS += -Wl,--gc-sections
LDFLAGS += -Wl,-T$(CONTIKI_CPU)/atsamd21g18a.ld -lc
LDFLAGS += -Wl,-Map=$(OBJECTDIR)/$(CONTIKI_PROJECT).map
LDFLAGS += $(CPUFLAGS)


#Configure the CPU path and source files.
CONTIKI_CPU_DIRS += .
CONTIKI_CPU_DIRS += dev
CONTIKI_CPU_DIRS += samd21dfp/
CONTIKI_CPU_DIRS += samd21dfp/samd21a/include
CONTIKI_CPU_DIRS += samd21dfp/samd21a/include/component
CONTIKI_CPU_DIRS += samd21dfp/samd21a/include/instance
CONTIKI_CPU_DIRS += ../arm/common/CMSIS


CONTIKI_SOURCEFILES += samd21-startup.c clock.c rtimer-arch.c
CONTIKI_SOURCEFILES += rtc.c evsys.c

PROJECT_OBJECTFILES += ${addprefix $(OBJECTDIR)/,$(CONTIKI_TARGET_MAIN:.c=.o)}


#Add objcopy to the verbosity control.
ifeq ($(V),1)
  TRACE_OBJCOPY =
else
  TRACE_OBJCOPY = @echo "  OBJCOPY  " $@
endif

#Don't treat project object files and syscalls.o as intermediates (avoids deletion and recompiling).
.SECONDARY: $(PROJECT_OBJECTFILES)
.SECONDARY: $(OBJECTDIR)/syscalls.o


#This rule creates a .bin image from the .elf file. Its output is made precious so it doesn't get
#deleted even if it's an intermediate.
.PRECIOUS: %.$(TARGET).bin
%.$(TARGET).bin: %.$(TARGET).elf
	$(TRACE_OBJCOPY)
	$(Q)$(OBJCOPY) -O binary $< $@


.PRECIOUS: %.$(TARGET).elf
%.$(TARGET).elf: %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a \
                 $(OBJECTDIR)/syscalls.o $(CONTIKI_SOURCEFILES)
	$(TRACE_LD)
	$(Q)$(CC) $(LDFLAGS) -Wl,--section-start=.text=0x2000 $(TARGET_STARTFILES) ${filter-out %.a,$^} \
	    ${filter %.a,$^} $(TARGET_LIBFILES) -o $@ -I$(CONTIKI_CPU_DIRS) -I$(OBJECTDIR)


#Add the .elf file to the clean list.
CLEAN += *.$(TARGET).elf *.$(TARGET).bin