8 years, 11 months ago.

Makefile: GCC offline compiling and copying to MBED

Hi,

I use GCC compiler under Linux. Does any one know, how to modify Makefile, to copy the .bin to the target MBED right after compile?

I have this line inserted in Makefile, there are no errors, the compilyng works OK, but the copy instruction never fires:

prog: cp $(PROJECT).bin /home/media/MBED1/$(PROJECT).bin sync #flush all buffers

I use MBED1, as far I have several MBEDs hooked to my computer.

Thank you for any answer.

1 Answer

8 years, 11 months ago.

Look at the syntax of a makefile, the full explanation is at www.gnu.org/software/make/manual/make.html
or a short one http://mrbook.org/blog/tutorials/make/
The basic makefile is composed of:
target: dependencies
[tab] system command

My makefile has one line with prog: and the next line begins with a tab

prog: 
	cp $(PROJECT).bin /media/robert/MBED/$(PROJECT).bin
	sync  #flush all buffers 

Hi, I tried everything but with no result.

Here's my Makefile

<code>

.asm.o: $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .s.o: $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< .S.o: $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $<

.c.o: $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $<

.cpp.o: $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<

$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)

$(PROJECT).bin: $(PROJECT).elf $(OBJCOPY) -O binary $< $@

$(PROJECT).hex: $(PROJECT).elf @$(OBJCOPY) -O ihex $< $@

$(PROJECT).lst: $(PROJECT).elf @$(OBJDUMP) -Sdh $< > $@

lst: $(PROJECT).lst

size: $(PROJECT).elf $(SIZE) $(PROJECT).elf

prog: $(PROJECT).bin /media/gorazd/MBED1/$(PROJECT).bin sync #flush all buffers

DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) -include $(DEPS)

</code>

posted by Gorazd Rosbach 27 Nov 2015