Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 1 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 2 | # We use the UCL code available in the Rockbox tools/ directory |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 3 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 4 | CFLAGS=-I../../tools/ucl/include |
| 5 | LIBUCL=../../tools/ucl/src/libucl.a |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 6 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 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! |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 12 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 13 | BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o |
| 14 | BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 15 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 16 | CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \ |
| 17 | dualboot-clip.bin bootimg_clip.c bootimg_clip.h |
| 18 | |
| 19 | E200V2FILES = dualboot-e200v2.o dualboot-e200v2.elf dualboot-e200v2.o \ |
| 20 | dualboot-e200v2.bin bootimg_e200v2.c bootimg_e200v2.h |
| 21 | |
| 22 | all: mkamsboot |
| 23 | |
| 24 | $(LIBUCL): |
| 25 | make -C ../../tools/ucl/src libucl.a |
| 26 | |
| 27 | mkamsboot.o: mkamsboot.c $(BOOTHEADERS) uclimg.h |
| 28 | gcc $(CFLAGS) -c -o mkamsboot.o -W -Wall mkamsboot.c |
| 29 | |
| 30 | mkamsboot: mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL) |
| 31 | gcc -o mkamsboot mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL) |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 32 | |
| 33 | # Rules for our test ARM application - assemble, link, then extract |
| 34 | # the binary code |
| 35 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 36 | # CLIP |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 37 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 38 | dualboot-clip.o: dualboot.S |
| 39 | arm-elf-gcc -DSANSA_CLIP -c -o dualboot-clip.o dualboot.S |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 40 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 41 | dualboot-clip.elf: dualboot-clip.o |
| 42 | arm-elf-ld -e 0 -Ttext=0 -o dualboot-clip.elf dualboot-clip.o |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 43 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 44 | dualboot-clip.bin: dualboot-clip.elf |
| 45 | arm-elf-objcopy -O binary dualboot-clip.elf dualboot-clip.bin |
| 46 | |
| 47 | bootimg_clip.c bootimg_clip.h: dualboot-clip.bin bin2c |
| 48 | ./bin2c dualboot-clip.bin bootimg_clip |
| 49 | |
| 50 | bootimg_clip.o: bootimg_clip.c |
| 51 | gcc -c -o bootimg_clip.o bootimg_clip.c |
| 52 | |
| 53 | # E200V2 |
| 54 | |
| 55 | dualboot-e200v2.o: dualboot.S |
| 56 | arm-elf-gcc -DSANSA_E200V2 -c -o dualboot-e200v2.o dualboot.S |
| 57 | |
| 58 | dualboot-e200v2.elf: dualboot-e200v2.o |
| 59 | arm-elf-ld -e 0 -Ttext=0 -o dualboot-e200v2.elf dualboot-e200v2.o |
| 60 | |
| 61 | dualboot-e200v2.bin: dualboot-e200v2.elf |
| 62 | arm-elf-objcopy -O binary dualboot-e200v2.elf dualboot-e200v2.bin |
| 63 | |
| 64 | bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c |
| 65 | ./bin2c dualboot-e200v2.bin bootimg_e200v2 |
| 66 | |
| 67 | bootimg_e200v2.o: bootimg_e200v2.c |
| 68 | gcc -c -o bootimg_e200v2.o bootimg_e200v2.c |
| 69 | |
| 70 | # Rules for the ucl unpack function |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 71 | nrv2e_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 Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 75 | # is irrelevant. We just link at address 0, but it can run from anywhere. |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 76 | nrv2e_d8.elf: nrv2e_d8.o |
| 77 | arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o |
| 78 | |
| 79 | nrv2e_d8.bin: nrv2e_d8.elf |
| 80 | arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin |
| 81 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 82 | uclimg.c uclimg.h: nrv2e_d8.bin bin2c |
| 83 | ./bin2c nrv2e_d8.bin uclimg |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 84 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 85 | uclimg.o: uclimg.c |
| 86 | gcc -c -o uclimg.o uclimg.c |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 87 | |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 88 | bin2c: bin2c.c |
| 89 | gcc -o bin2c bin2c.c |
Dave Chapman | c6be818 | 2008-10-04 08:46:03 +0000 | [diff] [blame] | 90 | |
| 91 | clean: |
Dave Chapman | 1c4bcfa | 2008-10-11 11:35:59 +0000 | [diff] [blame^] | 92 | 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) |