diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2003-08-02 12:53:57 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2003-08-02 12:53:57 +0000 |
commit | f80505c9d0275ce56b9d03b01aa96a5ad2ac0b59 (patch) | |
tree | 8447074db140cce259e8effe7f65b4cfa7a26d34 /apps | |
parent | 9513236c9454ec363392c9160f533780f924b8e9 (diff) | |
download | rockbox-f80505c9d0275ce56b9d03b01aa96a5ad2ac0b59.tar.gz rockbox-f80505c9d0275ce56b9d03b01aa96a5ad2ac0b59.zip |
Diagnostic code added, to find init problems (charging, etc.) when flashed: the whole I/O space is saved on startup, can be dumped to a file via debug menu.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3912 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 26 | ||||
-rw-r--r-- | apps/main.c | 32 |
2 files changed, 58 insertions, 0 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 6df8f2f534..91746d2e58 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -193,6 +193,7 @@ bool dbg_mpeg_thread(void) | |||
193 | /* Tool function to calculate a CRC16 across some buffer */ | 193 | /* Tool function to calculate a CRC16 across some buffer */ |
194 | unsigned short crc_16(unsigned char* buf, unsigned len) | 194 | unsigned short crc_16(unsigned char* buf, unsigned len) |
195 | { | 195 | { |
196 | /* CCITT standard polynomial 0x1021 */ | ||
196 | static const unsigned short crc16_lookup[16] = | 197 | static const unsigned short crc16_lookup[16] = |
197 | { /* lookup table for 4 bits at a time is affordable */ | 198 | { /* lookup table for 4 bits at a time is affordable */ |
198 | 0x0000, 0x1021, 0x2042, 0x3063, | 199 | 0x0000, 0x1021, 0x2042, 0x3063, |
@@ -1324,6 +1325,30 @@ bool dbg_save_roms(void) | |||
1324 | return false; | 1325 | return false; |
1325 | } | 1326 | } |
1326 | 1327 | ||
1328 | |||
1329 | /* test code, to be removed later */ | ||
1330 | extern union /* defined in main.c */ | ||
1331 | { | ||
1332 | unsigned char port8 [512]; | ||
1333 | unsigned short port16[256]; | ||
1334 | unsigned port32[128]; | ||
1335 | } startup_io; | ||
1336 | |||
1337 | bool dbg_save_io(void) /* dump the initial I/O space to disk */ | ||
1338 | { | ||
1339 | int fd; | ||
1340 | |||
1341 | fd = creat("/startup_io.bin", O_WRONLY); | ||
1342 | if(fd >= 0) | ||
1343 | { | ||
1344 | write(fd, (void *)&startup_io, sizeof(startup_io)); | ||
1345 | close(fd); | ||
1346 | } | ||
1347 | |||
1348 | return false; | ||
1349 | } | ||
1350 | /* end of test code */ | ||
1351 | |||
1327 | bool debug_menu(void) | 1352 | bool debug_menu(void) |
1328 | { | 1353 | { |
1329 | int m; | 1354 | int m; |
@@ -1331,6 +1356,7 @@ bool debug_menu(void) | |||
1331 | 1356 | ||
1332 | struct menu_items items[] = { | 1357 | struct menu_items items[] = { |
1333 | { "Dump ROM contents", dbg_save_roms }, | 1358 | { "Dump ROM contents", dbg_save_roms }, |
1359 | { "Dump startup I/O", dbg_save_io }, | ||
1334 | { "View I/O ports", dbg_ports }, | 1360 | { "View I/O ports", dbg_ports }, |
1335 | #ifdef HAVE_LCD_BITMAP | 1361 | #ifdef HAVE_LCD_BITMAP |
1336 | #ifdef HAVE_RTC | 1362 | #ifdef HAVE_RTC |
diff --git a/apps/main.c b/apps/main.c index e10f9ed5f1..4d329bb658 100644 --- a/apps/main.c +++ b/apps/main.c | |||
@@ -54,6 +54,16 @@ | |||
54 | #include "screens.h" | 54 | #include "screens.h" |
55 | #include "power.h" | 55 | #include "power.h" |
56 | 56 | ||
57 | /* diagnostic, to be removed later: */ | ||
58 | /* snapshot of the I/O space on startup, to compare initialisations */ | ||
59 | union | ||
60 | { | ||
61 | unsigned char port8 [512]; | ||
62 | unsigned short port16[256]; | ||
63 | unsigned port32[128]; | ||
64 | } startup_io; | ||
65 | |||
66 | |||
57 | char appsversion[]=APPSVERSION; | 67 | char appsversion[]=APPSVERSION; |
58 | 68 | ||
59 | void init(void); | 69 | void init(void); |
@@ -225,6 +235,28 @@ void init(void) | |||
225 | 235 | ||
226 | int main(void) | 236 | int main(void) |
227 | { | 237 | { |
238 | /* diagnostic, to be removed later: dump I/O space */ | ||
239 | int i; | ||
240 | for (i = 0; i < 512; i++) | ||
241 | { // most can be read with 8 bit access | ||
242 | startup_io.port8[i] = *((volatile unsigned char*)0x5FFFE00 + i); | ||
243 | } | ||
244 | // some don't allow that, read with 32 bit if aligned | ||
245 | startup_io.port32[0x140/4] = *((volatile unsigned char*)0x5FFFF40); | ||
246 | startup_io.port32[0x144/4] = *((volatile unsigned char*)0x5FFFF44); | ||
247 | startup_io.port32[0x150/4] = *((volatile unsigned char*)0x5FFFF50); | ||
248 | startup_io.port32[0x154/4] = *((volatile unsigned char*)0x5FFFF54); | ||
249 | startup_io.port32[0x160/4] = *((volatile unsigned char*)0x5FFFF60); | ||
250 | startup_io.port32[0x170/4] = *((volatile unsigned char*)0x5FFFF70); | ||
251 | startup_io.port32[0x174/4] = *((volatile unsigned char*)0x5FFFF74); | ||
252 | |||
253 | // read the rest with 16 bit | ||
254 | startup_io.port16[0x14A/2] = *((volatile unsigned short*)0x5FFFF4A); | ||
255 | startup_io.port16[0x15A/2] = *((volatile unsigned short*)0x5FFFF5A); | ||
256 | startup_io.port16[0x16A/2] = *((volatile unsigned short*)0x5FFFF6A); | ||
257 | startup_io.port16[0x17A/2] = *((volatile unsigned short*)0x5FFFF7A); | ||
258 | /* end of diagnostic */ | ||
259 | |||
228 | app_main(); | 260 | app_main(); |
229 | 261 | ||
230 | while(1) { | 262 | while(1) { |