summaryrefslogtreecommitdiff
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.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 @@
1#if defined(IPOD_ARCH) 1#if defined(IPOD_ARCH)
2ipod.c 2ipod.c
3#elif defined(GIGABEAT_F)
4gigabeat.c
3#elif defined(SANSA_E200) 5#elif defined(SANSA_E200)
4e200.c 6e200.c
5#elif defined(IRIVER_H10) 7#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 @@
1#include "config.h"
2
3#include <stdlib.h>
4#include <stdio.h>
5#include <string.h>
6#include "cpu.h"
7#include "system.h"
8#include "lcd.h"
9#include "kernel.h"
10#include "thread.h"
11#include "ata.h"
12#include "fat.h"
13#include "disk.h"
14#include "font.h"
15#include "adc.h"
16#include "backlight.h"
17#include "panic.h"
18#include "power.h"
19#include "file.h"
20
21char version[] = APPSVERSION;
22
23void go_usb_mode() {
24 /* Drop into USB mode. This does not check for disconnection. */
25
26 int i;
27
28 GPBDAT &= 0x7EF;
29 GPBCON |= 1<<8;
30
31 GPGDAT &= 0xE7FF;
32 GPGDAT |= 1<<11;
33
34 for (i = 0; i < 10000000; i++) {continue;}
35
36 GPBCON &= 0x2FFCFF;
37 GPBDAT |= 1<<5;
38 GPBDAT |= 1<<6;
39}
40
41void * main(void)
42{
43 int line = 0, i;
44 char buf[256];
45 struct partinfo* pinfo;
46 unsigned short* identify_info;
47 int testfile;
48
49 lcd_init();
50 lcd_setfont(FONT_SYSFIXED);
51/*
52 lcd_puts(0, line++, "Rockbox boot loader");
53 snprintf(buf, sizeof(buf), "Version: 20%s", version);
54 lcd_puts(0, line++, buf);
55 snprintf(buf, sizeof(buf), "Gigabeat version: 0x%08x", 1);
56 lcd_puts(0, line++, buf);
57*/
58
59 lcd_puts(0, line++, "Hold MENU when booting for rescue mode.");
60 lcd_update();
61
62 /* hold MENU to enter rescue mode */
63 if (GPGDAT & 2) {
64 lcd_puts(0, line++, "Entering rescue mode..");
65 lcd_update();
66 go_usb_mode();
67 while(1);
68 }
69
70 i = ata_init();
71 i = disk_mount_all();
72
73 snprintf(buf, sizeof(buf), "disk_mount_all: %d", i);
74 lcd_puts(0, line++, buf);
75
76 identify_info = ata_get_identify();
77
78 for (i=0; i < 20; i++)
79 ((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
80
81 buf[40]=0;
82
83 /* kill trailing space */
84 for (i=39; i && buf[i]==' '; i--)
85 buf[i] = 0;
86
87 lcd_puts(0, line++, "Model");
88 lcd_puts(0, line++, buf);
89
90 for (i=0; i < 4; i++)
91 ((unsigned short*)buf)[i]=htobe16(identify_info[i+23]);
92
93 buf[8]=0;
94
95 lcd_puts(0, line++, "Firmware");
96 lcd_puts(0, line++, buf);
97
98 pinfo = disk_partinfo(0);
99 snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB",
100 pinfo->type, pinfo->size / 2048);
101 lcd_puts(0, line++, buf);
102
103 testfile = open("/boottest.txt", O_WRONLY|O_CREAT|O_TRUNC);
104 write(testfile, "It works!", 9);
105 close(testfile);
106
107 lcd_update();
108
109 /* now wait in USB mode so the bootloader can be updated */
110 go_usb_mode();
111 while(1);
112
113 return((void *)0);
114}
115
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)
69#define FLASHSIZE 256K - ROM_START 69#define FLASHSIZE 256K - ROM_START
70#endif 70#endif
71 71
72#ifndef CPU_PP 72#if !defined(CPU_PP) && (CONFIG_CPU!=S3C2440)
73MEMORY 73MEMORY
74{ 74{
75 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE 75 DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
@@ -117,6 +117,36 @@ SECTIONS
117 _end = .; 117 _end = .;
118 } 118 }
119} 119}
120#elif (CONFIG_CPU==S3C2440)
121{
122 . = DRAMORIG + 0x8000;
123 .text : {
124 *(.init.text)
125 *(.text)
126 }
127 .data : {
128 *(.icode)
129 *(.irodata)
130 *(.idata)
131 *(.data)
132 _dataend = . ;
133 }
134 .stack :
135 {
136 *(.stack)
137 _stackbegin = .;
138 stackbegin = .;
139 . += 0x2000;
140 _stackend = .;
141 stackend = .;
142 }
143 .bss : {
144 _edata = .;
145 *(.bss);
146 *(.ibss);
147 _end = .;
148 }
149}
120#else 150#else
121{ 151{
122 .vectors : 152 .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:
303 .space 400 303 .space 400
304#endif /* PP specific */ 304#endif /* PP specific */
305/* Code for ARM bootloader targets other than iPod go here */ 305/* Code for ARM bootloader targets other than iPod go here */
306
307#if CONFIG_CPU == S3C2440
308 bl main
309#endif
310
306#else /* BOOTLOADER */ 311#else /* BOOTLOADER */
307 312
308 /* Set up stack for IRQ mode */ 313 /* 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)
56 56
57void sleep(int ticks) 57void sleep(int ticks)
58{ 58{
59#if CONFIG_CPU == S3C2440 && defined(BOOTLOADER)
60 int counter;
61 TCON &= ~(1 << 20); // stop timer 4
62 // TODO: this constant depends on dividers settings inherited from
63 // firmware. Set them explicitly somwhere.
64 TCNTB4 = 12193 * ticks / HZ;
65 TCON |= 1 << 21; // set manual bit
66 TCON &= ~(1 << 21); // reset manual bit
67 TCON &= ~(1 << 22); //autoreload Off
68 TCON |= (1 << 20); // start timer 4
69 do {
70 counter = TCNTO4;
71 } while(counter > 0);
72
73#else
59 /* Always sleep at least 1 tick */ 74 /* Always sleep at least 1 tick */
60 int timeout = current_tick + ticks + 1; 75 int timeout = current_tick + ticks + 1;
61 76
@@ -63,12 +78,16 @@ void sleep(int ticks)
63 sleep_thread(); 78 sleep_thread();
64 } 79 }
65 wake_up_thread(); 80 wake_up_thread();
81#endif
66} 82}
67 83
68void yield(void) 84void yield(void)
69{ 85{
86#if CONFIG_CPU == S3C2440 && defined(BOOTLOADER)
87#else
70 switch_thread(); 88 switch_thread();
71 wake_up_thread(); 89 wake_up_thread();
90#endif
72} 91}
73 92
74/**************************************************************************** 93/****************************************************************************
diff --git a/tools/configure b/tools/configure
index 449041094a..f9558b8e9d 100755
--- a/tools/configure
+++ b/tools/configure
@@ -997,7 +997,7 @@ fi
997 case $option in 997 case $option in
998 [Bb]) 998 [Bb])
999 case $archos in 999 case $archos in
1000 h100|h120|h300|x5|ipodcolor|ipodnano|ipodvideo|ipod3g|ipod4g|ipodmini|ipodmini2g|h10|e200) 1000 h100|h120|h300|x5|ipodcolor|ipodnano|ipodvideo|ipod3g|ipod4g|ipodmini|ipodmini2g|gigabeatf|h10|e200)
1001 extradefines="-DBOOTLOADER" # for target makefile symbol EXTRA_DEFINES 1001 extradefines="-DBOOTLOADER" # for target makefile symbol EXTRA_DEFINES
1002 appsdir='\$(ROOTDIR)/bootloader' 1002 appsdir='\$(ROOTDIR)/bootloader'
1003 apps="bootloader" 1003 apps="bootloader"