diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2008-10-19 19:51:42 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2008-10-19 19:51:42 +0000 |
commit | 415c46ed548f6f75e638ad5e30829f10aec176f9 (patch) | |
tree | 9a5678895db8ae157203b8b5bf3051e15f4561bc /rbutil | |
parent | 184d0dab7446d5b02c80e92552e71d17cb8db337 (diff) |
add sansa m200v2 support to mkamsboot.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18840 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/mkamsboot/Makefile | 30 | ||||
-rw-r--r-- | rbutil/mkamsboot/dualboot.S | 21 | ||||
-rw-r--r-- | rbutil/mkamsboot/mkamsboot.c | 12 |
3 files changed, 52 insertions, 11 deletions
diff --git a/rbutil/mkamsboot/Makefile b/rbutil/mkamsboot/Makefile index e3d98f03f0..c5f8dd5e51 100644 --- a/rbutil/mkamsboot/Makefile +++ b/rbutil/mkamsboot/Makefile @@ -10,8 +10,8 @@ LIBUCL=../../tools/ucl/src/libucl.a # # If anyone reading this wants to improve this makefile, please do! -BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o -BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h +BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o bootimg_m200v2.o +BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h bootimg_m200v2.h CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \ dualboot-clip.bin bootimg_clip.c bootimg_clip.h @@ -19,6 +19,9 @@ CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \ E200V2FILES = dualboot-e200v2.o dualboot-e200v2.elf dualboot-e200v2.o \ dualboot-e200v2.bin bootimg_e200v2.c bootimg_e200v2.h +M200V2FILES = dualboot-m200v2.o dualboot-m200v2.elf dualboot-m200v2.o \ + dualboot-m200v2.bin bootimg_m200v2.c bootimg_m200v2.h + all: mkamsboot $(LIBUCL): @@ -64,9 +67,26 @@ dualboot-e200v2.bin: dualboot-e200v2.elf bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c ./bin2c dualboot-e200v2.bin bootimg_e200v2 -bootimg_e200v2.o: bootimg_e200v2.c - gcc -c -o bootimg_e200v2.o bootimg_e200v2.c +# M200V2 + +bootimg_m200v2.o: bootimg_m200v2.c + gcc -c -o bootimg_m200v2.o bootimg_m200v2.c +dualboot-m200v2.o: dualboot.S + arm-elf-gcc -DSANSA_M200V2 -c -o dualboot-m200v2.o dualboot.S + +dualboot-m200v2.elf: dualboot-m200v2.o + arm-elf-ld -e 0 -Ttext=0 -o dualboot-m200v2.elf dualboot-m200v2.o + +dualboot-m200v2.bin: dualboot-m200v2.elf + arm-elf-objcopy -O binary dualboot-m200v2.elf dualboot-m200v2.bin + +bootimg_m200v2.c bootimg_m200v2.h: dualboot-m200v2.bin bin2c + ./bin2c dualboot-m200v2.bin bootimg_m200v2 + +bootimg_m200v2.o: bootimg_m200v2.c + gcc -c -o bootimg_m200v2.o bootimg_m200v2.c + # 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 @@ -91,4 +111,4 @@ bin2c: bin2c.c clean: rm -f mkamsboot mkamsboot.o nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin *~ \ bin2c uclimg.c uclimg.h uclimg.o \ - $(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES) + $(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES) $(M200V2FILES) diff --git a/rbutil/mkamsboot/dualboot.S b/rbutil/mkamsboot/dualboot.S index 8a1caa6f63..1713017060 100644 --- a/rbutil/mkamsboot/dualboot.S +++ b/rbutil/mkamsboot/dualboot.S @@ -5,7 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id:$ + * $Id$ * * Copyright (C) 2008 Rafaël Carré * @@ -77,6 +77,8 @@ uclcopy: orr r1, r1, #(1<<16) str r1, [r0] + +#ifndef SANSA_M200V2 /* this doesnt work for m200 */ /* we check A3 unconditionally of the model because it seems to be */ /* either hold, either usb on every model */ @@ -87,6 +89,7 @@ uclcopy: cmp r1, #0 bne boot_of +#endif /* here are model specific tests, for dual boot without a computer */ @@ -108,6 +111,22 @@ uclcopy: cmp r1, #0 /* C6 = #0 means button pressed */ beq boot_of +#elif defined(SANSA_M200V2) +.set row, (1<<5) /* 4 or <<5 or <<6 */ + /* enable output on A3-A5 */ + /* set keyscan row A0-A3 */ + ldr r0, =GPIOA + mov r1, #row + str r1, [r0, #0x400] + str r1, [r0, #(4*row)] + +.set col, (1<<0) /* 0 or 1, 2, 3 */ + /* read keyscan column A0-A3 */ + ldr r2, [r0, #(4*col)] + + /* check value read (compare to 0!) */ + cmp r2, #0 + beq boot_of /* for beginning we jump if button select is not pressed */ #else #error No target-specific key check defined! #endif diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c index cfa9e37746..e4b6e09782 100644 --- a/rbutil/mkamsboot/mkamsboot.c +++ b/rbutil/mkamsboot/mkamsboot.c @@ -89,6 +89,7 @@ execution to the uncompressed firmware. #include "uclimg.h" #include "bootimg_clip.h" #include "bootimg_e200v2.h" +#include "bootimg_m200v2.h" /* Win32 compatibility */ #ifndef O_BINARY @@ -126,7 +127,7 @@ static const unsigned char* bootloaders[] = bootimg_clip, NULL, bootimg_e200v2, - NULL, + bootimg_m200v2, NULL }; @@ -136,7 +137,7 @@ static const int bootloader_sizes[] = sizeof(bootimg_clip), 0, sizeof(bootimg_e200v2), - 0, + sizeof(bootimg_m200v2), 0 }; @@ -373,6 +374,7 @@ int main(int argc, char* argv[]) int fw_version; int totalsize; unsigned char* p; + uint32_t checksum; fprintf(stderr,"mkamsboot v" VERSION " - (C) Dave Chapman and Rafaël Carré 2008\n"); fprintf(stderr,"This is free software; see the source for copying conditions. There is NO\n"); @@ -395,9 +397,10 @@ int main(int argc, char* argv[]) return 1; } - /* TODO: Do some more sanity checks on the OF image */ + /* TODO: Do some more sanity checks on the OF image. Some images (like m200v2) dont have a checksum at the end, only padding (0xdeadbeef). */ + checksum = get_uint32le(buf + len - 4); + if (checksum != 0xefbeadde && checksum != calc_checksum(buf, len - 4)) { - if (get_uint32le(buf + len - 4) != calc_checksum(buf, len - 4)) { fprintf(stderr,"[ERR] Whole file checksum failed - %s\n",infile); return 1; } @@ -420,7 +423,6 @@ int main(int argc, char* argv[]) if (bootloaders[model] == NULL) { fprintf(stderr,"[ERR] Unsupported model - \"%s\"\n",model_names[model]); free(buf); - free(rb_unpacked); return 1; } |