summaryrefslogtreecommitdiff
path: root/bootloader/telechips.c
diff options
context:
space:
mode:
authorRob Purchase <shotofadds@rockbox.org>2008-03-12 20:57:19 +0000
committerRob Purchase <shotofadds@rockbox.org>2008-03-12 20:57:19 +0000
commitc8836112c6f88298f7d43eab0e83e05ca87eaf91 (patch)
treeb5ba6773db6d8160a89d751f1cadf773dcca9160 /bootloader/telechips.c
parent769fcbd4d9425d0de1fa1628acdce1a2ffbdcd98 (diff)
downloadrockbox-c8836112c6f88298f7d43eab0e83e05ca87eaf91.tar.gz
rockbox-c8836112c6f88298f7d43eab0e83e05ca87eaf91.zip
Cowon D2: Make the bootloader functional (usage instructions to appear on the CowonD2Info wikipage shortly). Also re-enable IRAM by reducing Tremor's ICODE usage.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16646 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader/telechips.c')
-rw-r--r--bootloader/telechips.c55
1 files changed, 26 insertions, 29 deletions
diff --git a/bootloader/telechips.c b/bootloader/telechips.c
index dcb0c48d6c..8d2e36914b 100644
--- a/bootloader/telechips.c
+++ b/bootloader/telechips.c
@@ -43,12 +43,15 @@
43 43
44#if defined(COWON_D2) 44#if defined(COWON_D2)
45#include "i2c.h" 45#include "i2c.h"
46#define LOAD_ADDRESS 0x20000000 /* DRAM_START */
46#endif 47#endif
47 48
48char version[] = APPSVERSION; 49char version[] = APPSVERSION;
49 50
50extern int line; 51extern int line;
51 52
53#define MAX_LOAD_SIZE (8*1024*1024) /* Arbitrary, but plenty. */
54
52void* main(void) 55void* main(void)
53{ 56{
54 int button; 57 int button;
@@ -56,9 +59,9 @@ void* main(void)
56 int count = 0; 59 int count = 0;
57 bool do_power_off = false; 60 bool do_power_off = false;
58 61
59#if defined(COWON_D2) 62#if defined(COWON_D2) && defined(TCCBOOT)
60 int i,rc,fd,len; 63 int rc;
61 int* buf = (int*)0x21000000; /* Unused DRAM */ 64 unsigned char* loadbuffer = (unsigned char*)LOAD_ADDRESS;
62#endif 65#endif
63 66
64 power_init(); 67 power_init();
@@ -78,7 +81,12 @@ void* main(void)
78 81
79 _backlight_on(); 82 _backlight_on();
80 83
81#if defined(COWON_D2) 84/* Only load the firmware if TCCBOOT is defined - this ensures SDRAM_START is
85 available for loading the firmware. Otherwise display the debug screen. */
86#if defined(COWON_D2) && defined(TCCBOOT)
87 printf("Rockbox boot loader");
88 printf("Version %s", version);
89
82 printf("ATA"); 90 printf("ATA");
83 rc = ata_init(); 91 rc = ata_init();
84 if(rc) 92 if(rc)
@@ -94,36 +102,20 @@ void* main(void)
94 error(EDISK,rc); 102 error(EDISK,rc);
95 } 103 }
96 104
97#if 0 105 rc = load_firmware(loadbuffer, BOOTFILE, MAX_LOAD_SIZE);
98 printf("opening test file...");
99 106
100 fd = open("/test.bin", O_RDONLY); 107 if (rc < 0)
101 if (fd < 0) panicf("could not open test file");
102
103 len = filesize(fd);
104 printf("Length: %x", len);
105
106 lseek(fd, 0, SEEK_SET);
107 read(fd, buf, len);
108 close(fd);
109
110 printf("testing contents...");
111
112 i = 0;
113 while (buf[i] == i && i<(len/4)) { i++; }
114
115 if (i < len/4)
116 { 108 {
117 printf("mismatch at %x [0x%x]", i, buf[i]); 109 error(EBOOTFILE,rc);
118 } 110 }
119 else 111 else if (rc == EOK)
120 { 112 {
121 printf("passed!"); 113 int(*kernel_entry)(void);
114
115 kernel_entry = (void*) loadbuffer;
116 rc = kernel_entry();
122 } 117 }
123 while (!button_read_device()) {}; 118#else
124 while (button_read_device()) {};
125#endif
126#endif
127 119
128 while(!do_power_off) { 120 while(!do_power_off) {
129 line = 0; 121 line = 0;
@@ -145,6 +137,8 @@ void* main(void)
145 printf("Btn: 0x%08x",button); 137 printf("Btn: 0x%08x",button);
146 138
147#if defined(COWON_D2) 139#if defined(COWON_D2)
140 int i;
141
148 printf("GPIOA: 0x%08x",GPIOA); 142 printf("GPIOA: 0x%08x",GPIOA);
149 printf("GPIOB: 0x%08x",GPIOB); 143 printf("GPIOB: 0x%08x",GPIOB);
150 printf("GPIOC: 0x%08x",GPIOC); 144 printf("GPIOC: 0x%08x",GPIOC);
@@ -195,6 +189,9 @@ void* main(void)
195 /* Power-off */ 189 /* Power-off */
196 power_off(); 190 power_off();
197 191
192 printf("(NOT) POWERED OFF");
193#endif
194
198 return 0; 195 return 0;
199} 196}
200 197