summaryrefslogtreecommitdiff
path: root/rbutil/mkamsboot/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/mkamsboot/Makefile')
-rw-r--r--rbutil/mkamsboot/Makefile98
1 files changed, 68 insertions, 30 deletions
diff --git a/rbutil/mkamsboot/Makefile b/rbutil/mkamsboot/Makefile
index 4040c716b5..e3d98f03f0 100644
--- a/rbutil/mkamsboot/Makefile
+++ b/rbutil/mkamsboot/Makefile
@@ -1,56 +1,94 @@
1# Change INFILE to point to your original firmware file
2INFILE=$(HOME)/FW/AMS/CLIP/m300a-1.1.17A.bin
3 1
4# OUTFILE is the file you copy to your device's root and rename to 2# We use the UCL code available in the Rockbox tools/ directory
5# (e.g.) m300a.bin
6OUTFILE=patched.bin
7 3
8# The uclpack command 4CFLAGS=-I../../tools/ucl/include
9UCLPACK=../../tools/uclpack 5LIBUCL=../../tools/ucl/src/libucl.a
10 6
11all: $(OUTFILE) 7# Edit the following variables (plus copy/paste another set of rules) when
8# adding a new target. mkamsboot.c also needs to be edited to refer to these
9# new images.
10#
11# If anyone reading this wants to improve this makefile, please do!
12 12
13mkamsboot: mkamsboot.c 13BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o
14 gcc -o mkamsboot -W -Wall mkamsboot.c 14BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h
15 15
16extract_fw: extract_fw.c 16CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \
17 gcc -o extract_fw -W -Wall extract_fw.c 17 dualboot-clip.bin bootimg_clip.c bootimg_clip.h
18
19E200V2FILES = dualboot-e200v2.o dualboot-e200v2.elf dualboot-e200v2.o \
20 dualboot-e200v2.bin bootimg_e200v2.c bootimg_e200v2.h
21
22all: mkamsboot
23
24$(LIBUCL):
25 make -C ../../tools/ucl/src libucl.a
26
27mkamsboot.o: mkamsboot.c $(BOOTHEADERS) uclimg.h
28 gcc $(CFLAGS) -c -o mkamsboot.o -W -Wall mkamsboot.c
29
30mkamsboot: mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL)
31 gcc -o mkamsboot mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL)
18 32
19# Rules for our test ARM application - assemble, link, then extract 33# Rules for our test ARM application - assemble, link, then extract
20# the binary code 34# the binary code
21 35
22test.o: test.S 36# CLIP
23 arm-elf-as -o test.o test.S 37
38dualboot-clip.o: dualboot.S
39 arm-elf-gcc -DSANSA_CLIP -c -o dualboot-clip.o dualboot.S
40
41dualboot-clip.elf: dualboot-clip.o
42 arm-elf-ld -e 0 -Ttext=0 -o dualboot-clip.elf dualboot-clip.o
43
44dualboot-clip.bin: dualboot-clip.elf
45 arm-elf-objcopy -O binary dualboot-clip.elf dualboot-clip.bin
46
47bootimg_clip.c bootimg_clip.h: dualboot-clip.bin bin2c
48 ./bin2c dualboot-clip.bin bootimg_clip
49
50bootimg_clip.o: bootimg_clip.c
51 gcc -c -o bootimg_clip.o bootimg_clip.c
52
53# E200V2
54
55dualboot-e200v2.o: dualboot.S
56 arm-elf-gcc -DSANSA_E200V2 -c -o dualboot-e200v2.o dualboot.S
57
58dualboot-e200v2.elf: dualboot-e200v2.o
59 arm-elf-ld -e 0 -Ttext=0 -o dualboot-e200v2.elf dualboot-e200v2.o
60
61dualboot-e200v2.bin: dualboot-e200v2.elf
62 arm-elf-objcopy -O binary dualboot-e200v2.elf dualboot-e200v2.bin
24 63
25test.elf: test.o 64bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c
26 arm-elf-ld -e 0 -Ttext=0 -o test.elf test.o 65 ./bin2c dualboot-e200v2.bin bootimg_e200v2
27 66
28test.bin: test.elf 67bootimg_e200v2.o: bootimg_e200v2.c
29 arm-elf-objcopy -O binary test.elf test.bin 68 gcc -c -o bootimg_e200v2.o bootimg_e200v2.c
30 69
31# Rules for the ucl unpack function - this is inserted in the padding at 70# Rules for the ucl unpack function
32# the end of the original firmware block
33nrv2e_d8.o: nrv2e_d8.S 71nrv2e_d8.o: nrv2e_d8.S
34 arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S 72 arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S
35 73
36# NOTE: this function has no absolute references, so the link address (-e) 74# NOTE: this function has no absolute references, so the link address (-e)
37# is irrelevant. We just link at address 0. 75# is irrelevant. We just link at address 0, but it can run from anywhere.
38nrv2e_d8.elf: nrv2e_d8.o 76nrv2e_d8.elf: nrv2e_d8.o
39 arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o 77 arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o
40 78
41nrv2e_d8.bin: nrv2e_d8.elf 79nrv2e_d8.bin: nrv2e_d8.elf
42 arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin 80 arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin
43 81
44firmware_block.ucl: firmware_block.bin 82uclimg.c uclimg.h: nrv2e_d8.bin bin2c
45 $(UCLPACK) --best --2e firmware_block.bin firmware_block.ucl 83 ./bin2c nrv2e_d8.bin uclimg
46 84
47firmware_block.bin: $(INFILE) extract_fw 85uclimg.o: uclimg.c
48 ./extract_fw $(INFILE) firmware_block.bin 86 gcc -c -o uclimg.o uclimg.c
49 87
50$(OUTFILE): mkamsboot firmware_block.ucl test.bin nrv2e_d8.bin $(INFILE) 88bin2c: bin2c.c
51 ./mkamsboot $(INFILE) firmware_block.ucl test.bin nrv2e_d8.bin $(OUTFILE) 89 gcc -o bin2c bin2c.c
52 90
53clean: 91clean:
54 rm -fr amsinfo mkamsboot test.o test.elf test.bin extract_fw \ 92 rm -f mkamsboot mkamsboot.o nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin *~ \
55 nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin firmware_block.bin \ 93 bin2c uclimg.c uclimg.h uclimg.o \
56 firmware_block.ucl $(OUTFILE) *~ 94 $(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES)