summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-09-09 11:20:20 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-09-09 11:20:20 +0000
commit9db22efd1fe133d7477fb7ceb6ded745dc889cdc (patch)
tree3618bcafee34be52d6bac212daf5e19ab843cadd
parentc9f6858de83ec5a15e4d4bdf78185cbca231e5bf (diff)
downloadrockbox-9db22efd1fe133d7477fb7ceb6ded745dc889cdc.tar.gz
rockbox-9db22efd1fe133d7477fb7ceb6ded745dc889cdc.tar.bz2
rockbox-9db22efd1fe133d7477fb7ceb6ded745dc889cdc.zip
Firmware "hacker" code for the e200r install so the full bootloader rom doesnt need to be written.
Requires a custom version of e200tool which isnt available yet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14654 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/Makefile4
-rw-r--r--bootloader/SOURCES4
-rw-r--r--bootloader/main-e200r-installer.c119
-rw-r--r--firmware/boot.lds2
-rw-r--r--firmware/export/config-e200.h3
-rw-r--r--firmware/target/arm/crt0-pp-bl.S3
-rwxr-xr-xtools/configure10
7 files changed, 142 insertions, 3 deletions
diff --git a/bootloader/Makefile b/bootloader/Makefile
index 342cdc5861..4c63cfea18 100644
--- a/bootloader/Makefile
+++ b/bootloader/Makefile
@@ -18,7 +18,7 @@ ifdef DEBUG
CFLAGS += -g
endif
-SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P -include "config.h" - )
+SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
DIRS = .
ifdef APPEXTRA
@@ -50,7 +50,7 @@ endif
dep: $(DEPFILE)
$(LINKFILE): $(LDS)
- $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - >$@
+ $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) $(DEFINES) -E -P $(ROMBUILD) - >$@
$(MAXOUTFILE):
$(SILENT)echo '#include "config.h"' > $(MAXINFILE)
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 5d82e57309..2de38930ea 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -6,7 +6,11 @@ ipod.c
gigabeat.c
#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || \
defined(SANSA_E200) || defined(SANSA_C200)
+#ifdef E200R_INSTALLER
+main-e200r-installer.c
+#else
main-pp.c
+#endif
#elif defined(ELIO_TPJ1022)
tpj1022.c
#elif defined(IAUDIO_X5) || defined(IAUDIO_M5)
diff --git a/bootloader/main-e200r-installer.c b/bootloader/main-e200r-installer.c
new file mode 100644
index 0000000000..9b977ca538
--- /dev/null
+++ b/bootloader/main-e200r-installer.c
@@ -0,0 +1,119 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Barry Wardell
+ *
+ * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
+ * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include "common.h"
+#include "cpu.h"
+#include "file.h"
+#include "system.h"
+#include "kernel.h"
+#include "lcd.h"
+#include "font.h"
+#include "ata.h"
+#include "button.h"
+#include "disk.h"
+#include "crc32-mi4.h"
+#include <string.h>
+#include "i2c.h"
+#include "backlight-target.h"
+
+/* Bootloader version */
+char version[] = APPSVERSION;
+
+#define START_SECTOR_OF_ROM 1
+#define ROMSECTOR_TO_HACK 63
+#define HACK_OFFSET 498
+#define KNOWN_CRC32 0x5a09c266
+char knownBytes[] = {0x00, 0x24, 0x07, 0xe1};
+char changedBytes[] = {0xc0, 0x46, 0xc0, 0x46 };
+void* main(void)
+{
+ int i;
+ int btn;
+ int num_partitions;
+ int crc32;
+ char sector[512];
+ struct partinfo* pinfo;
+ chksum_crc32gentab ();
+
+ system_init();
+ kernel_init();
+ lcd_init();
+ font_init();
+ button_init();
+ i2c_init();
+ __backlight_on();
+
+ lcd_set_foreground(LCD_WHITE);
+ lcd_set_background(LCD_BLACK);
+ lcd_clear_display();
+
+ btn = button_read_device();
+ verbose = true;
+
+ lcd_setfont(FONT_SYSFIXED);
+
+ printf("Rockbox e200R installer");
+ printf("Version: %s", version);
+ printf(MODEL_NAME);
+
+ i=ata_init();
+ disk_init(IF_MV(0));
+ num_partitions = disk_mount_all();
+ if (num_partitions<=0)
+ {
+ error(EDISK,num_partitions);
+ }
+ pinfo = disk_partinfo(1);
+ printf("--- Partition info ---");
+ printf("start: %x", pinfo->start);
+ printf("size: %x", pinfo->size);
+ printf("type: %x", pinfo->type);
+ printf("reading: %x", (START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK)*512);
+ ata_read_sectors(IF_MV2(0,)
+ pinfo->start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK,
+ 1 , sector);
+ crc32 = chksum_crc32 (sector, 512);
+ printf("--- Hack Status ---");
+ printf("Sector checksum: %x", crc32);
+
+ if ((crc32 == KNOWN_CRC32) &&
+ !memcmp(&sector[HACK_OFFSET], knownBytes,
+ sizeof(knownBytes)/sizeof(*knownBytes)))
+ {
+
+ memcpy(&sector[HACK_OFFSET], changedBytes,
+ sizeof(changedBytes)/sizeof(*changedBytes));
+ ata_write_sectors(IF_MV2(0,)
+ pinfo->start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK,
+ 1 , sector);
+ printf("Firmware Hacked");
+ printf("Proceed to Step 2");
+ }
+ else
+ printf("Unknown bootloader... aborted");
+ GPIOG_OUTPUT_VAL &=~0x80;
+
+ while(1);
+ return NULL;
+}
+
diff --git a/firmware/boot.lds b/firmware/boot.lds
index 0896e86fca..7f7bb9b12f 100644
--- a/firmware/boot.lds
+++ b/firmware/boot.lds
@@ -45,7 +45,9 @@ INPUT(target/sh/crt0.o)
#define FLASHSIZE 2M
#elif (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024)
#define DRAMORIG 0x10000000
+#ifndef IRAMORIG
#define IRAMORIG 0x40000000
+#endif
#define IRAMSIZE 0x20000
#define FLASHORIG 0x001f0000
#define FLASHSIZE 2M
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h
index fdcfa840eb..3bde3fc204 100644
--- a/firmware/export/config-e200.h
+++ b/firmware/export/config-e200.h
@@ -187,4 +187,7 @@
#define DEFAULT_REC_LEFT_GAIN 23
#define DEFAULT_REC_RIGHT_GAIN 23
+#ifdef E200R_INSTALLER
+#define IRAMORIG 0x40004000
+#endif
diff --git a/firmware/target/arm/crt0-pp-bl.S b/firmware/target/arm/crt0-pp-bl.S
index 4f50cac699..ef04eced30 100644
--- a/firmware/target/arm/crt0-pp-bl.S
+++ b/firmware/target/arm/crt0-pp-bl.S
@@ -51,7 +51,7 @@ start:
#endif
msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */
-
+#ifndef E200R_INSTALLER
/* 1 - Copy the bootloader to IRAM */
/* get the high part of our execute address */
ldr r7, =0xffffff00
@@ -79,6 +79,7 @@ pad_skip:
/* 2 - Jump both CPU and COP there */
ldr pc, =start_loc /* jump to the relocated start_loc: */
+#endif /* E200R_INSTALLER */
start_loc:
diff --git a/tools/configure b/tools/configure
index 36295b5446..9cd3991e90 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1424,6 +1424,9 @@ fi
ifp7xx)
gdbstub="(G)DB stub, "
;;
+ e200r|e200)
+ gdbstub="(I)installer, "
+ ;;
*)
;;
esac
@@ -1434,6 +1437,13 @@ fi
option=`input`;
case $option in
+ [Ii])
+ appsdir='\$(ROOTDIR)/bootloader'
+ apps="bootloader"
+ extradefines="-DBOOTLOADER -DE200R_INSTALLER -ffunction-sections -fdata-sections"
+ bootloader="1"
+ echo "e200R-installer build selected"
+ ;;
[Bb])
if test $t_manufacturer = "archos"; then
# Archos SH-based players do this somewhat differently for