Compare commits

...

3 Commits

2 changed files with 37 additions and 31 deletions

2
.gitignore vendored
View File

@ -1,4 +1,5 @@
project.elf project.elf
*.lss
*.o *.o
*.map *.map
*.bin *.bin
@ -7,3 +8,4 @@ project.elf
*.user *.user
*.user* *.user*
*.user.* *.user.*
obj/*

View File

@ -7,8 +7,9 @@ CFILES = main.c syscalls/syscalls.c setup/system_init.c startup/startup_stm32f7
ASFILES = ASFILES =
INCLUDEPATH = -Iinclude INCLUDEPATH = -Iinclude
OBJDIR := obj
target = project TARGET = project
LIBRARYPATH = -Lstartup -Ldsp LIBRARYPATH = -Lstartup -Ldsp
LIBRARIES = -larm_cortexM7lfsp_math -lm LIBRARIES = -larm_cortexM7lfsp_math -lm
@ -29,56 +30,59 @@ SIZE=arm-none-eabi-size
LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork LFLAGS = -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
LFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles LFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 --disable-newlib-supplied-syscalls -nostartfiles
LFLAGS += -Tstm32f746zgt-axim.ld -Wl,-Map=$(mapfile).map -Wl,--gc-sections LFLAGS += -Tstm32f746zgt-axim.ld -Wl,-Map=$(mapfile).map -Wl,--gc-sections
LFLAGS += -Wl,--print-memory-usage
CFLAGS = -c -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork CFLAGS = -fmessage-length=0 -mlittle-endian -mthumb -mcpu=cortex-m7 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 -nostartfiles -Wall CFLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16 -nostartfiles -Wall
#################################################################################### ####################################################################################
OBJ = $(CFILES:%.c=%.c.o) OBJ = $(CFILES:%.c=$(OBJDIR)/%.c.o)
ASOBJ = $(ASFILES:%.S=%.S.o) ASOBJ = $(ASFILES:%.S=$(OBJDIR)/%.S.o)
default: $(target).elf DEPENDENCY_FILES = $(CFILES:%.c=$(OBJDIR)/%.c.d) $(ASFILES:%.S=$(OBJDIR)/%.S.d)
binary: $(target).bin $(target).hex default: $(TARGET).elf
%.bin: %.elf %.bin: %.elf
$(OBJCOPY) -O binary $^ $@ @echo [BIN] $@
@$(OBJCOPY) -O binary $^ $@
%.hex: %.elf %.hex: %.elf
$(OBJCOPY) -O ihex $^ $@ @echo [HEX] $@
@$(OBJCOPY) -O ihex $^ $@
#Linking #Linking
$(target).elf: $(OBJ) $(ASOBJ) $(TARGET).elf: $(OBJ) $(ASOBJ)
$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES) @$(CC) $(LFLAGS) $(LIBRARYPATH) -o $@ $^ $(LIBRARIES)
$(SIZE) $@ @$(SIZE) $@
#Compiling #Compiling
%.c.o: %.c $(OBJ):
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $< @echo [CC] $@
@mkdir -p $(@D)
@$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ -c $(@:$(OBJDIR)/%.c.o=%.c)
%.S.o: %.S $(ASOBJ):
$(CC) $(CFLAGS) $(INCLUDEPATH) $(DEFINES) -o $@ $< @echo [AS] $@
@mkdir -p $(@D)
@$(CC) $(CFLAGS) -MMD -MT $@ $(INCLUDEPATH) $(DEFINES) -o $@ -c $(@:$(OBJDIR)/%.S.o=%.S)
.PHONY: qtproject clean mrproper objcopy disassemble .PHONY: clean mrproper objcopy disassemble binary
disassemble: $(target).elf binary: $(TARGET).bin $(TARGET).hex
$(OBJDUMP) -D -s $< > $(target).lss
objcopy: $(target).bin $(target).hex disassemble: $(TARGET).elf
$(OBJDUMP) -D -s $< > $(TARGET).lss
objcopy: $(TARGET).bin $(TARGET).hex
mrproper: mrproper:
rm -f $(target).pro rm -f $(TARGET).pro
clean: clean:
rm -f $(target).elf $(target).bin $(target).hex $(OBJ) $(ASOBJ) $(mapfile).map $(target).lss @echo [RM] in $(OBJDIR)
qtproject: @rm -f $(TARGET).elf $(TARGET).bin $(TARGET).hex $(OBJ) $(ASOBJ) $(mapfile).map $(TARGET).lss $(DEPENDENCY_FILES)
echo -e "TEMPLATE = app\nCONFIG -= console app_bundle qt" > $(target).pro @rm -rf $(OBJDIR)/*
echo -e "SOURCES += $(CFILES) $(ASFILES)" >> $(target).pro
echo -ne "INCLUDEPATH += " >> $(target).pro
echo "$(INCLUDEPATH)" | sed "s!-I!./!g" >> $(target).pro
echo -ne "HEADERS += " >> $(target).pro
find -name "*.h" | tr "\\n" " " >> $(target).pro
echo -ne "\nDEFINES += " >> $(target).pro
echo "$(DEFINES)" | sed "s/-D//g" >> $(target).pro
# Include dependency files, if available
-include $(DEPENDENCY_FILES)