diff options
Diffstat (limited to 'apps/debug_menu.c')
-rw-r--r-- | apps/debug_menu.c | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index d8f91cd8ff..6df21ca48f 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include "dircache.h" | 52 | #include "dircache.h" |
53 | #include "tagcache.h" | 53 | #include "tagcache.h" |
54 | #include "lcd-remote.h" | 54 | #include "lcd-remote.h" |
55 | #include "crc32.h" | ||
55 | 56 | ||
56 | #ifdef HAVE_LCD_BITMAP | 57 | #ifdef HAVE_LCD_BITMAP |
57 | #include "widgets.h" | 58 | #include "widgets.h" |
@@ -301,41 +302,6 @@ bool dbg_audio_thread(void) | |||
301 | #endif /* CONFIG_CODEC */ | 302 | #endif /* CONFIG_CODEC */ |
302 | #endif /* HAVE_LCD_BITMAP */ | 303 | #endif /* HAVE_LCD_BITMAP */ |
303 | 304 | ||
304 | /* Tool function to calculate a CRC16 across some buffer */ | ||
305 | unsigned short crc_16(const unsigned char* buf, unsigned len) | ||
306 | { | ||
307 | /* CCITT standard polynomial 0x1021 */ | ||
308 | static const unsigned short crc16_lookup[16] = | ||
309 | { /* lookup table for 4 bits at a time is affordable */ | ||
310 | 0x0000, 0x1021, 0x2042, 0x3063, | ||
311 | 0x4084, 0x50A5, 0x60C6, 0x70E7, | ||
312 | 0x8108, 0x9129, 0xA14A, 0xB16B, | ||
313 | 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF | ||
314 | }; | ||
315 | unsigned short crc16 = 0xFFFF; /* initialise to 0xFFFF (CCITT specification) */ | ||
316 | unsigned t; | ||
317 | unsigned char byte; | ||
318 | |||
319 | while (len--) | ||
320 | { | ||
321 | byte = *buf++; /* get one byte of data */ | ||
322 | |||
323 | /* upper nibble of our data */ | ||
324 | t = crc16 >> 12; /* extract the 4 most significant bits */ | ||
325 | t ^= byte >> 4; /* XOR in 4 bits of the data into the extracted bits */ | ||
326 | crc16 <<= 4; /* shift the CRC Register left 4 bits */ | ||
327 | crc16 ^= crc16_lookup[t]; /* do the table lookup and XOR the result */ | ||
328 | |||
329 | /* lower nibble of our data */ | ||
330 | t = crc16 >> 12; /* extract the 4 most significant bits */ | ||
331 | t ^= byte & 0x0F; /* XOR in 4 bits of the data into the extracted bits */ | ||
332 | crc16 <<= 4; /* shift the CRC Register left 4 bits */ | ||
333 | crc16 ^= crc16_lookup[t]; /* do the table lookup and XOR the result */ | ||
334 | } | ||
335 | |||
336 | return crc16; | ||
337 | } | ||
338 | |||
339 | 305 | ||
340 | #if CONFIG_CPU == TCC730 | 306 | #if CONFIG_CPU == TCC730 |
341 | static unsigned flash_word_temp __attribute__ ((section (".idata"))); | 307 | static unsigned flash_word_temp __attribute__ ((section (".idata"))); |
@@ -444,7 +410,7 @@ bool dbg_hw_info(void) | |||
444 | int rom_version = *(unsigned short*)0x20000fe; | 410 | int rom_version = *(unsigned short*)0x20000fe; |
445 | unsigned manu, id; /* flash IDs */ | 411 | unsigned manu, id; /* flash IDs */ |
446 | bool got_id; /* flag if we managed to get the flash IDs */ | 412 | bool got_id; /* flag if we managed to get the flash IDs */ |
447 | unsigned rom_crc = 0xFFFF; /* CRC16 of the boot ROM */ | 413 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ |
448 | bool has_bootrom; /* flag for boot ROM present */ | 414 | bool has_bootrom; /* flag for boot ROM present */ |
449 | int oldmode; /* saved memory guard mode */ | 415 | int oldmode; /* saved memory guard mode */ |
450 | 416 | ||
@@ -474,7 +440,7 @@ bool dbg_hw_info(void) | |||
474 | if (has_bootrom) /* if ROM and Flash different */ | 440 | if (has_bootrom) /* if ROM and Flash different */ |
475 | { | 441 | { |
476 | /* calculate CRC16 checksum of boot ROM */ | 442 | /* calculate CRC16 checksum of boot ROM */ |
477 | rom_crc = crc_16((unsigned char*)0x0000, 64*1024); | 443 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); |
478 | } | 444 | } |
479 | 445 | ||
480 | system_memory_guard(oldmode); /* re-enable memory guard */ | 446 | system_memory_guard(oldmode); /* re-enable memory guard */ |
@@ -505,9 +471,10 @@ bool dbg_hw_info(void) | |||
505 | 471 | ||
506 | if (has_bootrom) | 472 | if (has_bootrom) |
507 | { | 473 | { |
508 | snprintf(buf, 32-3, "ROM CRC: 0x%04x", rom_crc); | 474 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ |
509 | if (rom_crc == 0x222F) /* known Version 1 */ | 475 | snprintf(buf, 32, "Boot ROM: V1"); |
510 | strcat(buf, " V1"); | 476 | else |
477 | snprintf(buf, 32, "ROMcrc: 0x%08x", rom_crc); | ||
511 | } | 478 | } |
512 | else | 479 | else |
513 | { | 480 | { |
@@ -578,7 +545,7 @@ bool dbg_hw_info(void) | |||
578 | int rom_version = *(unsigned short*)0x20000fe; | 545 | int rom_version = *(unsigned short*)0x20000fe; |
579 | unsigned manu, id; /* flash IDs */ | 546 | unsigned manu, id; /* flash IDs */ |
580 | bool got_id; /* flag if we managed to get the flash IDs */ | 547 | bool got_id; /* flag if we managed to get the flash IDs */ |
581 | unsigned rom_crc = 0xFFFF; /* CRC16 of the boot ROM */ | 548 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ |
582 | bool has_bootrom; /* flag for boot ROM present */ | 549 | bool has_bootrom; /* flag for boot ROM present */ |
583 | int oldmode; /* saved memory guard mode */ | 550 | int oldmode; /* saved memory guard mode */ |
584 | 551 | ||
@@ -599,7 +566,7 @@ bool dbg_hw_info(void) | |||
599 | if (has_bootrom) /* if ROM and Flash different */ | 566 | if (has_bootrom) /* if ROM and Flash different */ |
600 | { | 567 | { |
601 | /* calculate CRC16 checksum of boot ROM */ | 568 | /* calculate CRC16 checksum of boot ROM */ |
602 | rom_crc = crc_16((unsigned char*)0x0000, 64*1024); | 569 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); |
603 | } | 570 | } |
604 | 571 | ||
605 | system_memory_guard(oldmode); /* re-enable memory guard */ | 572 | system_memory_guard(oldmode); /* re-enable memory guard */ |
@@ -634,7 +601,15 @@ bool dbg_hw_info(void) | |||
634 | break; | 601 | break; |
635 | case 5: | 602 | case 5: |
636 | if (has_bootrom) | 603 | if (has_bootrom) |
637 | snprintf(buf, 32, "RomCRC:%04x", rom_crc); | 604 | { |
605 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
606 | snprintf(buf, 32, "BootROM: V1"); | ||
607 | else if (rom_crc == 0x358099E8) | ||
608 | snprintf(buf, 32, "BootROM: V2"); | ||
609 | /* alternative boot ROM found in one single player so far */ | ||
610 | else | ||
611 | snprintf(buf, 32, "R: %08x", rom_crc); | ||
612 | } | ||
638 | else | 613 | else |
639 | snprintf(buf, 32, "BootROM: no"); | 614 | snprintf(buf, 32, "BootROM: no"); |
640 | } | 615 | } |