blob: 4040c716b5d842635561203a0c76c1fd0e919326 [file] [log] [blame]
Dave Chapmanc6be8182008-10-04 08:46:03 +00001# Change INFILE to point to your original firmware file
2INFILE=$(HOME)/FW/AMS/CLIP/m300a-1.1.17A.bin
3
4# OUTFILE is the file you copy to your device's root and rename to
5# (e.g.) m300a.bin
6OUTFILE=patched.bin
7
8# The uclpack command
9UCLPACK=../../tools/uclpack
10
11all: $(OUTFILE)
12
13mkamsboot: mkamsboot.c
14 gcc -o mkamsboot -W -Wall mkamsboot.c
15
16extract_fw: extract_fw.c
17 gcc -o extract_fw -W -Wall extract_fw.c
18
19# Rules for our test ARM application - assemble, link, then extract
20# the binary code
21
22test.o: test.S
23 arm-elf-as -o test.o test.S
24
25test.elf: test.o
26 arm-elf-ld -e 0 -Ttext=0 -o test.elf test.o
27
28test.bin: test.elf
29 arm-elf-objcopy -O binary test.elf test.bin
30
31# Rules for the ucl unpack function - this is inserted in the padding at
32# the end of the original firmware block
33nrv2e_d8.o: nrv2e_d8.S
34 arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S
35
36# NOTE: this function has no absolute references, so the link address (-e)
37# is irrelevant. We just link at address 0.
38nrv2e_d8.elf: nrv2e_d8.o
39 arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o
40
41nrv2e_d8.bin: nrv2e_d8.elf
42 arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin
43
44firmware_block.ucl: firmware_block.bin
45 $(UCLPACK) --best --2e firmware_block.bin firmware_block.ucl
46
47firmware_block.bin: $(INFILE) extract_fw
48 ./extract_fw $(INFILE) firmware_block.bin
49
50$(OUTFILE): mkamsboot firmware_block.ucl test.bin nrv2e_d8.bin $(INFILE)
51 ./mkamsboot $(INFILE) firmware_block.ucl test.bin nrv2e_d8.bin $(OUTFILE)
52
53clean:
54 rm -fr amsinfo mkamsboot test.o test.elf test.bin extract_fw \
55 nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin firmware_block.bin \
56 firmware_block.ucl $(OUTFILE) *~