Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame^] | 1 | # Change INFILE to point to your original firmware file |
| 2 | INFILE=$(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 |
| 6 | OUTFILE=patched.bin |
| 7 | |
| 8 | # The uclpack command |
| 9 | UCLPACK=../../tools/uclpack |
| 10 | |
| 11 | all: $(OUTFILE) |
| 12 | |
| 13 | mkamsboot: mkamsboot.c |
| 14 | gcc -o mkamsboot -W -Wall mkamsboot.c |
| 15 | |
| 16 | extract_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 | |
| 22 | test.o: test.S |
| 23 | arm-elf-as -o test.o test.S |
| 24 | |
| 25 | test.elf: test.o |
| 26 | arm-elf-ld -e 0 -Ttext=0 -o test.elf test.o |
| 27 | |
| 28 | test.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 |
| 33 | nrv2e_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. |
| 38 | nrv2e_d8.elf: nrv2e_d8.o |
| 39 | arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o |
| 40 | |
| 41 | nrv2e_d8.bin: nrv2e_d8.elf |
| 42 | arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin |
| 43 | |
| 44 | firmware_block.ucl: firmware_block.bin |
| 45 | $(UCLPACK) --best --2e firmware_block.bin firmware_block.ucl |
| 46 | |
| 47 | firmware_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 | |
| 53 | clean: |
| 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) *~ |