forked from Asmageddon/airbreak-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·101 lines (79 loc) · 3.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# stm32-unlocked.bin: patch-airsense
# ./patch-airsense stm32.bin $@
SRC=patches
BUILD=build
all: $(BUILD)/stm32-patched.bin $(BUILD)/stm32-asv.bin
$(BUILD)/stm32-patched.bin: patch-airsense $(BUILD)/common_code.bin $(BUILD)/graph.bin $(BUILD)/squarewave.bin
export PATCH_CODE=1 && export PATCH_S=1 && ./patch-airsense stm32.bin $@
$(BUILD)/stm32-asv.bin: patch-airsense $(BUILD)/common_code.bin $(BUILD)/graph.bin $(BUILD)/squarewave_asv.bin $(BUILD)/asv_task_wrapper.bin $(BUILD)/wrapper_limit_max_pdiff.bin
export PATCH_CODE=1 && export PATCH_S_ASV=1 && export PATCH_ASV_TASK_WRAPPER=1 && export PATCH_VAUTO_WRAPPER=1 && ./patch-airsense stm32.bin $@
binaries: $(BUILD)/common_code.bin $(BUILD)/graph.bin $(BUILD)/squarewave.bin $(BUILD)/squarewave_asv.bin $(BUILD)/asv_task_wrapper.bin $(BUILD)/wrapper_limit_max_pdiff.bin
serve:
mkdocs serve
deploy:
mkdocs gh-deploy
$(BUILD)/common_code.elf: $(BUILD)/common_code.o $(BUILD)/stubs.o
common_code-offset := 0x80fe000
# The graphing is too large to fit directly in the location at 0x8067d2c,
# so it is in high in the flash and the function pointer is fixed up at 0x80f9c88
$(BUILD)/graph.elf: $(BUILD)/graph.o $(BUILD)/stubs.o
graph-offset := 0x80fcd40
graph-extra := --just-symbols=$(BUILD)/common_code.elf
$(BUILD)/squarewave.elf: $(BUILD)/squarewave.o $(BUILD)/stubs.o
squarewave-offset := 0x80fd000
squarewave-extra := --just-symbols=$(BUILD)/common_code.elf
$(BUILD)/squarewave_asv.elf: $(BUILD)/squarewave_asv.o $(BUILD)/stubs.o
squarewave_asv-offset := 0x80fd000
squarewave_asv-extra := --just-symbols=$(BUILD)/common_code.elf
$(BUILD)/asv_task_wrapper.elf: $(BUILD)/asv_task_wrapper.o $(BUILD)/stubs.o
asv_task_wrapper-offset := 0x80fdf00
asv_task_wrapper-extra := --just-symbols=$(BUILD)/common_code.elf
$(BUILD)/wrapper_limit_max_pdiff.elf: $(BUILD)/wrapper_limit_max_pdiff.o $(BUILD)/stubs.o
wrapper_limit_max_pdiff-offset := 0x80fee00
wrapper_limit_max_pdiff-extra := --just-symbols=$(BUILD)/common_code.elf
# If there is a new version of the ghidra XML, the stubs.S
# file will be regenerated so that the addresses and functions
# are at the correct address in the ELF image.
#stubs.S: stm32.bin.xml
# ./ghidra2stubs < $< > $@
CROSS ?= arm-none-eabi-
CC := $(CROSS)gcc
AS := $(CC)
LD := $(CROSS)ld
OBJCOPY := $(CROSS)objcopy
CFLAGS ?= \
-g \
-Os \
-mcpu=cortex-m4 \
-mhard-float \
-mfp16-format=ieee \
-mthumb \
-W \
-Wall \
-Wno-unused-result \
-Wno-unused-parameter \
-Wno-unused-variable \
-nostdlib \
-nostdinc \
-ffreestanding \
ASFLAGS ?= $(CFLAGS)
LDFLAGS ?= \
--nostdlib \
--no-dynamic-linker \
--Ttext $($*-offset) \
$($*-extra) \
--entry start \
--sort-section=name \
# TODO: Sort sections by name, lay out main before the rest, to avoid inlining everything
# $(BUILD)/shared_code.o: $(BUILD)/shared_code.c
# $(CC) $(CFLAGS) -static -shared -c -o $@ $<
$(BUILD)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(SRC)/%.S
$(AS) $(ASFLAGS) -c -o $@ $<
$(BUILD)/%.elf:
$(LD) $(LDFLAGS) -o $@ $^
$(BUILD)/%.bin: $(BUILD)/%.elf
$(OBJCOPY) -Obinary $< $@
clean:
$(RM) $(BUILD)/*