diff options
author | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-24 19:14:10 +0100 |
---|---|---|
committer | jaseg <git-bigdata-wsl-arch@jaseg.de> | 2020-02-24 19:14:10 +0100 |
commit | 23a1333abe125ff2dd4a1493dd6553ddccf84514 (patch) | |
tree | 90a954270b90facff3709f12c97a9ce3f6efe508 /controller/fw/Makefile | |
parent | b5196749352cdba56b99221e648feb371cf017ac (diff) | |
download | master-thesis-23a1333abe125ff2dd4a1493dd6553ddccf84514.tar.gz master-thesis-23a1333abe125ff2dd4a1493dd6553ddccf84514.tar.bz2 master-thesis-23a1333abe125ff2dd4a1493dd6553ddccf84514.zip |
Initial reset controller firmware
Diffstat (limited to 'controller/fw/Makefile')
-rw-r--r-- | controller/fw/Makefile | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/controller/fw/Makefile b/controller/fw/Makefile new file mode 100644 index 0000000..8a6d0da --- /dev/null +++ b/controller/fw/Makefile @@ -0,0 +1,93 @@ + +SOURCES := main.c mspdebug_wrapper.c +SOURCES += mspdebug/drivers/jtaglib.c + +BUILDDIR ?= build +BINARY := safetyreset +LDSCRIPT := stm32f407.ld +LIBNAME := opencm3_stm32f4 + +OPENCM3_DIR ?= libopencm3 + +PREFIX ?= arm-none-eabi- + + +CC := $(PREFIX)gcc +CXX := $(PREFIX)g++ +LD := $(PREFIX)gcc +AR := $(PREFIX)ar +AS := $(PREFIX)as +OBJCOPY := $(PREFIX)objcopy +OBJDUMP := $(PREFIX)objdump +GDB := $(PREFIX)gdb + + +CFLAGS += -I$(OPENCM3_DIR)/include -Imspdebug/util -Imspdebug/drivers + +CFLAGS += -Os -std=c11 -g -DSTM32F4 +# Note: libopencm3 requires some standard libc definitions from stdint.h and stdbool.h, so we don't pass -nostdinc here. +CFLAGS += -nostdlib -ffreestanding +CFLAGS += -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g +CFLAGS += -Wextra -Wshadow -Wimplicit-function-declaration -Wundef +CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes +CFLAGS += -fno-common -ffunction-sections -fdata-sections + +LDFLAGS += --static -nostartfiles +LDFLAGS += -T$(LDSCRIPT) +LDFLAGS += -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g +LDFLAGS += -Wl,--cre +#LDFLAGS += -Wl,--gc-sections +LDFLAGS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group +LDFLAGS += -L$(OPENCM3_DIR)/lib +LDFLAGS += -l$(LIBNAME) $(shell $(CC) -print-libgcc-file-name) + +all: elf + +elf: $(BUILDDIR)/$(BINARY).elf +bin: $(BUILDDIR)/$(BINARY).bin +hex: $(BUILDDIR)/$(BINARY).hex +srec: $(BUILDDIR)/$(BINARY).srec +list: $(BUILDDIR)/$(BINARY).list + +images: $(BUILDDIR)/$(BINARY).images + +$(OPENCM3_DIR)/lib/lib$(LIBNAME).a: + echo "Warning, $@ not found, attempting to rebuild in $(OPENCM3_DIR)" + $(MAKE) -C $(OPENCM3_DIR) + +OBJS := $(addprefix $(BUILDDIR)/,$(SOURCES:%.c=%.o)) + +# Define a helper macro for debugging make errors online +# you can type "make print-OPENCM3_DIR" and it will show you +# how that ended up being resolved by all of the included +# makefiles. +print-%: + @echo $*=$($*) + +$(BUILDDIR)/%.images: $(BUILDDIR)/%.bin $(BUILDDIR)/%.hex $(BUILDDIR)/%.srec $(BUILDDIR)/%.list $(BUILDDIR)/%.map + +$(BUILDDIR)/%.bin: $(BUILDDIR)/%.elf + $(OBJCOPY) -Obinary $< $@ + +$(BUILDDIR)/%.hex: $(BUILDDIR)/%.elf + $(OBJCOPY) -Oihex $< $@ + +$(BUILDDIR)/%.srec: $(BUILDDIR)/%.elf + $(OBJCOPY) -Osrec $< $@ + +$(BUILDDIR)/%.list: $(BUILDDIR)/%.elf + $(OBJDUMP) -S $< > $@ + +$(BUILDDIR)/%.elf: $(OBJS) $(LDSCRIPT) $(OPENCM3_DIR)/lib/lib$(LIBNAME).a + $(LD) $(OBJS) $(LDFLAGS) -o $@ -Wl,-Map=$*.map + +$(BUILDDIR)/%.o: %.c + mkdir -p $(dir $@) + $(CC) $(CFLAGS) -o $@ -c $< + +clean: + -rm -r $(BUILDDIR) + +.PHONY: images clean elf bin hex srec list + +-include $(OBJS:.o=.d) |