summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcoen Hirschberg <marcoen@gmail.com>2006-08-12 08:27:48 +0000
committerMarcoen Hirschberg <marcoen@gmail.com>2006-08-12 08:27:48 +0000
commit0a0682474e6326f63994a6cd62f23efd9818a7ec (patch)
tree9ddd8fbfe72fa4ca001b21de93b951ab24dc951f
parentdd754886f5fd4004b521c954e263772d35fb6a46 (diff)
downloadrockbox-0a0682474e6326f63994a6cd62f23efd9818a7ec.tar.gz
rockbox-0a0682474e6326f63994a6cd62f23efd9818a7ec.tar.bz2
rockbox-0a0682474e6326f63994a6cd62f23efd9818a7ec.zip
initial gigabeat bootloader (only test code)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10536 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/SOURCES2
-rw-r--r--bootloader/gigabeat.c115
-rw-r--r--firmware/boot.lds32
-rw-r--r--firmware/crt0.S5
-rw-r--r--firmware/kernel.c19
-rwxr-xr-xtools/configure2
6 files changed, 173 insertions, 2 deletions
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index c4af9cd838..52bb973cf7 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -1,5 +1,7 @@
#if defined(IPOD_ARCH)
ipod.c
+#elif defined(GIGABEAT_F)
+gigabeat.c
#elif defined(SANSA_E200)
e200.c
#elif defined(IRIVER_H10)
diff --git a/bootloader/gigabeat.c b/bootloader/gigabeat.c
new file mode 100644
index 0000000000..dcd013e867
--- /dev/null
+++ b/bootloader/gigabeat.c
@@ -0,0 +1,115 @@
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "cpu.h"
+#include "system.h"
+#include "lcd.h"
+#include "kernel.h"
+#include "thread.h"
+#include "ata.h"
+#include "fat.h"
+#include "disk.h"
+#include "font.h"
+#include "adc.h"
+#include "backlight.h"
+#include "panic.h"
+#include "power.h"
+#include "file.h"
+
+char version[] = APPSVERSION;
+
+void go_usb_mode() {
+ /* Drop into USB mode. This does not check for disconnection. */
+
+ int i;
+
+ GPBDAT &= 0x7EF;
+ GPBCON |= 1<<8;
+
+ GPGDAT &= 0xE7FF;
+ GPGDAT |= 1<<11;
+
+ for (i = 0; i < 10000000; i++) {continue;}
+
+ GPBCON &= 0x2FFCFF;
+ GPBDAT |= 1<<5;
+ GPBDAT |= 1<<6;
+}
+
+void * main(void)
+{
+ int line = 0, i;
+ char buf[256];
+ struct partinfo* pinfo;
+ unsigned short* identify_info;
+ int testfile;
+
+ lcd_init();
+ lcd_setfont(FONT_SYSFIXED);
+/*
+ lcd_puts(0, line++, "Rockbox boot loader");
+ snprintf(buf, sizeof(buf), "Version: 20%s", version);
+ lcd_puts(0, line++, buf);
+ snprintf(buf, sizeof(buf), "Gigabeat version: 0x%08x", 1);
+ lcd_puts(0, line++, buf);
+*/
+
+ lcd_puts(0, line++, "Hold MENU when booting for rescue mode.");
+ lcd_update();
+
+ /* hold MENU to enter rescue mode */
+ if (GPGDAT & 2) {
+ lcd_puts(0, line++, "Entering rescue mode..");
+ lcd_update();
+ go_usb_mode();
+ while(1);
+ }
+
+ i = ata_init();
+ i = disk_mount_all();
+
+ snprintf(buf, sizeof(buf), "disk_mount_all: %d", i);
+ lcd_puts(0, line++, buf);
+
+ identify_info = ata_get_identify();
+
+ for (i=0; i < 20; i++)
+ ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
+
+ buf[40]=0;
+
+ /* kill trailing space */
+ for (i=39; i && buf[i]==' '; i--)
+ buf[i] = 0;
+
+ lcd_puts(0, line++, "Model");
+ lcd_puts(0, line++, buf);
+
+ for (i=0; i < 4; i++)
+ ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]);
+
+ buf[8]=0;
+
+ lcd_puts(0, line++, "Firmware");
+ lcd_puts(0, line++, buf);
+
+ pinfo = disk_partinfo(0);
+ snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB",
+ pinfo->type, pinfo->size / 2048);
+ lcd_puts(0, line++, buf);
+
+ testfile = open("/boottest.txt", O_WRONLY|O_CREAT|O_TRUNC);
+ write(testfile, "It works!", 9);
+ close(testfile);
+
+ lcd_update();
+
+ /* now wait in USB mode so the bootloader can be updated */
+ go_usb_mode();
+ while(1);
+
+ return((void *)0);
+}
+
diff --git a/firmware/boot.lds b/firmware/boot.lds
index 78dd40bf92..56383d7723 100644
--- a/firmware/boot.lds
+++ b/firmware/boot.lds
@@ -69,7 +69,7 @@ INPUT(crt0.o)
#define FLASHSIZE 256K - ROM_START
#endif
-#ifndef CPU_PP
+#if !defined(CPU_PP) && (CONFIG_CPU!=S3C2440)
MEMORY
{
DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
@@ -117,6 +117,36 @@ SECTIONS
_end = .;
}
}
+#elif (CONFIG_CPU==S3C2440)
+{
+ . = DRAMORIG + 0x8000;
+ .text : {
+ *(.init.text)
+ *(.text)
+ }
+ .data : {
+ *(.icode)
+ *(.irodata)
+ *(.idata)
+ *(.data)
+ _dataend = . ;
+ }
+ .stack :
+ {
+ *(.stack)
+ _stackbegin = .;
+ stackbegin = .;
+ . += 0x2000;
+ _stackend = .;
+ stackend = .;
+ }
+ .bss : {
+ _edata = .;
+ *(.bss);
+ *(.ibss);
+ _end = .;
+ }
+}
#else
{
.vectors :
diff --git a/firmware/crt0.S b/firmware/crt0.S
index 1c52658c7c..96e08be9f1 100644
--- a/firmware/crt0.S
+++ b/firmware/crt0.S
@@ -303,6 +303,11 @@ boot_table:
.space 400
#endif /* PP specific */
/* Code for ARM bootloader targets other than iPod go here */
+
+#if CONFIG_CPU == S3C2440
+ bl main
+#endif
+
#else /* BOOTLOADER */
/* Set up stack for IRQ mode */
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 7c5c74c662..1c8bf9dd81 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -56,6 +56,21 @@ void kernel_init(void)
void sleep(int ticks)
{
+#if CONFIG_CPU == S3C2440 && defined(BOOTLOADER)
+ int counter;
+ TCON &= ~(1 << 20); // stop timer 4
+ // TODO: this constant depends on dividers settings inherited from
+ // firmware. Set them explicitly somwhere.
+ TCNTB4 = 12193 * ticks / HZ;
+ TCON |= 1 << 21; // set manual bit
+ TCON &= ~(1 << 21); // reset manual bit
+ TCON &= ~(1 << 22); //autoreload Off
+ TCON |= (1 << 20); // start timer 4
+ do {
+ counter = TCNTO4;
+ } while(counter > 0);
+
+#else
/* Always sleep at least 1 tick */
int timeout = current_tick + ticks + 1;
@@ -63,12 +78,16 @@ void sleep(int ticks)
sleep_thread();
}
wake_up_thread();
+#endif
}
void yield(void)
{
+#if CONFIG_CPU == S3C2440 && defined(BOOTLOADER)
+#else
switch_thread();
wake_up_thread();
+#endif
}
/****************************************************************************
diff --git a/tools/configure b/tools/configure
index 449041094a..f9558b8e9d 100755
--- a/tools/configure
+++ b/tools/configure
@@ -997,7 +997,7 @@ fi
case $option in
[Bb])
case $archos in
- h100|h120|h300|x5|ipodcolor|ipodnano|ipodvideo|ipod3g|ipod4g|ipodmini|ipodmini2g|h10|e200)
+ h100|h120|h300|x5|ipodcolor|ipodnano|ipodvideo|ipod3g|ipod4g|ipodmini|ipodmini2g|gigabeatf|h10|e200)
extradefines="-DBOOTLOADER" # for target makefile symbol EXTRA_DEFINES
appsdir='\$(ROOTDIR)/bootloader'
apps="bootloader"