forked from dirtyjtag/DirtyJTAG
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework build system to decouple linker script from platform
- Loading branch information
Showing
12 changed files
with
142 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,23 @@ | ||
SUPPORTED_PLATFORMS = baite bluepill olimexstm32h103 stlinkv2 stlinkv2white | ||
PLATFORM ?= bluepill | ||
|
||
OBJS := src/dirtyjtag.$(PLATFORM).o src/jtag.$(PLATFORM).o src/usb.$(PLATFORM).o src/delay.$(PLATFORM).o src/cmd.$(PLATFORM).o | ||
|
||
PREFIX ?= arm-none-eabi | ||
TARGETS := stm32/f1 | ||
DEFS += -DSTM32F1 | ||
ARCH_FLAGS := -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd | ||
LD_SCRIPT := ld/$(PLATFORM).ld | ||
|
||
UCMX_DIR := $(realpath unicore-mx) | ||
UCMX_INCLUDE_DIR := $(UCMX_DIR)/include | ||
UCMX_LIB_DIR := $(UCMX_DIR)/lib | ||
|
||
CFLAGS = -g -O2 | ||
CFLAGS += -Wall -Wextra -Werror | ||
CFLAGS += -fno-common -ffunction-sections -fdata-sections | ||
CFLAGS += -std=gnu11 | ||
CFLAGS += -DPLATFORM='HW_$(PLATFORM)' | ||
|
||
CPPFLAGS = -MD -g | ||
CPPFLAGS += -Wall -Wundef | ||
CPPFLAGS += -I$(UCMX_INCLUDE_DIR) $(DEFS) | ||
|
||
LDFLAGS += --static -nostartfiles | ||
LDFLAGS += -L"$(UCMX_LIB_DIR)" | ||
LDFLAGS += -T$(LD_SCRIPT) | ||
LDFLAGS += -Wl,-Map=$(*).map | ||
LDFLAGS += -Wl,--gc-sections # Remove deadcode | ||
|
||
LDLIBS += -lucmx_stm32f1 | ||
LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group | ||
|
||
CC := $(PREFIX)-gcc | ||
LD := $(PREFIX)-ld | ||
AR := $(PREFIX)-ar | ||
AS := $(PREFIX)-as | ||
SIZE := $(PREFIX)-size | ||
OBJCOPY := $(PREFIX)-objcopy | ||
|
||
all: dirtyjtag | ||
|
||
clean: dirtyjtag-clean ucmx-clean | ||
|
||
dirtyjtag: src/dirtyjtag.$(PLATFORM).elf src/dirtyjtag.$(PLATFORM).bin | ||
|
||
dirtyjtag-release: $(patsubst %, src/dirtyjtag.%.bin, $(SUPPORTED_PLATFORMS)) | ||
|
||
dirtyjtag-clean: | ||
$(Q)$(RM) src/*.d src/*.o src/*.map src/*.bin src/*.elf *.bin *.elf | ||
|
||
ucmx: | ||
$(Q)$(MAKE) -C $(UCMX_DIR) lib/stm32/f1 | ||
|
||
ucmx-clean: | ||
$(Q)$(MAKE) -C $(UCMX_DIR) clean | ||
|
||
%.bin: %.elf | ||
$(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin | ||
|
||
%.elf %.map: $(OBJS) $(LD_SCRIPT) | ||
$(Q)$(CC) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(*).elf | ||
$(Q)$(SIZE) $(*).elf | ||
|
||
%.$(PLATFORM).o: %.c | ucmx | ||
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $@ -c $< | ||
|
||
.PHONY: clean dirtyjtag dirtyjtag-release dirtyjtag-clean ucmx ucmx-clean | ||
MAKE := make | ||
|
||
all: | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=bluepill LOADER=noloader | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=baite LOADER=noloader | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=olimexstm32h103 LOADER=noloader | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=stlinkv2 LOADER=noloader | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=stlinkv2white LOADER=noloader | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=bluepill LOADER=loader2k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=baite LOADER=loader2k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=olimexstm32h103 LOADER=loader2k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=stlinkv2 LOADER=loader2k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=stlinkv2white LOADER=loader2k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=bluepill LOADER=loader4k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=baite LOADER=loader4k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=olimexstm32h103 LOADER=loader4k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=stlinkv2 LOADER=loader4k | ||
$(MAKE) -f Makefile.stm32f1 PLATFORM=stlinkv2white LOADER=loader4k | ||
|
||
clean: | ||
$(MAKE) -f Makefile.stm32f1 clean | ||
|
||
.PHONY: all clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
SUPPORTED_PLATFORMS = baite bluepill olimexstm32h103 stlinkv2 stlinkv2white | ||
PLATFORM ?= bluepill | ||
LOADER ?= noloader | ||
|
||
OBJS := src/dirtyjtag.$(PLATFORM).o src/jtag.$(PLATFORM).o src/usb.$(PLATFORM).o src/delay.$(PLATFORM).o src/cmd.$(PLATFORM).o | ||
|
||
PREFIX ?= arm-none-eabi | ||
TARGETS := stm32/f1 | ||
DEFS += -DSTM32F1 | ||
ARCH_FLAGS := -mthumb -mcpu=cortex-m3 -msoft-float -mfix-cortex-m3-ldrd | ||
LD_SCRIPT := ld/stm32f1-$(LOADER).ld | ||
|
||
UCMX_DIR := $(realpath unicore-mx) | ||
UCMX_INCLUDE_DIR := $(UCMX_DIR)/include | ||
UCMX_LIB_DIR := $(UCMX_DIR)/lib | ||
|
||
CFLAGS = -g -O2 | ||
CFLAGS += -Wall -Wextra -Werror | ||
CFLAGS += -fno-common -ffunction-sections -fdata-sections | ||
CFLAGS += -std=gnu11 | ||
CFLAGS += -DPLATFORM='HW_$(PLATFORM)' $(DEFS) | ||
|
||
CPPFLAGS = -MD -g | ||
CPPFLAGS += -Wall -Wundef | ||
CPPFLAGS += -I$(UCMX_INCLUDE_DIR) $(DEFS) | ||
|
||
LDFLAGS += --static -nostartfiles | ||
LDFLAGS += -L"$(UCMX_LIB_DIR)" | ||
LDFLAGS += -T$(LD_SCRIPT) | ||
LDFLAGS += -Wl,-Map=$(*).map | ||
LDFLAGS += -Wl,--gc-sections # Remove deadcode | ||
|
||
LDLIBS += -lucmx_stm32f1 | ||
LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group | ||
|
||
CC := $(PREFIX)-gcc | ||
LD := $(PREFIX)-ld | ||
AR := $(PREFIX)-ar | ||
AS := $(PREFIX)-as | ||
SIZE := $(PREFIX)-size | ||
OBJCOPY := $(PREFIX)-objcopy | ||
|
||
all: dirtyjtag | ||
|
||
clean: dirtyjtag-clean ucmx-clean | ||
|
||
dirtyjtag: src/dirtyjtag.$(PLATFORM).$(LOADER).elf src/dirtyjtag.$(PLATFORM).$(LOADER).bin | ||
|
||
#dirtyjtag-release: $(patsubst %, src/dirtyjtag.%.bin, $(SUPPORTED_PLATFORMS)) | ||
|
||
dirtyjtag-clean: | ||
$(Q)$(RM) src/*.d src/*.o src/*.map src/*.bin src/*.elf *.bin *.elf | ||
|
||
ucmx: | ||
$(Q)$(MAKE) -C $(UCMX_DIR) lib/stm32/f1 | ||
|
||
ucmx-clean: | ||
$(Q)$(MAKE) -C $(UCMX_DIR) clean | ||
|
||
%.bin: %.elf | ||
$(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin | ||
|
||
%.$(LOADER).elf %.$(LOADER).map: $(OBJS) $(LD_SCRIPT) | ||
$(Q)$(CC) $(LDFLAGS) $(ARCH_FLAGS) $(OBJS) $(LDLIBS) -o $(*).$(LOADER).elf | ||
$(Q)$(SIZE) $(*).$(LOADER).elf | ||
|
||
%.$(PLATFORM).o: %.c | ucmx | ||
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) $(ARCH_FLAGS) -o $@ -c $< | ||
|
||
.PHONY: clean dirtyjtag dirtyjtag-release dirtyjtag-clean ucmx ucmx-clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* Generic STM32F1, application at 0x4000 */ | ||
MEMORY { | ||
rom (rx) : ORIGIN = 0x08002000, LENGTH = 128K-0x2000 | ||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K | ||
} | ||
|
||
INCLUDE libucmx_stm32f1.ld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters