summaryrefslogtreecommitdiffstats
path: root/rbutil/mkamsboot/Makefile
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2008-10-11 11:35:59 +0000
committerDave Chapman <dave@dchapman.com>2008-10-11 11:35:59 +0000
commit1c4bcfac691d4473cf513ba958c8edbdc8c97939 (patch)
treed9a4a2c8138608c5ae7728fcf24e247024a8416f /rbutil/mkamsboot/Makefile
parentced0adc527b44c3041a2ac0a4a3a5c9cd805531e (diff)
downloadrockbox-1c4bcfac691d4473cf513ba958c8edbdc8c97939.tar.gz
rockbox-1c4bcfac691d4473cf513ba958c8edbdc8c97939.tar.bz2
rockbox-1c4bcfac691d4473cf513ba958c8edbdc8c97939.zip
Major rework of mkamsboot, extending work done by Rafael Carre. We now build one "dualboot.bin" mini-bootloader per target and embed it in the mkamsboot binary. The user of mkamsboot just needs to provide an original firmware file, and a Rockbox bootloader file. This code currently supports just the Clip (hardware revision 1) and the E200v2 - button checks are needed for the other V2 targets. NOTE: This is completely untested on-target, and may brick your device.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18767 a1c6a512-1295-4272-9138-f99709370657
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 @@
-# Change INFILE to point to your original firmware file
-INFILE=$(HOME)/FW/AMS/CLIP/m300a-1.1.17A.bin
-# OUTFILE is the file you copy to your device's root and rename to
-# (e.g.) m300a.bin
-OUTFILE=patched.bin
+# We use the UCL code available in the Rockbox tools/ directory
-# The uclpack command
-UCLPACK=../../tools/uclpack
+CFLAGS=-I../../tools/ucl/include
+LIBUCL=../../tools/ucl/src/libucl.a
-all: $(OUTFILE)
+# Edit the following variables (plus copy/paste another set of rules) when
+# adding a new target. mkamsboot.c also needs to be edited to refer to these
+# new images.
+#
+# If anyone reading this wants to improve this makefile, please do!
-mkamsboot: mkamsboot.c
- gcc -o mkamsboot -W -Wall mkamsboot.c
+BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o
+BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h
-extract_fw: extract_fw.c
- gcc -o extract_fw -W -Wall extract_fw.c
+CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \
+ dualboot-clip.bin bootimg_clip.c bootimg_clip.h
+
+E200V2FILES = dualboot-e200v2.o dualboot-e200v2.elf dualboot-e200v2.o \
+ dualboot-e200v2.bin bootimg_e200v2.c bootimg_e200v2.h
+
+all: mkamsboot
+
+$(LIBUCL):
+ make -C ../../tools/ucl/src libucl.a
+
+mkamsboot.o: mkamsboot.c $(BOOTHEADERS) uclimg.h
+ gcc $(CFLAGS) -c -o mkamsboot.o -W -Wall mkamsboot.c
+
+mkamsboot: mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL)
+ gcc -o mkamsboot mkamsboot.o $(BOOTIMAGES) uclimg.o $(LIBUCL)
# Rules for our test ARM application - assemble, link, then extract
# the binary code
-test.o: test.S
- arm-elf-as -o test.o test.S
+# CLIP
+
+dualboot-clip.o: dualboot.S
+ arm-elf-gcc -DSANSA_CLIP -c -o dualboot-clip.o dualboot.S
+
+dualboot-clip.elf: dualboot-clip.o
+ arm-elf-ld -e 0 -Ttext=0 -o dualboot-clip.elf dualboot-clip.o
+
+dualboot-clip.bin: dualboot-clip.elf
+ arm-elf-objcopy -O binary dualboot-clip.elf dualboot-clip.bin
+
+bootimg_clip.c bootimg_clip.h: dualboot-clip.bin bin2c
+ ./bin2c dualboot-clip.bin bootimg_clip
+
+bootimg_clip.o: bootimg_clip.c
+ gcc -c -o bootimg_clip.o bootimg_clip.c
+
+# E200V2
+
+dualboot-e200v2.o: dualboot.S
+ arm-elf-gcc -DSANSA_E200V2 -c -o dualboot-e200v2.o dualboot.S
+
+dualboot-e200v2.elf: dualboot-e200v2.o
+ arm-elf-ld -e 0 -Ttext=0 -o dualboot-e200v2.elf dualboot-e200v2.o
+
+dualboot-e200v2.bin: dualboot-e200v2.elf
+ arm-elf-objcopy -O binary dualboot-e200v2.elf dualboot-e200v2.bin
-test.elf: test.o
- arm-elf-ld -e 0 -Ttext=0 -o test.elf test.o
+bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c
+ ./bin2c dualboot-e200v2.bin bootimg_e200v2
-test.bin: test.elf
- arm-elf-objcopy -O binary test.elf test.bin
+bootimg_e200v2.o: bootimg_e200v2.c
+ gcc -c -o bootimg_e200v2.o bootimg_e200v2.c
-# Rules for the ucl unpack function - this is inserted in the padding at
-# the end of the original firmware block
+# Rules for the ucl unpack function
nrv2e_d8.o: nrv2e_d8.S
arm-elf-gcc -DPURE_THUMB -c -o nrv2e_d8.o nrv2e_d8.S
# NOTE: this function has no absolute references, so the link address (-e)
-# is irrelevant. We just link at address 0.
+# is irrelevant. We just link at address 0, but it can run from anywhere.
nrv2e_d8.elf: nrv2e_d8.o
arm-elf-ld -e 0 -Ttext=0 -o nrv2e_d8.elf nrv2e_d8.o
nrv2e_d8.bin: nrv2e_d8.elf
arm-elf-objcopy -O binary nrv2e_d8.elf nrv2e_d8.bin
-firmware_block.ucl: firmware_block.bin
- $(UCLPACK) --best --2e firmware_block.bin firmware_block.ucl
+uclimg.c uclimg.h: nrv2e_d8.bin bin2c
+ ./bin2c nrv2e_d8.bin uclimg
-firmware_block.bin: $(INFILE) extract_fw
- ./extract_fw $(INFILE) firmware_block.bin
+uclimg.o: uclimg.c
+ gcc -c -o uclimg.o uclimg.c
-$(OUTFILE): mkamsboot firmware_block.ucl test.bin nrv2e_d8.bin $(INFILE)
- ./mkamsboot $(INFILE) firmware_block.ucl test.bin nrv2e_d8.bin $(OUTFILE)
+bin2c: bin2c.c
+ gcc -o bin2c bin2c.c
clean:
- rm -fr amsinfo mkamsboot test.o test.elf test.bin extract_fw \
- nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin firmware_block.bin \
- firmware_block.ucl $(OUTFILE) *~
+ rm -f mkamsboot mkamsboot.o nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin *~ \
+ bin2c uclimg.c uclimg.h uclimg.o \
+ $(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES)