-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile.common
47 lines (38 loc) · 1.51 KB
/
Makefile.common
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
OK := $(foreach exec,$(REQUIREMENTS),\
$(if $(shell which $(exec)),,$(error "Cannot find '$(exec)' in PATH")))
all:
QUIET=@
build/section_isr.bin: build/orig_fw.bin
@echo "Create isr vectors binary..."
$(QUIET)dd if=$< of=$@ bs=1 skip=32736 count=32 status=none
build/section_data.bin: build/orig_fw.bin
@echo "Create data section binary..."
$(QUIET)dd if=$< of=$@ bs=1 count=10112 status=none
build/section_data_patch.bin: build/section_data.bin patch.py
@echo "Patching data section..."
$(QUIET)python patch.py $< $@
# IDA friendly elf file
build/main.o: build/section_data_patch.bin build/section_isr.bin
@echo "Create main.o..."
$(QUIET)msp430-objcopy -I binary -O elf32-msp430 -B msp430:430X \
--rename-section .data=.text,contents,code,alloc,load,readonly \
--change-section-address .data=0x8000 \
--add-section .vectors=build/section_isr.bin \
--set-section-flags .vectors=contents,alloc,load,readonly,code \
--change-section-address .vectors=0xffe0 \
--set-start 0x8000 build/section_data_patch.bin $@
build/enter_bsl.o: shellcode/enter_bsl.c
@echo "Compiling shellcode..."
$(QUIET)msp430-gcc -Os -mmcu=msp430f5510 -c $< -o $@
# The main.o is an relocatable elf which we convert to an actual elf
# for IDA to like it. Also link in our own objects
build/main.elf: build/main.o build/enter_bsl.o
@echo "Create main.elf..."
$(QUIET)msp430-gcc -O0 -mmcu=msp430f5510 \
-Wl,--section-start=.text=0x8000 \
-Wl,--section-start=.vectors=0xffe0 \
-Wl,--entry=0x9ca6 \
-nostdlib \
$^ -o $@
clean:
rm build/*