Re-organize build output, store under build/

master
Adam Engström 2015-01-10 20:02:51 +01:00
parent ce2e290d23
commit bc13145aea
2 changed files with 25 additions and 20 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.bin *.bin
*.elf *.elf
*.hex *.hex
build/

View File

@ -1,35 +1,38 @@
all: all:
QUIET=@ QUIET=@
orig_fw.hex: orig_fw.hex:
@echo "Reading Novatouch firmware to $@..." @echo "Reading Novatouch firmware to $@..."
$(QUIET)mspdebug rf2500 "hexout 0x8000 0xffff $@" $(QUIET)mspdebug rf2500 "hexout 0x8000 0xffff $@"
orig_fw.bin: orig_fw.hex build/orig_fw.bin: orig_fw.hex
@echo "Converting ihex fw to binary blob..." @echo "Converting ihex fw to binary blob..."
$(QUIET)mkdir -p build
$(QUIET)msp430-objcopy -I ihex -O binary $< $@ $(QUIET)msp430-objcopy -I ihex -O binary $< $@
section_isr.bin: orig_fw.bin build/section_isr.bin: build/orig_fw.bin
@echo "Create isr vectors binary..." @echo "Create isr vectors binary..."
$(QUIET)dd if=$< of=$@ bs=1 skip=0x7fe0 count=0x20 $(QUIET)dd if=$< of=$@ bs=1 skip=0x7fe0 count=0x20 2> /dev/null
section_data.bin: orig_fw.bin build/section_data.bin: build/orig_fw.bin
@echo "Create data section binary..." @echo "Create data section binary..."
$(QUIET)dd if=$< of=$@ bs=1 count=0x2780 $(QUIET)dd if=$< of=$@ bs=1 count=0x2780 2> /dev/null
section_data_patch.bin: section_data.bin build/section_data_patch.bin: build/section_data.bin patch.py
@echo "Patching firmware..." @echo "Patching data section..."
$(QUIET)python patch.py section_data.bin section_data_patch.bin $(QUIET)python patch.py $< $@
# IDA friendly elf file # IDA friendly elf file
main.o: section_data_patch.bin section_isr.bin 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 \ $(QUIET)msp430-objcopy -I binary -O elf32-msp430 -B msp430:430X \
--rename-section .data=.text,contents,code,alloc,load,readonly \ --rename-section .data=.text,contents,code,alloc,load,readonly \
--change-section-address .data=0x8000 \ --change-section-address .data=0x8000 \
--add-section .vectors=section_isr.bin \ --add-section .vectors=build/section_isr.bin \
--set-section-flags .vectors=contents,alloc,load,readonly,code \ --set-section-flags .vectors=contents,alloc,load,readonly,code \
--change-section-address .vectors=0xff80 \ --change-section-address .vectors=0xffe0 \
--set-start 0x8000 section_data_patch.bin $@ --set-start 0x8000 build/section_data_patch.bin $@
build/enter_bsl.o: shellcode/enter_bsl.c build/enter_bsl.o: shellcode/enter_bsl.c
@echo "Compiling shellcode..." @echo "Compiling shellcode..."
@ -37,13 +40,14 @@ build/enter_bsl.o: shellcode/enter_bsl.c
# The main.o is an relocatable elf which we convert to an actual elf # 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 # for IDA to like it. Also link in our own objects
main.elf: build/main.o enter_bsl.o main.elf: build/main.o build/enter_bsl.o
@echo "Create main.elf..." @echo "Create main.elf..."
$(QUIET)msp430-gcc -O0 -mmcu=msp430f5510 \ $(QUIET)msp430-gcc -O0 -mmcu=msp430f5510 \
-Wl,--section-start=.text=0x8000 \ -Wl,--section-start=.text=0x8000 \
-Wl,--section-start=.vectors=0xffe0 \
-Wl,--entry=0x9ca6 \ -Wl,--entry=0x9ca6 \
-nostdlib \ -nostdlib \
$< -o $@ $^ -o $@
.PHONY: flash .PHONY: flash
flash: main.elf flash: main.elf