diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2011-06-05 10:26:06 +0000 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2011-06-05 10:26:06 +0000 |
commit | dceceef05264cdeff0e2c60b8cb00719d7d7baeb (patch) | |
tree | eb8573dbe429755165372a91a620435e8b14e4bd | |
parent | dace72166e5250e2ea0a9beb6451f5e4da9e50e2 (diff) | |
download | rockbox-dceceef05264cdeff0e2c60b8cb00719d7d7baeb.tar.gz rockbox-dceceef05264cdeff0e2c60b8cb00719d7d7baeb.zip |
Move dbg_hw_info() into target tree. FS#11735 by me
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29964 a1c6a512-1295-4272-9138-f99709370657
26 files changed, 536 insertions, 387 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index a43dd0a768..b557f46dc3 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -416,361 +416,6 @@ static bool dbg_buffering_thread(void) | |||
416 | #endif /* CONFIG_CODEC */ | 416 | #endif /* CONFIG_CODEC */ |
417 | #endif /* HAVE_LCD_BITMAP */ | 417 | #endif /* HAVE_LCD_BITMAP */ |
418 | 418 | ||
419 | |||
420 | #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)) | ||
421 | /* Tool function to read the flash manufacturer and type, if available. | ||
422 | Only chips which could be reprogrammed in system will return values. | ||
423 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | ||
424 | /* In IRAM to avoid problems when running directly from Flash */ | ||
425 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
426 | unsigned addr1, unsigned addr2) | ||
427 | ICODE_ATTR __attribute__((noinline)); | ||
428 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
429 | unsigned addr1, unsigned addr2) | ||
430 | |||
431 | { | ||
432 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | ||
433 | unsigned manu, id; /* read values when in ID mode */ | ||
434 | |||
435 | #if CONFIG_CPU == SH7034 | ||
436 | volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */ | ||
437 | #elif defined(CPU_COLDFIRE) | ||
438 | volatile unsigned short* flash = (unsigned short*)0; /* flash mapping */ | ||
439 | #endif | ||
440 | int old_level; /* saved interrupt level */ | ||
441 | |||
442 | not_manu = flash[0]; /* read the normal content */ | ||
443 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | ||
444 | |||
445 | /* disable interrupts, prevent any stray flash access */ | ||
446 | old_level = disable_irq_save(); | ||
447 | |||
448 | flash[addr1] = 0xAA; /* enter command mode */ | ||
449 | flash[addr2] = 0x55; | ||
450 | flash[addr1] = 0x90; /* ID command */ | ||
451 | /* Atmel wants 20ms pause here */ | ||
452 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
453 | |||
454 | manu = flash[0]; /* read the IDs */ | ||
455 | id = flash[1]; | ||
456 | |||
457 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | ||
458 | /* Atmel wants 20ms pause here */ | ||
459 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
460 | |||
461 | restore_irq(old_level); /* enable interrupts again */ | ||
462 | |||
463 | /* I assume success if the obtained values are different from | ||
464 | the normal flash content. This is not perfectly bulletproof, they | ||
465 | could theoretically be the same by chance, causing us to fail. */ | ||
466 | if (not_manu != manu || not_id != id) /* a value has changed */ | ||
467 | { | ||
468 | *p_manufacturer = manu; /* return the results */ | ||
469 | *p_device = id; | ||
470 | return true; /* success */ | ||
471 | } | ||
472 | return false; /* fail */ | ||
473 | } | ||
474 | #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */ | ||
475 | |||
476 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | ||
477 | #ifdef CPU_PP | ||
478 | static int perfcheck(void) | ||
479 | { | ||
480 | int result; | ||
481 | |||
482 | asm ( | ||
483 | "mrs r2, CPSR \n" | ||
484 | "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */ | ||
485 | "msr CPSR_c, r0 \n" | ||
486 | "mov %[res], #0 \n" | ||
487 | "ldr r0, [%[timr]] \n" | ||
488 | "add r0, r0, %[tmo] \n" | ||
489 | "1: \n" | ||
490 | "add %[res], %[res], #1 \n" | ||
491 | "ldr r1, [%[timr]] \n" | ||
492 | "cmp r1, r0 \n" | ||
493 | "bmi 1b \n" | ||
494 | "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */ | ||
495 | : | ||
496 | [res]"=&r"(result) | ||
497 | : | ||
498 | [timr]"r"(&USEC_TIMER), | ||
499 | [tmo]"r"( | ||
500 | #if CONFIG_CPU == PP5002 | ||
501 | 16000 | ||
502 | #else /* PP5020/5022/5024 */ | ||
503 | 10226 | ||
504 | #endif | ||
505 | ) | ||
506 | : | ||
507 | "r0", "r1", "r2" | ||
508 | ); | ||
509 | return result; | ||
510 | } | ||
511 | #endif | ||
512 | |||
513 | #ifdef HAVE_LCD_BITMAP | ||
514 | static bool dbg_hw_info(void) | ||
515 | { | ||
516 | #if CONFIG_CPU == SH7034 | ||
517 | int bitmask = HW_MASK; | ||
518 | int rom_version = ROM_VERSION; | ||
519 | unsigned manu, id; /* flash IDs */ | ||
520 | bool got_id; /* flag if we managed to get the flash IDs */ | ||
521 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ | ||
522 | bool has_bootrom; /* flag for boot ROM present */ | ||
523 | int oldmode; /* saved memory guard mode */ | ||
524 | |||
525 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
526 | |||
527 | /* get flash ROM type */ | ||
528 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
529 | if (!got_id) | ||
530 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
531 | |||
532 | /* check if the boot ROM area is a flash mirror */ | ||
533 | has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0); | ||
534 | if (has_bootrom) /* if ROM and Flash different */ | ||
535 | { | ||
536 | /* calculate CRC16 checksum of boot ROM */ | ||
537 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); | ||
538 | } | ||
539 | |||
540 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
541 | |||
542 | lcd_setfont(FONT_SYSFIXED); | ||
543 | lcd_clear_display(); | ||
544 | |||
545 | lcd_puts(0, 0, "[Hardware info]"); | ||
546 | |||
547 | lcd_putsf(0, 1, "ROM: %d.%02d", rom_version/100, rom_version%100); | ||
548 | |||
549 | lcd_putsf(0, 2, "Mask: 0x%04x", bitmask); | ||
550 | |||
551 | if (got_id) | ||
552 | lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu, id); | ||
553 | else | ||
554 | lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */ | ||
555 | |||
556 | if (has_bootrom) | ||
557 | { | ||
558 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
559 | lcd_puts(0, 4, "Boot ROM: V1"); | ||
560 | else | ||
561 | lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc); | ||
562 | } | ||
563 | else | ||
564 | { | ||
565 | lcd_puts(0, 4, "Boot ROM: none"); | ||
566 | } | ||
567 | |||
568 | lcd_update(); | ||
569 | |||
570 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
571 | |||
572 | #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250 | ||
573 | unsigned manu, id; /* flash IDs */ | ||
574 | int got_id; /* flag if we managed to get the flash IDs */ | ||
575 | int oldmode; /* saved memory guard mode */ | ||
576 | int line = 0; | ||
577 | |||
578 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
579 | |||
580 | /* get flash ROM type */ | ||
581 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
582 | if (!got_id) | ||
583 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
584 | |||
585 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
586 | |||
587 | lcd_setfont(FONT_SYSFIXED); | ||
588 | lcd_clear_display(); | ||
589 | |||
590 | lcd_puts(0, line++, "[Hardware info]"); | ||
591 | |||
592 | if (got_id) | ||
593 | lcd_putsf(0, line++, "Flash: M=%04x D=%04x", manu, id); | ||
594 | else | ||
595 | lcd_puts(0, line++, "Flash: M=???? D=????"); /* unknown, sorry */ | ||
596 | |||
597 | #ifdef IAUDIO_X5 | ||
598 | { | ||
599 | struct ds2411_id id; | ||
600 | |||
601 | lcd_puts(0, ++line, "Serial Number:"); | ||
602 | |||
603 | got_id = ds2411_read_id(&id); | ||
604 | |||
605 | if (got_id == DS2411_OK) | ||
606 | { | ||
607 | lcd_putsf(0, ++line, " FC=%02x", (unsigned)id.family_code); | ||
608 | lcd_putsf(0, ++line, " ID=%02X %02X %02X %02X %02X %02X", | ||
609 | (unsigned)id.uid[0], (unsigned)id.uid[1], (unsigned)id.uid[2], | ||
610 | (unsigned)id.uid[3], (unsigned)id.uid[4], (unsigned)id.uid[5]); | ||
611 | lcd_putsf(0, ++line, " CRC=%02X", (unsigned)id.crc); | ||
612 | } | ||
613 | else | ||
614 | { | ||
615 | lcd_putsf(0, ++line, "READ ERR=%d", got_id); | ||
616 | } | ||
617 | } | ||
618 | #endif | ||
619 | |||
620 | lcd_update(); | ||
621 | |||
622 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
623 | |||
624 | #elif defined(CPU_PP502x) | ||
625 | int line = 0; | ||
626 | char pp_version[] = { (PP_VER2 >> 24) & 0xff, (PP_VER2 >> 16) & 0xff, | ||
627 | (PP_VER2 >> 8) & 0xff, (PP_VER2) & 0xff, | ||
628 | (PP_VER1 >> 24) & 0xff, (PP_VER1 >> 16) & 0xff, | ||
629 | (PP_VER1 >> 8) & 0xff, (PP_VER1) & 0xff, '\0' }; | ||
630 | |||
631 | lcd_setfont(FONT_SYSFIXED); | ||
632 | lcd_clear_display(); | ||
633 | |||
634 | lcd_puts(0, line++, "[Hardware info]"); | ||
635 | |||
636 | #ifdef IPOD_ARCH | ||
637 | lcd_putsf(0, line++, "HW rev: 0x%08lx", IPOD_HW_REVISION); | ||
638 | #endif | ||
639 | |||
640 | #ifdef IPOD_COLOR | ||
641 | extern int lcd_type; /* Defined in lcd-colornano.c */ | ||
642 | |||
643 | lcd_putsf(0, line++, "LCD type: %d", lcd_type); | ||
644 | #endif | ||
645 | |||
646 | lcd_putsf(0, line++, "PP version: %s", pp_version); | ||
647 | |||
648 | lcd_putsf(0, line++, "Est. clock (kHz): %d", perfcheck()); | ||
649 | |||
650 | lcd_update(); | ||
651 | |||
652 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
653 | |||
654 | #elif CONFIG_CPU == PP5002 | ||
655 | int line = 0; | ||
656 | char pp_version[] = { (PP_VER4 >> 8) & 0xff, PP_VER4 & 0xff, | ||
657 | (PP_VER3 >> 8) & 0xff, PP_VER3 & 0xff, | ||
658 | (PP_VER2 >> 8) & 0xff, PP_VER2 & 0xff, | ||
659 | (PP_VER1 >> 8) & 0xff, PP_VER1 & 0xff, '\0' }; | ||
660 | |||
661 | |||
662 | lcd_setfont(FONT_SYSFIXED); | ||
663 | lcd_clear_display(); | ||
664 | |||
665 | lcd_puts(0, line++, "[Hardware info]"); | ||
666 | |||
667 | #ifdef IPOD_ARCH | ||
668 | lcd_putsf(0, line++, "HW rev: 0x%08lx", IPOD_HW_REVISION); | ||
669 | #endif | ||
670 | |||
671 | lcd_putsf(0, line++, "PP version: %s", pp_version); | ||
672 | |||
673 | lcd_putsf(0, line++, "Est. clock (kHz): %d", perfcheck()); | ||
674 | |||
675 | lcd_update(); | ||
676 | |||
677 | while (!(action_userabort(TIMEOUT_BLOCK))); | ||
678 | |||
679 | #else | ||
680 | /* Define this function in your target tree */ | ||
681 | return __dbg_hw_info(); | ||
682 | #endif /* CONFIG_CPU */ | ||
683 | lcd_setfont(FONT_UI); | ||
684 | return false; | ||
685 | } | ||
686 | #else /* !HAVE_LCD_BITMAP */ | ||
687 | static bool dbg_hw_info(void) | ||
688 | { | ||
689 | int button; | ||
690 | int currval = 0; | ||
691 | int rom_version = ROM_VERSION; | ||
692 | unsigned manu, id; /* flash IDs */ | ||
693 | bool got_id; /* flag if we managed to get the flash IDs */ | ||
694 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ | ||
695 | bool has_bootrom; /* flag for boot ROM present */ | ||
696 | int oldmode; /* saved memory guard mode */ | ||
697 | |||
698 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
699 | |||
700 | /* get flash ROM type */ | ||
701 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
702 | if (!got_id) | ||
703 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
704 | |||
705 | /* check if the boot ROM area is a flash mirror */ | ||
706 | has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0); | ||
707 | if (has_bootrom) /* if ROM and Flash different */ | ||
708 | { | ||
709 | /* calculate CRC16 checksum of boot ROM */ | ||
710 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); | ||
711 | } | ||
712 | |||
713 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
714 | |||
715 | lcd_clear_display(); | ||
716 | |||
717 | lcd_puts(0, 0, "[HW Info]"); | ||
718 | while(1) | ||
719 | { | ||
720 | switch(currval) | ||
721 | { | ||
722 | case 0: | ||
723 | lcd_putsf(0, 1, "ROM: %d.%02d", | ||
724 | rom_version/100, rom_version%100); | ||
725 | break; | ||
726 | case 1: | ||
727 | if (got_id) | ||
728 | lcd_putsf(0, 1, "Flash:%02x,%02x", manu, id); | ||
729 | else | ||
730 | lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */ | ||
731 | break; | ||
732 | case 2: | ||
733 | if (has_bootrom) | ||
734 | { | ||
735 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
736 | lcd_puts(0, 1, "BootROM: V1"); | ||
737 | else if (rom_crc == 0x358099E8) | ||
738 | lcd_puts(0, 1, "BootROM: V2"); | ||
739 | /* alternative boot ROM found in one single player so far */ | ||
740 | else | ||
741 | lcd_putsf(0, 1, "R: %08x", rom_crc); | ||
742 | } | ||
743 | else | ||
744 | lcd_puts(0, 1, "BootROM: no"); | ||
745 | } | ||
746 | |||
747 | lcd_update(); | ||
748 | |||
749 | button = get_action(CONTEXT_SETTINGS,TIMEOUT_BLOCK); | ||
750 | |||
751 | switch(button) | ||
752 | { | ||
753 | case ACTION_STD_CANCEL: | ||
754 | return false; | ||
755 | |||
756 | case ACTION_SETTINGS_DEC: | ||
757 | currval--; | ||
758 | if(currval < 0) | ||
759 | currval = 2; | ||
760 | break; | ||
761 | |||
762 | case ACTION_SETTINGS_INC: | ||
763 | currval++; | ||
764 | if(currval > 2) | ||
765 | currval = 0; | ||
766 | break; | ||
767 | } | ||
768 | } | ||
769 | return false; | ||
770 | } | ||
771 | #endif /* !HAVE_LCD_BITMAP */ | ||
772 | #endif /* PLATFORM_NATIVE */ | ||
773 | |||
774 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 419 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
775 | static const char* dbg_partitions_getname(int selected_item, void *data, | 420 | static const char* dbg_partitions_getname(int selected_item, void *data, |
776 | char *buffer, size_t buffer_len) | 421 | char *buffer, size_t buffer_len) |
diff --git a/bootloader/rk27xx.c b/bootloader/rk27xx.c index 37778db6dc..d94b080345 100644 --- a/bootloader/rk27xx.c +++ b/bootloader/rk27xx.c | |||
@@ -15,9 +15,56 @@ | |||
15 | #include "common.h" | 15 | #include "common.h" |
16 | #include "version.h" | 16 | #include "version.h" |
17 | 17 | ||
18 | // 441 Hz samples table, 44100 Hz and 441 Hz -> 100 samples | ||
19 | const int16_t samples[] = { | ||
20 | 0, 2057, 4106, 6139, 8148, 10125, 12062, 13951, 15785, 17557, | ||
21 | 19259, 20886, 22430, 23886, 25247, 26509, 27666, 28713, 29648, 30465, | ||
22 | 31163, 31737, 32186, 32508, 32702, 32767, 32702, 32508, 32186, 31737, | ||
23 | 31163, 30465, 29648, 28713, 27666, 26509, 25247, 23886, 22430, 20886, | ||
24 | 19259, 17557, 15785, 13951, 12062, 10125, 8148, 6139, 4106, 2057, | ||
25 | 0, -2057, -4106, -6139, -8148, -10125, -12062, -13951, -15785, -17557, | ||
26 | -19259, -20886, -22430, -23886, -25247, -26509, -27666, -28713, -29648, -30465, | ||
27 | -31163, -31737, -32186, -32508, -32702, -32767, -32702, -32508, -32186, -31737, | ||
28 | -31163, -30465, -29648, -28713, -27666, -26509, -25247, -23886, -22430, -20886, | ||
29 | -19259, -17557, -15785, -13951, -12062, -10125, -8148, -6139, -4106, -2057 }; | ||
30 | |||
18 | extern int show_logo( void ); | 31 | extern int show_logo( void ); |
32 | |||
33 | void INT_HDMA(void) | ||
34 | { | ||
35 | #if 0 | ||
36 | // static uint32_t i; | ||
37 | // printf("hdma int: %d", i++); | ||
38 | |||
39 | HDMA_ISRC0 = (uint32_t)&samples; | ||
40 | HDMA_IDST0 = (uint32_t)&I2S_TXR; | ||
41 | HDMA_ICNT0 = (sizeof(samples)/4) - 1; | ||
42 | HDMA_CON0 = (1<<22)| // slice mode | ||
43 | (1<<21)| // channel enable | ||
44 | (1<<18)| // interrupt mode | ||
45 | (5<<13)| // transfer mode inc8 | ||
46 | (6<<9) | // hdreq from i2s tx | ||
47 | (0<<7) | // source address increment | ||
48 | (1<<5) | // destination address fixed | ||
49 | (2<<3) | // data size word | ||
50 | (1<<0); // enable hardware triggered dma | ||
51 | |||
52 | HDMA_ISR = (1<<13) | // mask ch1 page overflow | ||
53 | (1<<11) | // mask ch1 page count down | ||
54 | (1<<9); // mask ch1 interrupts | ||
55 | #endif | ||
56 | return; | ||
57 | } | ||
58 | |||
59 | static int codec_write(uint8_t reg, uint8_t data) | ||
60 | { | ||
61 | uint8_t tmp = data; | ||
62 | return i2c_write(0x27<<1, reg<<1, 1, &tmp); | ||
63 | } | ||
64 | |||
19 | void main(void) | 65 | void main(void) |
20 | { | 66 | { |
67 | int i; | ||
21 | 68 | ||
22 | _backlight_init(); | 69 | _backlight_init(); |
23 | 70 | ||
@@ -33,13 +80,105 @@ void main(void) | |||
33 | show_logo(); | 80 | show_logo(); |
34 | sleep(HZ*2); | 81 | sleep(HZ*2); |
35 | 82 | ||
83 | printf("show logo passed"); | ||
84 | // I2S init | ||
85 | SCU_CLKCFG &= ~((1<<17) | (1<<16)); // enable i2s, i2c pclk | ||
86 | //SCU_CLKCFG |= ((1<<17) | (1<<16)); | ||
87 | I2S_OPR = (1<<17) | // reset Tx | ||
88 | (1<<16) | // reset Rx | ||
89 | (1<<6) | // disable HDMA Req1 | ||
90 | (1<<5); // disable HDMA Req2 | ||
91 | |||
92 | I2S_TXCTL = (1<<16) | // LRCK/SCLK = 64 | ||
93 | (4<<8) | // MCLK/SCK = 4 | ||
94 | (1<<4) | // 16bit samples | ||
95 | (0<<3) | // stereo mode | ||
96 | (0<<1); // I2S | ||
97 | |||
98 | I2S_RXCTL = (1<<16) | // LRCK/SCLK = 64 | ||
99 | (4<<8) | // MCLK/SCK = 4 | ||
100 | (1<<4) | // 16bit samples | ||
101 | (0<<3) | // stereo mode | ||
102 | (0<<1); // I2S | ||
103 | |||
104 | I2S_FIFOSTS = (1<<18) | // Tx int trigger half full | ||
105 | (1<<16); // Rx int trigger half full | ||
106 | |||
107 | // I2S start | ||
108 | I2S_OPR = (1<<17) | (1<<16); | ||
109 | sleep(HZ/100); | ||
110 | |||
111 | I2S_OPR = (0<<6) | // req channel 1 enable | ||
112 | (1<<5) | // req channel 2 disable | ||
113 | (0<<4) | // HDMA req channel 1 Tx | ||
114 | (0<<2) | // normal I2S operation (no loopback) | ||
115 | (1<<1); // Tx start | ||
116 | |||
117 | printf("I2S config passed"); | ||
118 | |||
119 | HDMA_ISRC0 = (uint32_t)&samples; | ||
120 | HDMA_IDST0 = (uint32_t)&I2S_TXR; | ||
121 | HDMA_ICNT0 = (sizeof(samples)/4) - 1; | ||
122 | HDMA_ISCNT0 = 7; | ||
123 | HDMA_IPNCNTD0 = 1; | ||
124 | HDMA_CON0 = (1<<22)| // slice mode | ||
125 | (1<<21)| // channel enable | ||
126 | (1<<18)| // interrupt mode | ||
127 | (5<<13)| // transfer mode inc8 | ||
128 | (6<<9) | // hdreq from i2s tx | ||
129 | (0<<7) | // source address increment | ||
130 | (1<<5) | // destination address fixed | ||
131 | (2<<3) | // data size word | ||
132 | (1<<0); // enable hardware triggered dma | ||
133 | |||
134 | HDMA_ISR = (1<<13) | // mask ch1 page overflow | ||
135 | (1<<11) | // mask ch1 page count down | ||
136 | (1<<9); // mask ch1 interrupts | ||
137 | |||
138 | INTC_IMR |= (1<<12); | ||
139 | INTC_IECR |= (1<<12); | ||
140 | |||
141 | printf("HDMA config passed"); | ||
142 | |||
143 | i2c_init(); | ||
144 | |||
145 | printf("I2C config passed"); | ||
146 | |||
147 | // codec init | ||
148 | codec_write(0x00, (1<<3)|(1<<2)|(1<<1)|(1<<0)); // AICR | ||
149 | codec_write(0x01, (1<<7)|(1<<5)|(1<<3)); // CR1 | ||
150 | codec_write(0x02, (1<<2)); // CR2 | ||
151 | codec_write(0x03, 0); // CCR1 | ||
152 | codec_write(0x04, (2<<4)|(2<<0)); // CCR2 | ||
153 | codec_write(0x07, (3<<5)|(3<<0)); // CCR | ||
154 | |||
155 | |||
156 | codec_write(0x0f, 0x1f|(2<<6)); // CGR6 | ||
157 | codec_write(0x14, (1<<1)); // TR1 | ||
158 | codec_write(0x05, (1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); // PMR1 | ||
159 | sleep(HZ/100); | ||
160 | |||
161 | codec_write(0x06, (1<<3)|(1<<2)|(1<<0)); // PMR2 | ||
162 | |||
163 | |||
164 | codec_write(0x05, (1<<6)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); // PMR1 | ||
165 | codec_write(0x05, (1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); // PMR1 | ||
166 | |||
167 | |||
168 | // DACout mode | ||
169 | codec_write(0x01, (1<<7)|(1<<3)|(1<<5)|(1<<4)); // CR1 | ||
170 | codec_write(0x05, (1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); //PMR1 | ||
171 | // codec_write(0x06, (1<<3)|(1<<2)); // PMR2 | ||
172 | |||
173 | printf("codec init passed"); | ||
174 | |||
175 | codec_write(0x01, (1<<7)|(1<<3)); // CR1 | ||
176 | |||
177 | codec_write(0x0a, 0); // 0dB digital gain | ||
178 | codec_write(0x11, 15|(2<<6)); // | ||
179 | |||
36 | while(1) | 180 | while(1) |
37 | { | 181 | { |
38 | reset_screen(); | 182 | printf("HDMA_CCNT0: 0x%0x FIFOSTS: 0x%0x", HDMA_CCNT0, I2S_FIFOSTS); |
39 | printf("GPIOA: 0x%0x", GPIO_PADR); | ||
40 | printf("GPIOB: 0x%0x", GPIO_PBDR); | ||
41 | printf("GPIOC: 0x%0x", GPIO_PCDR); | ||
42 | printf("GPIOD: 0x%0x", GPIO_PDDR); | ||
43 | sleep(HZ/10); | ||
44 | } | 183 | } |
45 | } | 184 | } |
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c index 513295edcb..d18f2d70b2 100644 --- a/firmware/target/arm/as3525/debug-as3525.c +++ b/firmware/target/arm/as3525/debug-as3525.c | |||
@@ -248,7 +248,7 @@ static int calc_freq(int clk) | |||
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | bool __dbg_hw_info(void) | 251 | bool dbg_hw_info(void) |
252 | { | 252 | { |
253 | int line; | 253 | int line; |
254 | #if CONFIG_CPU == AS3525 | 254 | #if CONFIG_CPU == AS3525 |
diff --git a/firmware/target/arm/as3525/debug-target.h b/firmware/target/arm/as3525/debug-target.h index a9e43550a8..1359e6a00e 100644 --- a/firmware/target/arm/as3525/debug-target.h +++ b/firmware/target/arm/as3525/debug-target.h | |||
@@ -24,6 +24,6 @@ | |||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | 25 | ||
26 | #define DEBUG_CANCEL BUTTON_LEFT | 26 | #define DEBUG_CANCEL BUTTON_LEFT |
27 | bool __dbg_hw_info(void); | 27 | bool dbg_hw_info(void); |
28 | bool dbg_ports(void); | 28 | bool dbg_ports(void); |
29 | #endif | 29 | #endif |
diff --git a/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c index 54a262a9ff..5277afc348 100644 --- a/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c +++ b/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c | |||
@@ -23,12 +23,12 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include "debug-target.h" | 24 | #include "debug-target.h" |
25 | 25 | ||
26 | bool __dbg_ports(void) | 26 | bool dbg_ports(void) |
27 | { | 27 | { |
28 | return false; | 28 | return false; |
29 | } | 29 | } |
30 | 30 | ||
31 | bool __dbg_hw_info(void) | 31 | bool dbg_hw_info(void) |
32 | { | 32 | { |
33 | return false; | 33 | return false; |
34 | } | 34 | } |
diff --git a/firmware/target/arm/at91sam/lyre_proto1/debug-target.h b/firmware/target/arm/at91sam/lyre_proto1/debug-target.h index 140feafe67..59dd58cb32 100644 --- a/firmware/target/arm/at91sam/lyre_proto1/debug-target.h +++ b/firmware/target/arm/at91sam/lyre_proto1/debug-target.h | |||
@@ -21,6 +21,6 @@ | |||
21 | 21 | ||
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | 23 | ||
24 | bool __dbg_ports(void); | 24 | bool dbg_ports(void); |
25 | bool __dbg_hw_info(void); | 25 | bool dbg_hw_info(void); |
26 | 26 | ||
diff --git a/firmware/target/arm/debug-pp.c b/firmware/target/arm/debug-pp.c index 3b9250c0fb..080e0ed631 100644 --- a/firmware/target/arm/debug-pp.c +++ b/firmware/target/arm/debug-pp.c | |||
@@ -28,8 +28,43 @@ | |||
28 | #include "powermgmt.h" | 28 | #include "powermgmt.h" |
29 | #include "adc.h" | 29 | #include "adc.h" |
30 | #include "iap.h" | 30 | #include "iap.h" |
31 | #include "hwcompat.h" | ||
31 | #include "debug-target.h" | 32 | #include "debug-target.h" |
32 | 33 | ||
34 | static int perfcheck(void) | ||
35 | { | ||
36 | int result; | ||
37 | |||
38 | asm ( | ||
39 | "mrs r2, CPSR \n" | ||
40 | "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */ | ||
41 | "msr CPSR_c, r0 \n" | ||
42 | "mov %[res], #0 \n" | ||
43 | "ldr r0, [%[timr]] \n" | ||
44 | "add r0, r0, %[tmo] \n" | ||
45 | "1: \n" | ||
46 | "add %[res], %[res], #1 \n" | ||
47 | "ldr r1, [%[timr]] \n" | ||
48 | "cmp r1, r0 \n" | ||
49 | "bmi 1b \n" | ||
50 | "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */ | ||
51 | : | ||
52 | [res]"=&r"(result) | ||
53 | : | ||
54 | [timr]"r"(&USEC_TIMER), | ||
55 | [tmo]"r"( | ||
56 | #if CONFIG_CPU == PP5002 | ||
57 | 16000 | ||
58 | #else /* PP5020/5022/5024 */ | ||
59 | 10226 | ||
60 | #endif | ||
61 | ) | ||
62 | : | ||
63 | "r0", "r1", "r2" | ||
64 | ); | ||
65 | return result; | ||
66 | } | ||
67 | |||
33 | bool dbg_ports(void) | 68 | bool dbg_ports(void) |
34 | { | 69 | { |
35 | int line; | 70 | int line; |
@@ -152,3 +187,46 @@ bool dbg_ports(void) | |||
152 | } | 187 | } |
153 | return false; | 188 | return false; |
154 | } | 189 | } |
190 | |||
191 | bool dbg_hw_info(void) | ||
192 | { | ||
193 | int line = 0; | ||
194 | #if defined(CPU_PP502x) | ||
195 | char pp_version[] = { (PP_VER2 >> 24) & 0xff, (PP_VER2 >> 16) & 0xff, | ||
196 | (PP_VER2 >> 8) & 0xff, (PP_VER2) & 0xff, | ||
197 | (PP_VER1 >> 24) & 0xff, (PP_VER1 >> 16) & 0xff, | ||
198 | (PP_VER1 >> 8) & 0xff, (PP_VER1) & 0xff, '\0' }; | ||
199 | #elif CONFIG_CPU == PP5002 | ||
200 | char pp_version[] = { (PP_VER4 >> 8) & 0xff, PP_VER4 & 0xff, | ||
201 | (PP_VER3 >> 8) & 0xff, PP_VER3 & 0xff, | ||
202 | (PP_VER2 >> 8) & 0xff, PP_VER2 & 0xff, | ||
203 | (PP_VER1 >> 8) & 0xff, PP_VER1 & 0xff, '\0' }; | ||
204 | #endif | ||
205 | |||
206 | lcd_setfont(FONT_SYSFIXED); | ||
207 | lcd_clear_display(); | ||
208 | |||
209 | lcd_puts(0, line++, "[Hardware info]"); | ||
210 | |||
211 | #ifdef IPOD_ARCH | ||
212 | lcd_putsf(0, line++, "HW rev: 0x%08lx", IPOD_HW_REVISION); | ||
213 | #endif | ||
214 | |||
215 | #ifdef IPOD_COLOR | ||
216 | extern int lcd_type; /* Defined in lcd-colornano.c */ | ||
217 | |||
218 | lcd_putsf(0, line++, "LCD type: %d", lcd_type); | ||
219 | #endif | ||
220 | |||
221 | lcd_putsf(0, line++, "PP version: %s", pp_version); | ||
222 | |||
223 | lcd_putsf(0, line++, "Est. clock (kHz): %d", perfcheck()); | ||
224 | |||
225 | lcd_update(); | ||
226 | |||
227 | /* wait for exit */ | ||
228 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); | ||
229 | |||
230 | lcd_setfont(FONT_UI); | ||
231 | return false; | ||
232 | } | ||
diff --git a/firmware/target/arm/debug-target.h b/firmware/target/arm/debug-target.h index 4408acf5da..28f95327ad 100644 --- a/firmware/target/arm/debug-target.h +++ b/firmware/target/arm/debug-target.h | |||
@@ -47,3 +47,4 @@ | |||
47 | # define DEBUG_CANCEL BUTTON_CANCEL | 47 | # define DEBUG_CANCEL BUTTON_CANCEL |
48 | #endif | 48 | #endif |
49 | bool dbg_ports(void); | 49 | bool dbg_ports(void); |
50 | bool dbg_hw_info(void); | ||
diff --git a/firmware/target/arm/imx31/debug-imx31.c b/firmware/target/arm/imx31/debug-imx31.c index f8dacbedd5..92884fe8aa 100644 --- a/firmware/target/arm/imx31/debug-imx31.c +++ b/firmware/target/arm/imx31/debug-imx31.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "dvfs_dptc-imx31.h" | 31 | #include "dvfs_dptc-imx31.h" |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | 33 | ||
34 | bool __dbg_hw_info(void) | 34 | bool dbg_hw_info(void) |
35 | { | 35 | { |
36 | int line; | 36 | int line; |
37 | unsigned int pllref; | 37 | unsigned int pllref; |
diff --git a/firmware/target/arm/imx31/debug-target.h b/firmware/target/arm/imx31/debug-target.h index ca02ab84de..25fd5d872b 100644 --- a/firmware/target/arm/imx31/debug-target.h +++ b/firmware/target/arm/imx31/debug-target.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #define DEBUG_TARGET_H | 22 | #define DEBUG_TARGET_H |
23 | 23 | ||
24 | #define DEBUG_CANCEL BUTTON_BACK | 24 | #define DEBUG_CANCEL BUTTON_BACK |
25 | bool __dbg_hw_info(void); | 25 | bool dbg_hw_info(void); |
26 | bool dbg_ports(void); | 26 | bool dbg_ports(void); |
27 | bool __dbg_dvfs_dptc(void); | 27 | bool __dbg_dvfs_dptc(void); |
28 | 28 | ||
diff --git a/firmware/target/arm/s3c2440/debug-s3c2440.c b/firmware/target/arm/s3c2440/debug-s3c2440.c index e552f12c2b..99ab8e4306 100644 --- a/firmware/target/arm/s3c2440/debug-s3c2440.c +++ b/firmware/target/arm/s3c2440/debug-s3c2440.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "font.h" | 29 | #include "font.h" |
30 | #include "debug-target.h" | 30 | #include "debug-target.h" |
31 | 31 | ||
32 | bool __dbg_hw_info(void) | 32 | bool dbg_hw_info(void) |
33 | { | 33 | { |
34 | return false; | 34 | return false; |
35 | } | 35 | } |
diff --git a/firmware/target/arm/s3c2440/debug-target.h b/firmware/target/arm/s3c2440/debug-target.h index dc274b9f06..9e83da6f48 100644 --- a/firmware/target/arm/s3c2440/debug-target.h +++ b/firmware/target/arm/s3c2440/debug-target.h | |||
@@ -25,6 +25,6 @@ | |||
25 | #define DEBUG_CANCEL BUTTON_MENU | 25 | #define DEBUG_CANCEL BUTTON_MENU |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | bool __dbg_hw_info(void); | 28 | bool dbg_hw_info(void); |
29 | bool dbg_ports(void); | 29 | bool dbg_ports(void); |
30 | 30 | ||
diff --git a/firmware/target/arm/s5l8700/debug-s5l8700.c b/firmware/target/arm/s5l8700/debug-s5l8700.c index 28bb9b2050..3631a474ed 100644 --- a/firmware/target/arm/s5l8700/debug-s5l8700.c +++ b/firmware/target/arm/s5l8700/debug-s5l8700.c | |||
@@ -41,7 +41,7 @@ | |||
41 | extern int lcd_type; | 41 | extern int lcd_type; |
42 | extern uint32_t nand_type[4]; | 42 | extern uint32_t nand_type[4]; |
43 | 43 | ||
44 | bool __dbg_hw_info(void) | 44 | bool dbg_hw_info(void) |
45 | { | 45 | { |
46 | int line; | 46 | int line; |
47 | int i; | 47 | int i; |
@@ -127,7 +127,7 @@ bool __dbg_hw_info(void) | |||
127 | } | 127 | } |
128 | 128 | ||
129 | #else | 129 | #else |
130 | _DEBUG_PRINTF("__dbg_hw_info"); | 130 | _DEBUG_PRINTF("dbg_hw_info"); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | lcd_update(); | 133 | lcd_update(); |
diff --git a/firmware/target/arm/s5l8700/debug-target.h b/firmware/target/arm/s5l8700/debug-target.h index 351468fb50..95f2f94795 100644 --- a/firmware/target/arm/s5l8700/debug-target.h +++ b/firmware/target/arm/s5l8700/debug-target.h | |||
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | #define DEBUG_CANCEL BUTTON_MENU | 27 | #define DEBUG_CANCEL BUTTON_MENU |
28 | 28 | ||
29 | bool __dbg_hw_info(void); | 29 | bool dbg_hw_info(void); |
30 | bool dbg_ports(void); | 30 | bool dbg_ports(void); |
31 | 31 | ||
32 | #endif /* _DEBUG_TARGET_H_ */ | 32 | #endif /* _DEBUG_TARGET_H_ */ |
diff --git a/firmware/target/arm/tcc77x/debug-target.h b/firmware/target/arm/tcc77x/debug-target.h index 6cf93cc5a4..c985751a23 100644 --- a/firmware/target/arm/tcc77x/debug-target.h +++ b/firmware/target/arm/tcc77x/debug-target.h | |||
@@ -19,6 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | bool __dbg_hw_info(void); | 22 | bool dbg_hw_info(void); |
23 | bool dbg_ports(void); | 23 | bool dbg_ports(void); |
24 | 24 | ||
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c index 88b0722a4e..250afb46c7 100644 --- a/firmware/target/arm/tcc77x/debug-tcc77x.c +++ b/firmware/target/arm/tcc77x/debug-tcc77x.c | |||
@@ -36,7 +36,7 @@ bool dbg_ports(void) | |||
36 | return false; | 36 | return false; |
37 | } | 37 | } |
38 | 38 | ||
39 | bool __dbg_hw_info(void) | 39 | bool dbg_hw_info(void) |
40 | { | 40 | { |
41 | int line = 0, i, button, oldline; | 41 | int line = 0, i, button, oldline; |
42 | bool done=false; | 42 | bool done=false; |
diff --git a/firmware/target/arm/tcc780x/debug-target.h b/firmware/target/arm/tcc780x/debug-target.h index 6cf93cc5a4..c985751a23 100644 --- a/firmware/target/arm/tcc780x/debug-target.h +++ b/firmware/target/arm/tcc780x/debug-target.h | |||
@@ -19,6 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | bool __dbg_hw_info(void); | 22 | bool dbg_hw_info(void); |
23 | bool dbg_ports(void); | 23 | bool dbg_ports(void); |
24 | 24 | ||
diff --git a/firmware/target/arm/tcc780x/debug-tcc780x.c b/firmware/target/arm/tcc780x/debug-tcc780x.c index d527e2b045..22de868639 100644 --- a/firmware/target/arm/tcc780x/debug-tcc780x.c +++ b/firmware/target/arm/tcc780x/debug-tcc780x.c | |||
@@ -40,7 +40,7 @@ bool dbg_ports(void) | |||
40 | return false; | 40 | return false; |
41 | } | 41 | } |
42 | 42 | ||
43 | bool __dbg_hw_info(void) | 43 | bool dbg_hw_info(void) |
44 | { | 44 | { |
45 | int line = 0, i, oldline; | 45 | int line = 0, i, oldline; |
46 | 46 | ||
diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c index 26f34a4f5f..de17d54843 100644 --- a/firmware/target/arm/tms320dm320/debug-dm320.c +++ b/firmware/target/arm/tms320dm320/debug-dm320.c | |||
@@ -121,7 +121,7 @@ bool dbg_ports(void) | |||
121 | return false; | 121 | return false; |
122 | } | 122 | } |
123 | 123 | ||
124 | bool __dbg_hw_info(void) | 124 | bool dbg_hw_info(void) |
125 | { | 125 | { |
126 | int line = 0, oldline; | 126 | int line = 0, oldline; |
127 | int button; | 127 | int button; |
diff --git a/firmware/target/arm/tms320dm320/debug-target.h b/firmware/target/arm/tms320dm320/debug-target.h index bcf9d688cd..5fc0c98ce0 100644 --- a/firmware/target/arm/tms320dm320/debug-target.h +++ b/firmware/target/arm/tms320dm320/debug-target.h | |||
@@ -19,5 +19,5 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | bool __dbg_hw_info(void); | 22 | bool dbg_hw_info(void); |
23 | bool dbg_ports(void); | 23 | bool dbg_ports(void); |
diff --git a/firmware/target/coldfire/debug-coldfire.c b/firmware/target/coldfire/debug-coldfire.c index 14221d6f02..b021cd19c0 100644 --- a/firmware/target/coldfire/debug-coldfire.c +++ b/firmware/target/coldfire/debug-coldfire.c | |||
@@ -29,6 +29,58 @@ | |||
29 | #include "adc.h" | 29 | #include "adc.h" |
30 | #include "debug-target.h" | 30 | #include "debug-target.h" |
31 | #include "lcd-remote.h" | 31 | #include "lcd-remote.h" |
32 | #ifdef IAUDIO_X5 | ||
33 | #include "ds2411.h" | ||
34 | #endif | ||
35 | |||
36 | /* Tool function to read the flash manufacturer and type, if available. | ||
37 | Only chips which could be reprogrammed in system will return values. | ||
38 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | ||
39 | /* In IRAM to avoid problems when running directly from Flash */ | ||
40 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
41 | unsigned addr1, unsigned addr2) | ||
42 | ICODE_ATTR __attribute__((noinline)); | ||
43 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
44 | unsigned addr1, unsigned addr2) | ||
45 | |||
46 | { | ||
47 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | ||
48 | unsigned manu, id; /* read values when in ID mode */ | ||
49 | |||
50 | volatile unsigned short* flash = (unsigned short*)0; /* flash mapping */ | ||
51 | int old_level; /* saved interrupt level */ | ||
52 | |||
53 | not_manu = flash[0]; /* read the normal content */ | ||
54 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | ||
55 | |||
56 | /* disable interrupts, prevent any stray flash access */ | ||
57 | old_level = disable_irq_save(); | ||
58 | |||
59 | flash[addr1] = 0xAA; /* enter command mode */ | ||
60 | flash[addr2] = 0x55; | ||
61 | flash[addr1] = 0x90; /* ID command */ | ||
62 | /* Atmel wants 20ms pause here */ | ||
63 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
64 | manu = flash[0]; /* read the IDs */ | ||
65 | id = flash[1]; | ||
66 | |||
67 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | ||
68 | /* Atmel wants 20ms pause here */ | ||
69 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
70 | |||
71 | restore_irq(old_level); /* enable interrupts again */ | ||
72 | |||
73 | /* I assume success if the obtained values are different from | ||
74 | the normal flash content. This is not perfectly bulletproof, they | ||
75 | could theoretically be the same by chance, causing us to fail. */ | ||
76 | if (not_manu != manu || not_id != id) /* a value has changed */ | ||
77 | { | ||
78 | *p_manufacturer = manu; /* return the results */ | ||
79 | *p_device = id; | ||
80 | return true; /* success */ | ||
81 | } | ||
82 | return false; /* fail */ | ||
83 | } | ||
32 | 84 | ||
33 | bool dbg_ports(void) | 85 | bool dbg_ports(void) |
34 | { | 86 | { |
@@ -105,3 +157,59 @@ bool dbg_ports(void) | |||
105 | } | 157 | } |
106 | return false; | 158 | return false; |
107 | } | 159 | } |
160 | |||
161 | bool dbg_hw_info(void) | ||
162 | { | ||
163 | unsigned manu, id; /* flash IDs */ | ||
164 | int got_id; /* flag if we managed to get the flash IDs */ | ||
165 | int oldmode; /* saved memory guard mode */ | ||
166 | int line = 0; | ||
167 | |||
168 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
169 | |||
170 | /* get flash ROM type */ | ||
171 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
172 | if (!got_id) | ||
173 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
174 | |||
175 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
176 | |||
177 | lcd_setfont(FONT_SYSFIXED); | ||
178 | lcd_clear_display(); | ||
179 | |||
180 | lcd_puts(0, line++, "[Hardware info]"); | ||
181 | |||
182 | if (got_id) | ||
183 | lcd_putsf(0, line++, "Flash: M=%04x D=%04x", manu, id); | ||
184 | else | ||
185 | lcd_puts(0, line++, "Flash: M=???? D=????"); /* unknown, sorry */ | ||
186 | |||
187 | #ifdef IAUDIO_X5 | ||
188 | { | ||
189 | struct ds2411_id id; | ||
190 | |||
191 | lcd_puts(0, ++line, "Serial Number:"); | ||
192 | |||
193 | got_id = ds2411_read_id(&id); | ||
194 | |||
195 | if (got_id == DS2411_OK) | ||
196 | { | ||
197 | lcd_putsf(0, ++line, " FC=%02x", (unsigned)id.family_code); | ||
198 | lcd_putsf(0, ++line, " ID=%02X %02X %02X %02X %02X %02X", | ||
199 | (unsigned)id.uid[0], (unsigned)id.uid[1], (unsigned)id.uid[2], | ||
200 | (unsigned)id.uid[3], (unsigned)id.uid[4], (unsigned)id.uid[5]); | ||
201 | lcd_putsf(0, ++line, " CRC=%02X", (unsigned)id.crc); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | lcd_putsf(0, ++line, "READ ERR=%d", got_id); | ||
206 | } | ||
207 | } | ||
208 | #endif | ||
209 | |||
210 | /* wait for exit */ | ||
211 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); | ||
212 | |||
213 | lcd_setfont(FONT_UI); | ||
214 | return false; | ||
215 | } | ||
diff --git a/firmware/target/coldfire/debug-target.h b/firmware/target/coldfire/debug-target.h index 8d01cdd6f1..71ff75360c 100644 --- a/firmware/target/coldfire/debug-target.h +++ b/firmware/target/coldfire/debug-target.h | |||
@@ -33,3 +33,4 @@ | |||
33 | # define DEBUG_CANCEL BUTTON_REC | 33 | # define DEBUG_CANCEL BUTTON_REC |
34 | #endif | 34 | #endif |
35 | bool dbg_ports(void); | 35 | bool dbg_ports(void); |
36 | bool dbg_hw_info(void); | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c index 5bdd4c4de9..d7170567f9 100644 --- a/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c | |||
@@ -134,7 +134,7 @@ bool dbg_ports(void) | |||
134 | return false; | 134 | return false; |
135 | } | 135 | } |
136 | 136 | ||
137 | bool __dbg_hw_info(void) | 137 | bool dbg_hw_info(void) |
138 | { | 138 | { |
139 | int btn = 0; | 139 | int btn = 0; |
140 | #ifdef HAVE_TOUCHSCREEN | 140 | #ifdef HAVE_TOUCHSCREEN |
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-target.h b/firmware/target/mips/ingenic_jz47xx/debug-target.h index f82b43da5b..f51c5bf8da 100644 --- a/firmware/target/mips/ingenic_jz47xx/debug-target.h +++ b/firmware/target/mips/ingenic_jz47xx/debug-target.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #ifndef __DEBUG_TARGET_H_ | 22 | #ifndef __DEBUG_TARGET_H_ |
23 | #define __DEBUG_TARGET_H_ | 23 | #define __DEBUG_TARGET_H_ |
24 | 24 | ||
25 | bool __dbg_hw_info(void); | 25 | bool dbg_hw_info(void); |
26 | bool dbg_ports(void); | 26 | bool dbg_ports(void); |
27 | 27 | ||
28 | #endif /* __DEBUG_TARGET_H_ */ | 28 | #endif /* __DEBUG_TARGET_H_ */ |
diff --git a/firmware/target/sh/debug-sh.c b/firmware/target/sh/debug-sh.c index 3502cfade0..78d0032199 100644 --- a/firmware/target/sh/debug-sh.c +++ b/firmware/target/sh/debug-sh.c | |||
@@ -22,13 +22,65 @@ | |||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "system.h" | 23 | #include "system.h" |
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | #include <string.h> | ||
25 | #include "font.h" | 26 | #include "font.h" |
26 | #include "lcd.h" | 27 | #include "lcd.h" |
27 | #include "button.h" | 28 | #include "button.h" |
28 | #include "powermgmt.h" | 29 | #include "powermgmt.h" |
29 | #include "adc.h" | 30 | #include "adc.h" |
31 | #include "hwcompat.h" /* ROM_VERSION */ | ||
32 | #include "crc32.h" | ||
30 | #include "debug-target.h" | 33 | #include "debug-target.h" |
31 | 34 | ||
35 | |||
36 | /* Tool function to read the flash manufacturer and type, if available. | ||
37 | Only chips which could be reprogrammed in system will return values. | ||
38 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | ||
39 | /* In IRAM to avoid problems when running directly from Flash */ | ||
40 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
41 | unsigned addr1, unsigned addr2) | ||
42 | ICODE_ATTR __attribute__((noinline)); | ||
43 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
44 | unsigned addr1, unsigned addr2) | ||
45 | { | ||
46 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | ||
47 | unsigned manu, id; /* read values when in ID mode */ | ||
48 | |||
49 | volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */ | ||
50 | int old_level; /* saved interrupt level */ | ||
51 | |||
52 | not_manu = flash[0]; /* read the normal content */ | ||
53 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | ||
54 | |||
55 | /* disable interrupts, prevent any stray flash access */ | ||
56 | old_level = disable_irq_save(); | ||
57 | |||
58 | flash[addr1] = 0xAA; /* enter command mode */ | ||
59 | flash[addr2] = 0x55; | ||
60 | flash[addr1] = 0x90; /* ID command */ | ||
61 | /* Atmel wants 20ms pause here */ | ||
62 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
63 | |||
64 | manu = flash[0]; /* read the IDs */ | ||
65 | id = flash[1]; | ||
66 | |||
67 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | ||
68 | /* Atmel wants 20ms pause here */ | ||
69 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
70 | |||
71 | restore_irq(old_level); /* enable interrupts again */ | ||
72 | /* I assume success if the obtained values are different from | ||
73 | the normal flash content. This is not perfectly bulletproof, they | ||
74 | could theoretically be the same by chance, causing us to fail. */ | ||
75 | if (not_manu != manu || not_id != id) /* a value has changed */ | ||
76 | { | ||
77 | *p_manufacturer = manu; /* return the results */ | ||
78 | *p_device = id; | ||
79 | return true; /* success */ | ||
80 | } | ||
81 | return false; /* fail */ | ||
82 | } | ||
83 | |||
32 | bool dbg_ports(void) | 84 | bool dbg_ports(void) |
33 | { | 85 | { |
34 | int adc_battery_voltage; | 86 | int adc_battery_voltage; |
@@ -58,11 +110,11 @@ bool dbg_ports(void) | |||
58 | adc_battery_voltage % 1000, adc_battery_level); | 110 | adc_battery_voltage % 1000, adc_battery_level); |
59 | 111 | ||
60 | lcd_update(); | 112 | lcd_update(); |
61 | if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) | 113 | |
62 | { | 114 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); |
63 | lcd_setfont(FONT_UI); | 115 | |
64 | return false; | 116 | lcd_setfont(FONT_UI); |
65 | } | 117 | |
66 | #else /* !HAVE_LCD_BITMAP */ | 118 | #else /* !HAVE_LCD_BITMAP */ |
67 | 119 | ||
68 | if (currval == 0) { | 120 | if (currval == 0) { |
@@ -101,3 +153,127 @@ bool dbg_ports(void) | |||
101 | } | 153 | } |
102 | return false; | 154 | return false; |
103 | } | 155 | } |
156 | |||
157 | bool dbg_hw_info(void) | ||
158 | { | ||
159 | #ifndef HAVE_LCD_BITMAP | ||
160 | int button; | ||
161 | int currval = 0; | ||
162 | #else | ||
163 | int bitmask = HW_MASK; | ||
164 | #endif | ||
165 | int rom_version = ROM_VERSION; | ||
166 | unsigned manu, id; /* flash IDs */ | ||
167 | bool got_id; /* flag if we managed to get the flash IDs */ | ||
168 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ | ||
169 | bool has_bootrom; /* flag for boot ROM present */ | ||
170 | int oldmode; /* saved memory guard mode */ | ||
171 | |||
172 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
173 | |||
174 | /* get flash ROM type */ | ||
175 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
176 | if (!got_id) | ||
177 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
178 | |||
179 | /* check if the boot ROM area is a flash mirror */ | ||
180 | has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0); | ||
181 | if (has_bootrom) /* if ROM and Flash different */ | ||
182 | { | ||
183 | /* calculate CRC16 checksum of boot ROM */ | ||
184 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); | ||
185 | } | ||
186 | |||
187 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
188 | |||
189 | lcd_clear_display(); | ||
190 | |||
191 | #ifdef HAVE_LCD_BITMAP | ||
192 | lcd_setfont(FONT_SYSFIXED); | ||
193 | |||
194 | lcd_puts(0, 0, "[Hardware info]"); | ||
195 | |||
196 | lcd_putsf(0, 1, "ROM: %d.%02d", rom_version/100, rom_version%100); | ||
197 | |||
198 | lcd_putsf(0, 2, "Mask: 0x%04x", bitmask); | ||
199 | if (got_id) | ||
200 | lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu, id); | ||
201 | else | ||
202 | lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */ | ||
203 | |||
204 | if (has_bootrom) | ||
205 | { | ||
206 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
207 | lcd_puts(0, 4, "Boot ROM: V1"); | ||
208 | else | ||
209 | lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc); | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | lcd_puts(0, 4, "Boot ROM: none"); | ||
214 | } | ||
215 | |||
216 | lcd_update(); | ||
217 | |||
218 | /* wait for exit */ | ||
219 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); | ||
220 | |||
221 | lcd_setfont(FONT_UI); | ||
222 | |||
223 | #else /* !HAVE_LCD_BITMAP */ | ||
224 | lcd_puts(0, 0, "[HW Info]"); | ||
225 | while(1) | ||
226 | { | ||
227 | switch(currval) | ||
228 | { | ||
229 | case 0: | ||
230 | lcd_putsf(0, 1, "ROM: %d.%02d", | ||
231 | rom_version/100, rom_version%100); | ||
232 | break; | ||
233 | case 1: | ||
234 | if (got_id) | ||
235 | lcd_putsf(0, 1, "Flash:%02x,%02x", manu, id); | ||
236 | else | ||
237 | lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */ | ||
238 | break; | ||
239 | case 2: | ||
240 | if (has_bootrom) | ||
241 | { | ||
242 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
243 | lcd_puts(0, 1, "BootROM: V1"); | ||
244 | else if (rom_crc == 0x358099E8) | ||
245 | lcd_puts(0, 1, "BootROM: V2"); | ||
246 | /* alternative boot ROM found in one single player so far */ | ||
247 | else | ||
248 | lcd_putsf(0, 1, "R: %08x", rom_crc); | ||
249 | } | ||
250 | else | ||
251 | lcd_puts(0, 1, "BootROM: no"); | ||
252 | } | ||
253 | |||
254 | lcd_update(); | ||
255 | |||
256 | button = button_get_w_tmo(HZ/10); | ||
257 | |||
258 | switch(button) | ||
259 | { | ||
260 | case BUTTON_STOP: | ||
261 | return false; | ||
262 | |||
263 | case BUTTON_LEFT: | ||
264 | currval--; | ||
265 | if(currval < 0) | ||
266 | currval = 2; | ||
267 | break; | ||
268 | |||
269 | case BUTTON_RIGHT: | ||
270 | currval++; | ||
271 | if(currval > 2) | ||
272 | currval = 0; | ||
273 | break; | ||
274 | } | ||
275 | } | ||
276 | #endif | ||
277 | return false; | ||
278 | } | ||
279 | |||
diff --git a/firmware/target/sh/debug-target.h b/firmware/target/sh/debug-target.h index 4e25b81948..f738795ea6 100644 --- a/firmware/target/sh/debug-target.h +++ b/firmware/target/sh/debug-target.h | |||
@@ -25,3 +25,4 @@ | |||
25 | # define DEBUG_CANCEL BUTTON_MENU | 25 | # define DEBUG_CANCEL BUTTON_MENU |
26 | #endif | 26 | #endif |
27 | bool dbg_ports(void); | 27 | bool dbg_ports(void); |
28 | bool dbg_hw_info(void); | ||