blob: e3d98f03f048db9f8d9ef56a7077485ae7ca2356 [file] [log] [blame]
Dave Chapmanc6be8182008-10-04 08:46:03 +00001
Dave Chapman1c4bcfa2008-10-11 11:35:59 +00002# We use the UCL code available in the Rockbox tools/ directory
Dave Chapmanc6be8182008-10-04 08:46:03 +00003
Dave Chapman1c4bcfa2008-10-11 11:35:59 +00004CFLAGS=-I../../tools/ucl/include
5LIBUCL=../../tools/ucl/src/libucl.a
Dave Chapmanc6be8182008-10-04 08:46:03 +00006
Dave Chapman1c4bcfa2008-10-11 11:35:59 +00007# 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!
Dave Chapmanc6be8182008-10-04 08:46:03 +000012
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000013BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o
14BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h
Dave Chapmanc6be8182008-10-04 08:46:03 +000015
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000016CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \
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)
Dave Chapmanc6be8182008-10-04 08:46:03 +000032
33# Rules for our test ARM application - assemble, link, then extract
34# the binary code
35
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000036# CLIP
Dave Chapmanc6be8182008-10-04 08:46:03 +000037
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000038dualboot-clip.o: dualboot.S
39 arm-elf-gcc -DSANSA_CLIP -c -o dualboot-clip.o dualboot.S
Dave Chapmanc6be8182008-10-04 08:46:03 +000040
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000041dualboot-clip.elf: dualboot-clip.o
42 arm-elf-ld -e 0 -Ttext=0 -o dualboot-clip.elf dualboot-clip.o
Dave Chapmanc6be8182008-10-04 08:46:03 +000043
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000044dualboot-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
63
64bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c
65 ./bin2c dualboot-e200v2.bin bootimg_e200v2
66
67bootimg_e200v2.o: bootimg_e200v2.c
68 gcc -c -o bootimg_e200v2.o bootimg_e200v2.c
69
70# Rules for the ucl unpack function
Dave Chapmanc6be8182008-10-04 08:46:03 +000071nrv2e_d8.o: nrv2e_d8.S
72 arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S
73
74# NOTE: this function has no absolute references, so the link address (-e)
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000075# is irrelevant. We just link at address 0, but it can run from anywhere.
Dave Chapmanc6be8182008-10-04 08:46:03 +000076nrv2e_d8.elf: nrv2e_d8.o
77 arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o
78
79nrv2e_d8.bin: nrv2e_d8.elf
80 arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin
81
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000082uclimg.c uclimg.h: nrv2e_d8.bin bin2c
83 ./bin2c nrv2e_d8.bin uclimg
Dave Chapmanc6be8182008-10-04 08:46:03 +000084
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000085uclimg.o: uclimg.c
86 gcc -c -o uclimg.o uclimg.c
Dave Chapmanc6be8182008-10-04 08:46:03 +000087
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000088bin2c: bin2c.c
89 gcc -o bin2c bin2c.c
Dave Chapmanc6be8182008-10-04 08:46:03 +000090
91clean:
Dave Chapman1c4bcfa2008-10-11 11:35:59 +000092 rm -f mkamsboot mkamsboot.o nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin *~ \
93 bin2c uclimg.c uclimg.h uclimg.o \
94 $(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES)