summaryrefslogtreecommitdiff
path: root/utils/AMS/hacking/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'utils/AMS/hacking/Makefile')
-rw-r--r--utils/AMS/hacking/Makefile35
1 files changed, 30 insertions, 5 deletions
diff --git a/utils/AMS/hacking/Makefile b/utils/AMS/hacking/Makefile
index 7a10c20ae4..8f48d611c8 100644
--- a/utils/AMS/hacking/Makefile
+++ b/utils/AMS/hacking/Makefile
@@ -1,4 +1,3 @@
1
2# Change INFILE to point to your original firmware file 1# Change INFILE to point to your original firmware file
3INFILE=$(HOME)/FW/AMS/CLIP/m300a-1.1.17A.bin 2INFILE=$(HOME)/FW/AMS/CLIP/m300a-1.1.17A.bin
4 3
@@ -6,6 +5,8 @@ INFILE=$(HOME)/FW/AMS/CLIP/m300a-1.1.17A.bin
6# (e.g.) m300a.bin 5# (e.g.) m300a.bin
7OUTFILE=patched.bin 6OUTFILE=patched.bin
8 7
8# The uclpack command
9UCLPACK=../../../tools/uclpack
9 10
10all: amsinfo $(OUTFILE) 11all: amsinfo $(OUTFILE)
11 12
@@ -15,6 +16,9 @@ amsinfo: amsinfo.c
15mkamsboot: mkamsboot.c 16mkamsboot: mkamsboot.c
16 gcc -o mkamsboot -W -Wall mkamsboot.c 17 gcc -o mkamsboot -W -Wall mkamsboot.c
17 18
19extract_fw: extract_fw.c
20 gcc -o extract_fw -W -Wall extract_fw.c
21
18# Rules for our test ARM application - assemble, link, then extract 22# Rules for our test ARM application - assemble, link, then extract
19# the binary code 23# the binary code
20 24
@@ -22,13 +26,34 @@ test.o: test.S
22 arm-elf-as -o test.o test.S 26 arm-elf-as -o test.o test.S
23 27
24test.elf: test.o 28test.elf: test.o
25 arm-elf-ld -e 0 -o test.elf test.o 29 arm-elf-ld -e 0 -Ttext=0 -o test.elf test.o
26 30
27test.bin: test.elf 31test.bin: test.elf
28 arm-elf-objcopy -O binary test.elf test.bin 32 arm-elf-objcopy -O binary test.elf test.bin
29 33
30$(OUTFILE): mkamsboot test.bin $(INFILE) 34# Rules for the ucl unpack function - this is inserted in the padding at
31 ./mkamsboot $(INFILE) test.bin $(OUTFILE) 35# the end of the original firmware block
36nrv2e_d8.o: nrv2e_d8.S
37 arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S
38
39# NOTE: this function has no absolute references, so the link address (-e)
40# is irrelevant. We just link at address 0.
41nrv2e_d8.elf: nrv2e_d8.o
42 arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o
43
44nrv2e_d8.bin: nrv2e_d8.elf
45 arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin
46
47firmware_block.ucl: firmware_block.bin
48 $(UCLPACK) --best --2e firmware_block.bin firmware_block.ucl
49
50firmware_block.bin: $(INFILE) extract_fw
51 ./extract_fw $(INFILE) firmware_block.bin
52
53$(OUTFILE): mkamsboot firmware_block.ucl test.bin nrv2e_d8.bin $(INFILE)
54 ./mkamsboot $(INFILE) firmware_block.ucl test.bin nrv2e_d8.bin $(OUTFILE)
32 55
33clean: 56clean:
34 rm -fr amsinfo mkamsboot test.bin test.o test.elf $(OUTFILE) *~ 57 rm -fr amsinfo mkamsboot test.o test.elf test.bin extract_fw \
58 nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin firmware_block.bin \
59 firmware_block.ucl $(OUTFILE) *~