From 415c46ed548f6f75e638ad5e30829f10aec176f9 Mon Sep 17 00:00:00 2001 From: Dominik Wenger Date: Sun, 19 Oct 2008 19:51:42 +0000 Subject: add sansa m200v2 support to mkamsboot. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18840 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/lcd-ssd1815.c | 1 + rbutil/mkamsboot/Makefile | 30 +++++++++++++++++++++++++----- rbutil/mkamsboot/dualboot.S | 21 ++++++++++++++++++++- rbutil/mkamsboot/mkamsboot.c | 12 +++++++----- 4 files changed, 53 insertions(+), 11 deletions(-) diff --git a/firmware/target/arm/lcd-ssd1815.c b/firmware/target/arm/lcd-ssd1815.c index fc3db940ba..2acfa791cb 100644 --- a/firmware/target/arm/lcd-ssd1815.c +++ b/firmware/target/arm/lcd-ssd1815.c @@ -139,6 +139,7 @@ void lcd_init_device(void) lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER|0x7); lcd_write_command(LCD_SET_DISPLAY_ON); lcd_write_command(LCD_SET_DISPLAY_START_LINE); + lcd_write_command(LCD_SET_NORMAL_DISPLAY); } 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; } -- cgit v1.2.3