add sansa m200v2 support to mkamsboot.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18840 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Wenger 2008-10-19 19:51:42 +00:00
parent 184d0dab74
commit 415c46ed54
4 changed files with 53 additions and 11 deletions

View file

@ -139,6 +139,7 @@ void lcd_init_device(void)
lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER|0x7); lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER|0x7);
lcd_write_command(LCD_SET_DISPLAY_ON); lcd_write_command(LCD_SET_DISPLAY_ON);
lcd_write_command(LCD_SET_DISPLAY_START_LINE); lcd_write_command(LCD_SET_DISPLAY_START_LINE);
lcd_write_command(LCD_SET_NORMAL_DISPLAY);
} }

View file

@ -10,8 +10,8 @@ LIBUCL=../../tools/ucl/src/libucl.a
# #
# If anyone reading this wants to improve this makefile, please do! # If anyone reading this wants to improve this makefile, please do!
BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o BOOTIMAGES = bootimg_clip.o bootimg_e200v2.o bootimg_m200v2.o
BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h BOOTHEADERS = bootimg_clip.h bootimg_e200v2.h bootimg_m200v2.h
CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \ CLIPFILES = dualboot-clip.o dualboot-clip.elf dualboot-clip.o \
dualboot-clip.bin bootimg_clip.c bootimg_clip.h 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 \ E200V2FILES = dualboot-e200v2.o dualboot-e200v2.elf dualboot-e200v2.o \
dualboot-e200v2.bin bootimg_e200v2.c bootimg_e200v2.h 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 all: mkamsboot
$(LIBUCL): $(LIBUCL):
@ -64,9 +67,26 @@ dualboot-e200v2.bin: dualboot-e200v2.elf
bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c bootimg_e200v2.c bootimg_e200v2.h: dualboot-e200v2.bin bin2c
./bin2c dualboot-e200v2.bin bootimg_e200v2 ./bin2c dualboot-e200v2.bin bootimg_e200v2
bootimg_e200v2.o: bootimg_e200v2.c # M200V2
gcc -c -o bootimg_e200v2.o bootimg_e200v2.c
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 # Rules for the ucl unpack function
nrv2e_d8.o: nrv2e_d8.S nrv2e_d8.o: nrv2e_d8.S
arm-elf-gcc -DPURE_THUMB -c -o 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: clean:
rm -f mkamsboot mkamsboot.o nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin *~ \ rm -f mkamsboot mkamsboot.o nrv2e_d8.o nrv2e_d8.elf nrv2e_d8.bin *~ \
bin2c uclimg.c uclimg.h uclimg.o \ bin2c uclimg.c uclimg.h uclimg.o \
$(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES) $(BOOTIMAGES) $(CLIPFILES) $(E200V2FILES) $(M200V2FILES)

View file

@ -5,7 +5,7 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id:$ * $Id$
* *
* Copyright (C) 2008 Rafaël Carré * Copyright (C) 2008 Rafaël Carré
* *
@ -77,6 +77,8 @@ uclcopy:
orr r1, r1, #(1<<16) orr r1, r1, #(1<<16)
str r1, [r0] str r1, [r0]
#ifndef SANSA_M200V2 /* this doesnt work for m200 */
/* we check A3 unconditionally of the model because it seems to be */ /* we check A3 unconditionally of the model because it seems to be */
/* either hold, either usb on every model */ /* either hold, either usb on every model */
@ -87,6 +89,7 @@ uclcopy:
cmp r1, #0 cmp r1, #0
bne boot_of bne boot_of
#endif
/* here are model specific tests, for dual boot without a computer */ /* here are model specific tests, for dual boot without a computer */
@ -108,6 +111,22 @@ uclcopy:
cmp r1, #0 /* C6 = #0 means button pressed */ cmp r1, #0 /* C6 = #0 means button pressed */
beq boot_of 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 #else
#error No target-specific key check defined! #error No target-specific key check defined!
#endif #endif

View file

@ -89,6 +89,7 @@ execution to the uncompressed firmware.
#include "uclimg.h" #include "uclimg.h"
#include "bootimg_clip.h" #include "bootimg_clip.h"
#include "bootimg_e200v2.h" #include "bootimg_e200v2.h"
#include "bootimg_m200v2.h"
/* Win32 compatibility */ /* Win32 compatibility */
#ifndef O_BINARY #ifndef O_BINARY
@ -126,7 +127,7 @@ static const unsigned char* bootloaders[] =
bootimg_clip, bootimg_clip,
NULL, NULL,
bootimg_e200v2, bootimg_e200v2,
NULL, bootimg_m200v2,
NULL NULL
}; };
@ -136,7 +137,7 @@ static const int bootloader_sizes[] =
sizeof(bootimg_clip), sizeof(bootimg_clip),
0, 0,
sizeof(bootimg_e200v2), sizeof(bootimg_e200v2),
0, sizeof(bootimg_m200v2),
0 0
}; };
@ -373,6 +374,7 @@ int main(int argc, char* argv[])
int fw_version; int fw_version;
int totalsize; int totalsize;
unsigned char* p; unsigned char* p;
uint32_t checksum;
fprintf(stderr,"mkamsboot v" VERSION " - (C) Dave Chapman and Rafaël Carré 2008\n"); 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"); 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; 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); fprintf(stderr,"[ERR] Whole file checksum failed - %s\n",infile);
return 1; return 1;
} }
@ -420,7 +423,6 @@ int main(int argc, char* argv[])
if (bootloaders[model] == NULL) { if (bootloaders[model] == NULL) {
fprintf(stderr,"[ERR] Unsupported model - \"%s\"\n",model_names[model]); fprintf(stderr,"[ERR] Unsupported model - \"%s\"\n",model_names[model]);
free(buf); free(buf);
free(rb_unpacked);
return 1; return 1;
} }