Skip to content

Commit

Permalink
create bin and hex versions of output.
Browse files Browse the repository at this point in the history
They're cheap, and some people like to use tools that only work with one
or the other.
  • Loading branch information
karlp committed Mar 19, 2018
1 parent 5210d2c commit 31a01d3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
OD=bin

all: realall.really
Expand All @@ -19,7 +20,9 @@ define RAWMakeBoard
endef

define MakeBoard
BOARDS_ALL+=$(OD)/$(1).elf
BOARDS_ELF+=$(OD)/$(1).elf
BOARDS_BIN+=$(OD)/$(1).bin
BOARDS_HEX+=$(OD)/$(1).hex
$(OD)/$(1).elf: template_stm32.c libopencm3/lib/libopencm3_$(5).a
@echo " $(5) -> Creating $(OD)/$(1).elf"
$(call RAWMakeBoard,RCC_$(2),$(2),$(3),$(4),$(1).elf)
Expand All @@ -34,7 +37,7 @@ include boards.stm32l0.mk
include boards.stm32l1.mk
include boards.stm32l4.mk

realall.really: outdir $(BOARDS_ALL)
realall.really: outdir $(BOARDS_ELF) $(BOARDS_BIN) $(BOARDS_HEX)

libopencm3/Makefile:
@echo "Initializing libopencm3 submodule"
Expand All @@ -43,11 +46,19 @@ libopencm3/Makefile:
libopencm3/lib/libopencm3_%.a: libopencm3/Makefile
$(MAKE) -C libopencm3

%.bin: %.elf
@#printf " OBJCOPY $(*).bin\n"
$(OBJCOPY) -Obinary $(*).elf $(*).bin

%.hex: %.elf
@#printf " OBJCOPY $(*).hex\n"
$(OBJCOPY) -Oihex $(*).elf $(*).hex

outdir:
mkdir -p $(OD)

clean:
$(RM) $(BOARDS_ALL)
$(RM) $(BOARDS_ELF) $(BOARDS_BIN) $(BOARDS_HEX)

.PHONY: realall.really outdir clean all
$(V).SILENT:

0 comments on commit 31a01d3

Please sign in to comment.