2020-12-07 21:39:07 +01:00
|
|
|
RAM_CODE_TARGET = updater-ram-code
|
2020-12-21 17:20:49 +01:00
|
|
|
target = $(RAM_CODE_TARGET)
|
2020-12-07 21:39:07 +01:00
|
|
|
OBJDIR = obj
|
2020-12-21 17:20:49 +01:00
|
|
|
CFILES = main.c startup.c hex-parser.c
|
|
|
|
CFILES += fatfs/ff.c fatfs/diskio.c fatfs/ffsystem.c fatfs/ffunicode.c fatfs/shimatta_sdio_driver/shimatta_sdio.c
|
2020-12-07 21:39:07 +01:00
|
|
|
LINKER_SCRIPT = ram-link.ld
|
|
|
|
MAPFILE = $(RAM_CODE_TARGET)
|
|
|
|
PREFIX = arm-none-eabi-
|
|
|
|
|
|
|
|
CC = $(PREFIX)gcc
|
|
|
|
OBJCOPY = $(PREFIX)objcopy
|
|
|
|
SIZE = $(PREFIX)size
|
|
|
|
|
|
|
|
ifneq ($(VERBOSE),true)
|
|
|
|
QUIET=@
|
|
|
|
else
|
|
|
|
QUIET=
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2020-12-14 20:29:51 +01:00
|
|
|
DEFINES = -DSTM32F407xx -DSTM32F4XX -DHSE_VALUE=8000000UL
|
|
|
|
INCLUDEPATH = -Iinclude
|
2020-12-07 21:39:07 +01:00
|
|
|
|
|
|
|
LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
|
|
|
|
LFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles
|
2020-12-14 20:29:51 +01:00
|
|
|
LFLAGS += -T$(LINKER_SCRIPT) -Wl,-Map=$(MAPFILE).map -Wl,--print-memory-usage -g3
|
2020-12-07 21:39:07 +01:00
|
|
|
|
2020-12-14 20:29:51 +01:00
|
|
|
CFLAGS = -c -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork -Os -g3
|
2020-12-07 21:39:07 +01:00
|
|
|
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 -nostartfiles
|
|
|
|
CFLAGS += -Wall -Wextra -Wold-style-declaration -Wuninitialized -Wmaybe-uninitialized -Wunused-parameter -Wimplicit-fallthrough=3 -Wsign-compare
|
|
|
|
|
|
|
|
OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o)
|
|
|
|
|
2020-12-21 17:20:49 +01:00
|
|
|
default: $(RAM_CODE_TARGET).bin.h
|
2020-12-07 21:39:07 +01:00
|
|
|
|
2020-12-21 17:20:49 +01:00
|
|
|
all: $(RAM_CODE_TARGET).bin.h
|
2020-12-07 21:39:07 +01:00
|
|
|
|
2020-12-14 20:29:51 +01:00
|
|
|
%.bin.h: %.bin
|
|
|
|
@echo "[BIN2H] $@"
|
2020-12-07 21:39:07 +01:00
|
|
|
$(QUIET)python bin2carray.py $@ $^
|
|
|
|
|
|
|
|
$(RAM_CODE_TARGET).bin: $(RAM_CODE_TARGET).elf
|
|
|
|
@echo "[ELF2BIN] $@"
|
|
|
|
$(QUIET)$(OBJCOPY) -O binary $^ $@
|
|
|
|
|
|
|
|
$(RAM_CODE_TARGET).elf: $(OBJ) $(LINKER_SCRIPT)
|
|
|
|
@echo [LD] $@
|
|
|
|
$(QUIET)$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $(OBJ) $(ASOBJ) $(LIBRARIES)
|
|
|
|
$(QUIET)$(SIZE) $@
|
|
|
|
|
|
|
|
$(OBJ):
|
|
|
|
@echo [CC] $@
|
|
|
|
$(eval OUTPATH=$(dir $@))
|
|
|
|
@mkdir -p $(OUTPATH)
|
|
|
|
$(QUIET)$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ $(@:$(OBJDIR)/%.c.o=%.c)
|
|
|
|
|
2020-12-21 17:20:49 +01:00
|
|
|
.PHONY: clean qtproject
|
2020-12-07 21:39:07 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@echo [CLEAN]
|
2020-12-07 22:35:52 +01:00
|
|
|
$(QUIET)rm -f $(OBJ) $(MAPFILE).map $(CFILES:%.c=$(OBJDIR)/%.c.d) $(RAM_CODE_TARGET).bin $(RAM_CODE_TARGET).elf $(RAM_CODE_TARGET).bin.c
|
2020-12-07 21:39:07 +01:00
|
|
|
|
2020-12-21 17:20:49 +01:00
|
|
|
qtproject:
|
|
|
|
$(QUIET)rm -f $(target).files $(target).cflags $(target).config $(target).creator $(target).includes $(target).creator.user
|
|
|
|
@echo "Generating source file list"
|
|
|
|
$(QUIET)echo "$(CFILES)" | tr ' ' '\n' > $(target).files
|
|
|
|
@echo -n "Appending found header files from folders "
|
|
|
|
@echo `echo $(INCLUDEPATH) | sed "s/-I//g"`
|
|
|
|
$(QUIET)for dir in `echo $(INCLUDEPATH) | sed "s/-I//g"`; do \
|
|
|
|
find `echo "$${dir}"` -name "*.h" >> $(target).files; \
|
|
|
|
done
|
|
|
|
@echo "Generating $(target).cflags"
|
|
|
|
$(QUIET)echo "" > $(target).cflags
|
|
|
|
@echo "Generating $(target).includes"
|
|
|
|
$(QUIET)echo $(INCLUDEPATH) | sed "s/-I/,/g" | tr , '\n' | sed "/^$$/d" > $(target).includes;
|
|
|
|
@echo "Generating $(target).config"
|
|
|
|
$(QUIET)echo $(DEFINES) | sed "s/-D/,#define /g" | tr , '\n' | sed "/^$$/d" > $(target).config
|
|
|
|
@echo "Generating $(target).creator"
|
|
|
|
$(QUIET)echo "[GENERAL]" > $(target).creator
|
|
|
|
|
2020-12-07 21:39:07 +01:00
|
|
|
-include $(CFILES:%.c=$(OBJDIR)/%.c.d)
|
|
|
|
|