1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Heikki Hannikainen
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #include "debug_menu.h"
36 #include "powermgmt.h"
40 #include "mp3_playback.h"
43 #include "statusbar.h"
54 #include "lcd-remote.h"
66 #include "eeprom_24cxx.h"
67 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
70 #if (CONFIG_STORAGE & STORAGE_ATA)
79 #ifdef HAVE_LCD_BITMAP
80 #include "scrollbar.h"
81 #include "peakmeter.h"
84 #if CONFIG_CODEC == SWCODEC
86 #include "buffering.h"
88 #if defined(HAVE_SPDIF_OUT) || defined(HAVE_SPDIF_IN)
92 #ifdef IRIVER_H300_SERIES
93 #include "pcf50606.h" /* for pcf50606_read */
100 #if CONFIG_RTC == RTC_PCF50605
101 #include "pcf50605.h"
104 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
105 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525
106 #include "debug-target.h"
109 #if defined(SANSA_E200) || defined(PHILIPS_SA9200)
114 #if defined(HAVE_USBSTACK)
115 #include "usb_core.h"
118 #include "usbstack/usb_storage.h"
121 /*---------------------------------------------------*/
122 /* SPECIAL DEBUG STUFF */
123 /*---------------------------------------------------*/
124 extern struct thread_entry threads
[MAXTHREADS
];
126 static char thread_status_char(unsigned status
)
128 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
130 [0 ... THREAD_NUM_STATES
] = '?',
131 [STATE_RUNNING
] = 'R',
132 [STATE_BLOCKED
] = 'B',
133 [STATE_SLEEPING
] = 'S',
134 [STATE_BLOCKED_W_TMO
] = 'T',
135 [STATE_FROZEN
] = 'F',
136 [STATE_KILLED
] = 'K',
139 if (status
> THREAD_NUM_STATES
)
140 status
= THREAD_NUM_STATES
;
142 return thread_status_chars
[status
];
145 static char* threads_getname(int selected_item
, void *data
,
146 char *buffer
, size_t buffer_len
)
149 struct thread_entry
*thread
;
153 if (selected_item
< (int)NUM_CORES
)
155 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
156 idle_stack_usage(selected_item
));
160 selected_item
-= NUM_CORES
;
163 thread
= &threads
[selected_item
];
165 if (thread
->state
== STATE_KILLED
)
167 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
171 thread_get_name(name
, 32, thread
);
173 snprintf(buffer
, buffer_len
,
174 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
176 IF_COP(thread
->core
,)
177 #ifdef HAVE_SCHEDULER_BOOSTCTRL
178 (thread
->cpu_boost
) ? '+' :
180 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
181 thread_status_char(thread
->state
),
182 IF_PRIO(thread
->base_priority
, thread
->priority
, )
183 thread_stack_usage(thread
), name
);
187 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
190 #ifdef ROCKBOX_HAS_LOGF
191 if (action
== ACTION_STD_OK
)
193 int selpos
= gui_synclist_get_sel_pos(lists
);
195 if (selpos
>= NUM_CORES
)
196 remove_thread(&threads
[selpos
- NUM_CORES
]);
198 remove_thread(&threads
[selpos
]);
200 return ACTION_REDRAW
;
202 #endif /* ROCKBOX_HAS_LOGF */
203 if (action
== ACTION_NONE
)
204 action
= ACTION_REDRAW
;
208 static bool dbg_os(void)
210 struct simplelist_info info
;
211 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
215 MAXTHREADS
+NUM_CORES
,
218 #ifndef ROCKBOX_HAS_LOGF
219 info
.hide_selection
= true;
220 info
.scroll_all
= true;
222 info
.action_callback
= dbg_threads_action_callback
;
223 info
.get_name
= threads_getname
;
224 return simplelist_show_list(&info
);
227 #ifdef HAVE_LCD_BITMAP
228 #if CONFIG_CODEC != SWCODEC
230 static bool dbg_audio_thread(void)
233 struct audio_debug d
;
235 lcd_setfont(FONT_SYSFIXED
);
236 viewportmanager_set_statusbar(false);
240 if (action_userabort(HZ
/5))
243 audio_get_debugdata(&d
);
247 snprintf(buf
, sizeof(buf
), "read: %x", d
.audiobuf_read
);
249 snprintf(buf
, sizeof(buf
), "write: %x", d
.audiobuf_write
);
251 snprintf(buf
, sizeof(buf
), "swap: %x", d
.audiobuf_swapwrite
);
253 snprintf(buf
, sizeof(buf
), "playing: %d", d
.playing
);
255 snprintf(buf
, sizeof(buf
), "playable: %x", d
.playable_space
);
257 snprintf(buf
, sizeof(buf
), "unswapped: %x", d
.unswapped_space
);
260 /* Playable space left */
261 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
262 d
.playable_space
, HORIZONTAL
);
264 /* Show the watermark limit */
265 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
266 d
.low_watermark_level
, HORIZONTAL
);
268 snprintf(buf
, sizeof(buf
), "wm: %x - %x",
269 d
.low_watermark_level
, d
.lowest_watermark_level
);
274 viewportmanager_set_statusbar(true);
277 #endif /* !SIMULATOR */
278 #else /* CONFIG_CODEC == SWCODEC */
279 extern size_t filebuflen
;
280 /* This is a size_t, but call it a long so it puts a - when it's bad. */
282 static unsigned int ticks
, boost_ticks
, freq_sum
;
284 static void dbg_audio_task(void)
287 if(FREQ
> CPUFREQ_NORMAL
)
289 freq_sum
+= FREQ
/1000000; /* in MHz */
294 static bool dbg_buffering_thread(void)
301 size_t bufsize
= pcmbuf_get_bufsize();
302 int pcmbufdescs
= pcmbuf_descs();
303 struct buffering_debug d
;
305 ticks
= boost_ticks
= freq_sum
= 0;
307 tick_add_task(dbg_audio_task
);
309 lcd_setfont(FONT_SYSFIXED
);
310 viewportmanager_set_statusbar(false);
313 button
= get_action(CONTEXT_STD
,HZ
/5);
316 case ACTION_STD_NEXT
:
319 case ACTION_STD_PREV
:
322 case ACTION_STD_CANCEL
:
327 buffering_get_debugdata(&d
);
332 bufused
= bufsize
- pcmbuf_free();
334 snprintf(buf
, sizeof(buf
), "pcm: %7ld/%7ld", (long) bufused
, (long) bufsize
);
335 lcd_puts(0, line
++, buf
);
337 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
338 bufsize
, 0, bufused
, HORIZONTAL
);
341 snprintf(buf
, sizeof(buf
), "alloc: %8ld/%8ld", audio_filebufused(),
343 lcd_puts(0, line
++, buf
);
346 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
347 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
350 snprintf(buf
, sizeof(buf
), "real: %8ld/%8ld", (long)d
.buffered_data
,
352 lcd_puts(0, line
++, buf
);
354 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
355 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
359 snprintf(buf
, sizeof(buf
), "usefl: %8ld/%8ld", (long)(d
.useful_data
),
361 lcd_puts(0, line
++, buf
);
364 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
365 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
369 snprintf(buf
, sizeof(buf
), "data_rem: %ld", (long)d
.data_rem
);
370 lcd_puts(0, line
++, buf
);
372 snprintf(buf
, sizeof(buf
), "track count: %2d", audio_track_count());
373 lcd_puts(0, line
++, buf
);
375 snprintf(buf
, sizeof(buf
), "handle count: %d", (int)d
.num_handles
);
376 lcd_puts(0, line
++, buf
);
379 snprintf(buf
, sizeof(buf
), "cpu freq: %3dMHz",
380 (int)((FREQ
+ 500000) / 1000000));
381 lcd_puts(0, line
++, buf
);
386 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
387 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
388 snprintf(buf
, sizeof(buf
), "boost ratio: %3d.%d%% (%2d.%dMHz)",
389 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
390 lcd_puts(0, line
++, buf
);
393 snprintf(buf
, sizeof(buf
), "pcmbufdesc: %2d/%2d",
394 pcmbuf_used_descs(), pcmbufdescs
);
395 lcd_puts(0, line
++, buf
);
400 tick_remove_task(dbg_audio_task
);
401 viewportmanager_set_statusbar(true);
405 #endif /* CONFIG_CODEC */
406 #endif /* HAVE_LCD_BITMAP */
409 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
410 /* Tool function to read the flash manufacturer and type, if available.
411 Only chips which could be reprogrammed in system will return values.
412 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
413 /* In IRAM to avoid problems when running directly from Flash */
414 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
415 unsigned addr1
, unsigned addr2
)
416 ICODE_ATTR
__attribute__((noinline
));
417 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
418 unsigned addr1
, unsigned addr2
)
421 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
422 unsigned manu
, id
; /* read values when in ID mode */
424 #if CONFIG_CPU == SH7034
425 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
426 #elif defined(CPU_COLDFIRE)
427 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
429 int old_level
; /* saved interrupt level */
431 not_manu
= flash
[0]; /* read the normal content */
432 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
434 /* disable interrupts, prevent any stray flash access */
435 old_level
= disable_irq_save();
437 flash
[addr1
] = 0xAA; /* enter command mode */
439 flash
[addr1
] = 0x90; /* ID command */
440 /* Atmel wants 20ms pause here */
441 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
443 manu
= flash
[0]; /* read the IDs */
446 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
447 /* Atmel wants 20ms pause here */
448 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
450 restore_irq(old_level
); /* enable interrupts again */
452 /* I assume success if the obtained values are different from
453 the normal flash content. This is not perfectly bulletproof, they
454 could theoretically be the same by chance, causing us to fail. */
455 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
457 *p_manufacturer
= manu
; /* return the results */
459 return true; /* success */
461 return false; /* fail */
463 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
467 static int perfcheck(void)
473 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
476 "ldr r0, [%[timr]] \n"
477 "add r0, r0, %[tmo] \n"
479 "add %[res], %[res], #1 \n"
480 "ldr r1, [%[timr]] \n"
483 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
487 [timr
]"r"(&USEC_TIMER
),
489 #if CONFIG_CPU == PP5002
491 #else /* PP5020/5022/5024 */
502 #ifdef HAVE_LCD_BITMAP
503 static bool dbg_hw_info(void)
505 #if CONFIG_CPU == SH7034
507 int bitmask
= HW_MASK
;
508 int rom_version
= ROM_VERSION
;
509 unsigned manu
, id
; /* flash IDs */
510 bool got_id
; /* flag if we managed to get the flash IDs */
511 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
512 bool has_bootrom
; /* flag for boot ROM present */
513 int oldmode
; /* saved memory guard mode */
515 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
517 /* get flash ROM type */
518 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
520 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
522 /* check if the boot ROM area is a flash mirror */
523 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
524 if (has_bootrom
) /* if ROM and Flash different */
526 /* calculate CRC16 checksum of boot ROM */
527 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
530 system_memory_guard(oldmode
); /* re-enable memory guard */
532 lcd_setfont(FONT_SYSFIXED
);
534 viewportmanager_set_statusbar(false);
536 lcd_puts(0, 0, "[Hardware info]");
538 snprintf(buf
, 32, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
541 snprintf(buf
, 32, "Mask: 0x%04x", bitmask
);
545 snprintf(buf
, 32, "Flash: M=%02x D=%02x", manu
, id
);
547 snprintf(buf
, 32, "Flash: M=?? D=??"); /* unknown, sorry */
552 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
553 snprintf(buf
, 32, "Boot ROM: V1");
555 snprintf(buf
, 32, "ROMcrc: 0x%08x", rom_crc
);
559 snprintf(buf
, 32, "Boot ROM: none");
565 while (!(action_userabort(TIMEOUT_BLOCK
)));
567 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
569 unsigned manu
, id
; /* flash IDs */
570 int got_id
; /* flag if we managed to get the flash IDs */
571 int oldmode
; /* saved memory guard mode */
573 viewportmanager_set_statusbar(false);
575 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
577 /* get flash ROM type */
578 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
580 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
582 system_memory_guard(oldmode
); /* re-enable memory guard */
584 lcd_setfont(FONT_SYSFIXED
);
587 lcd_puts(0, line
++, "[Hardware info]");
590 snprintf(buf
, 32, "Flash: M=%04x D=%04x", manu
, id
);
592 snprintf(buf
, 32, "Flash: M=???? D=????"); /* unknown, sorry */
593 lcd_puts(0, line
++, buf
);
599 lcd_puts(0, ++line
, "Serial Number:");
601 got_id
= ds2411_read_id(&id
);
603 if (got_id
== DS2411_OK
)
605 snprintf(buf
, 32, " FC=%02x", (unsigned)id
.family_code
);
606 lcd_puts(0, ++line
, buf
);
607 snprintf(buf
, 32, " ID=%02X %02X %02X %02X %02X %02X",
608 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
609 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
610 lcd_puts(0, ++line
, buf
);
611 snprintf(buf
, 32, " CRC=%02X", (unsigned)id
.crc
);
615 snprintf(buf
, 32, "READ ERR=%d", got_id
);
618 lcd_puts(0, ++line
, buf
);
624 while (!(action_userabort(TIMEOUT_BLOCK
)));
626 #elif defined(CPU_PP502x)
629 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
630 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
631 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
632 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
634 lcd_setfont(FONT_SYSFIXED
);
636 viewportmanager_set_statusbar(false);
638 lcd_puts(0, line
++, "[Hardware info]");
641 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
642 lcd_puts(0, line
++, buf
);
646 extern int lcd_type
; /* Defined in lcd-colornano.c */
648 snprintf(buf
, sizeof(buf
), "LCD type: %d", lcd_type
);
649 lcd_puts(0, line
++, buf
);
652 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
653 lcd_puts(0, line
++, buf
);
655 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
656 lcd_puts(0, line
++, buf
);
660 while (!(action_userabort(TIMEOUT_BLOCK
)));
662 #elif CONFIG_CPU == PP5002
665 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
666 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
667 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
668 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\0' };
671 lcd_setfont(FONT_SYSFIXED
);
674 lcd_puts(0, line
++, "[Hardware info]");
677 snprintf(buf
, sizeof(buf
), "HW rev: 0x%08lx", IPOD_HW_REVISION
);
678 lcd_puts(0, line
++, buf
);
681 snprintf(buf
, sizeof(buf
), "PP version: %s", pp_version
);
682 lcd_puts(0, line
++, buf
);
684 snprintf(buf
, sizeof(buf
), "Est. clock (kHz): %d", perfcheck());
685 lcd_puts(0, line
++, buf
);
689 while (!(action_userabort(TIMEOUT_BLOCK
)));
692 /* Define this function in your target tree */
693 return __dbg_hw_info();
694 #endif /* CONFIG_CPU */
695 viewportmanager_set_statusbar(true);
698 #else /* !HAVE_LCD_BITMAP */
699 static bool dbg_hw_info(void)
704 int rom_version
= ROM_VERSION
;
705 unsigned manu
, id
; /* flash IDs */
706 bool got_id
; /* flag if we managed to get the flash IDs */
707 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
708 bool has_bootrom
; /* flag for boot ROM present */
709 int oldmode
; /* saved memory guard mode */
711 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
713 /* get flash ROM type */
714 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
716 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
718 /* check if the boot ROM area is a flash mirror */
719 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
720 if (has_bootrom
) /* if ROM and Flash different */
722 /* calculate CRC16 checksum of boot ROM */
723 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
726 system_memory_guard(oldmode
); /* re-enable memory guard */
730 lcd_puts(0, 0, "[HW Info]");
736 snprintf(buf
, 32, "ROM: %d.%02d",
737 rom_version
/100, rom_version
%100);
741 snprintf(buf
, 32, "Flash:%02x,%02x", manu
, id
);
743 snprintf(buf
, 32, "Flash:??,??"); /* unknown, sorry */
748 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
749 snprintf(buf
, 32, "BootROM: V1");
750 else if (rom_crc
== 0x358099E8)
751 snprintf(buf
, 32, "BootROM: V2");
752 /* alternative boot ROM found in one single player so far */
754 snprintf(buf
, 32, "R: %08x", rom_crc
);
757 snprintf(buf
, 32, "BootROM: no");
763 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
767 case ACTION_STD_CANCEL
:
770 case ACTION_SETTINGS_DEC
:
776 case ACTION_SETTINGS_INC
:
785 #endif /* !HAVE_LCD_BITMAP */
786 #endif /* !SIMULATOR */
789 static char* dbg_partitions_getname(int selected_item
, void *data
,
790 char *buffer
, size_t buffer_len
)
793 int partition
= selected_item
/2;
794 struct partinfo
* p
= disk_partinfo(partition
);
797 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
801 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
806 bool dbg_partitions(void)
808 struct simplelist_info info
;
809 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
810 info
.selection_size
= 2;
811 info
.hide_selection
= true;
812 info
.scroll_all
= true;
813 info
.get_name
= dbg_partitions_getname
;
814 return simplelist_show_list(&info
);
818 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
819 static bool dbg_spdif(void)
823 unsigned int control
;
828 unsigned int interruptstat
;
829 bool valnogood
, symbolerr
, parityerr
;
832 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
833 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
836 lcd_setfont(FONT_SYSFIXED
);
837 viewportmanager_set_statusbar(false);
839 #ifdef HAVE_SPDIF_POWER
840 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
847 control
= EBU1RCVCCHANNEL1
;
848 interruptstat
= INTERRUPTSTAT
;
849 INTERRUPTCLEAR
= 0x03c00000;
851 valnogood
= (interruptstat
& 0x01000000)?true:false;
852 symbolerr
= (interruptstat
& 0x00800000)?true:false;
853 parityerr
= (interruptstat
& 0x00400000)?true:false;
855 snprintf(buf
, sizeof(buf
), "Val: %s Sym: %s Par: %s",
858 parityerr
?"--":"OK");
859 lcd_puts(0, line
++, buf
);
861 snprintf(buf
, sizeof(buf
), "Status word: %08x", (int)control
);
862 lcd_puts(0, line
++, buf
);
867 snprintf(buf
, sizeof(buf
), "PRO: %d (%s)",
868 x
, x
?"Professional":"Consumer");
869 lcd_puts(0, line
++, buf
);
871 x
= (control
>> 30) & 1;
872 snprintf(buf
, sizeof(buf
), "Audio: %d (%s)",
873 x
, x
?"Non-PCM":"PCM");
874 lcd_puts(0, line
++, buf
);
876 x
= (control
>> 29) & 1;
877 snprintf(buf
, sizeof(buf
), "Copy: %d (%s)",
878 x
, x
?"Permitted":"Inhibited");
879 lcd_puts(0, line
++, buf
);
881 x
= (control
>> 27) & 7;
894 snprintf(buf
, sizeof(buf
), "Preemphasis: %d (%s)", x
, s
);
895 lcd_puts(0, line
++, buf
);
897 x
= (control
>> 24) & 3;
898 snprintf(buf
, sizeof(buf
), "Mode: %d", x
);
899 lcd_puts(0, line
++, buf
);
901 category
= (control
>> 17) & 127;
913 snprintf(buf
, sizeof(buf
), "Category: 0x%02x (%s)", category
, s
);
914 lcd_puts(0, line
++, buf
);
916 x
= (control
>> 16) & 1;
918 if(((category
& 0x70) == 0x10) ||
919 ((category
& 0x70) == 0x40) ||
920 ((category
& 0x78) == 0x38))
922 generation
= !generation
;
924 snprintf(buf
, sizeof(buf
), "Generation: %d (%s)",
925 x
, generation
?"Original":"No ind.");
926 lcd_puts(0, line
++, buf
);
928 x
= (control
>> 12) & 15;
929 snprintf(buf
, sizeof(buf
), "Source: %d", x
);
930 lcd_puts(0, line
++, buf
);
932 x
= (control
>> 8) & 15;
948 snprintf(buf
, sizeof(buf
), "Channel: %d (%s)", x
, s
);
949 lcd_puts(0, line
++, buf
);
951 x
= (control
>> 4) & 15;
964 snprintf(buf
, sizeof(buf
), "Frequency: %d (%s)", x
, s
);
965 lcd_puts(0, line
++, buf
);
967 x
= (control
>> 2) & 3;
968 snprintf(buf
, sizeof(buf
), "Clock accuracy: %d", x
);
969 lcd_puts(0, line
++, buf
);
973 snprintf(buf
, sizeof(buf
), "Measured freq: %ldHz",
974 spdif_measure_frequency());
975 lcd_puts(0, line
++, buf
);
980 if (action_userabort(HZ
/10))
984 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
986 #ifdef HAVE_SPDIF_POWER
987 spdif_power_enable(global_settings
.spdif_enable
);
990 viewportmanager_set_statusbar(true);
993 #endif /* CPU_COLDFIRE */
996 #ifdef HAVE_LCD_BITMAP
997 /* button definitions */
998 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
999 (CONFIG_KEYPAD == IRIVER_H300_PAD)
1000 # define DEBUG_CANCEL BUTTON_OFF
1002 #elif CONFIG_KEYPAD == RECORDER_PAD
1003 # define DEBUG_CANCEL BUTTON_OFF
1005 #elif CONFIG_KEYPAD == ONDIO_PAD
1006 # define DEBUG_CANCEL BUTTON_MENU
1008 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
1009 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
1010 (CONFIG_KEYPAD == IPOD_4G_PAD)
1011 # define DEBUG_CANCEL BUTTON_MENU
1013 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
1014 # define DEBUG_CANCEL BUTTON_PLAY
1016 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
1017 # define DEBUG_CANCEL BUTTON_REC
1019 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
1020 # define DEBUG_CANCEL BUTTON_RC_REC
1022 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
1023 # define DEBUG_CANCEL BUTTON_REW
1025 #elif (CONFIG_KEYPAD == MROBE100_PAD)
1026 # define DEBUG_CANCEL BUTTON_MENU
1028 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
1029 (CONFIG_KEYPAD == SANSA_C200_PAD)
1030 # define DEBUG_CANCEL BUTTON_LEFT
1032 /* This is temporary until the SA9200 touchpad works */
1033 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) || \
1034 (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD)
1035 # define DEBUG_CANCEL BUTTON_POWER
1037 #endif /* key definitions */
1040 bool dbg_ports(void)
1042 #if CONFIG_CPU == SH7034
1044 int adc_battery_voltage
, adc_battery_level
;
1046 lcd_setfont(FONT_SYSFIXED
);
1047 lcd_clear_display();
1048 viewportmanager_set_statusbar(false);
1052 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1053 lcd_puts(0, 0, buf
);
1054 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1055 lcd_puts(0, 1, buf
);
1057 snprintf(buf
, 32, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1058 lcd_puts(0, 2, buf
);
1059 snprintf(buf
, 32, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1060 lcd_puts(0, 3, buf
);
1061 snprintf(buf
, 32, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1062 lcd_puts(0, 4, buf
);
1063 snprintf(buf
, 32, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1064 lcd_puts(0, 5, buf
);
1066 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1067 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1068 adc_battery_voltage
% 1000, adc_battery_level
);
1069 lcd_puts(0, 6, buf
);
1072 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1074 viewportmanager_set_statusbar(true);
1078 #elif defined(CPU_COLDFIRE)
1079 unsigned int gpio_out
;
1080 unsigned int gpio1_out
;
1081 unsigned int gpio_read
;
1082 unsigned int gpio1_read
;
1083 unsigned int gpio_function
;
1084 unsigned int gpio1_function
;
1085 unsigned int gpio_enable
;
1086 unsigned int gpio1_enable
;
1087 int adc_buttons
, adc_remote
;
1088 int adc_battery_voltage
, adc_battery_level
;
1092 lcd_clear_display();
1093 lcd_setfont(FONT_SYSFIXED
);
1094 viewportmanager_set_statusbar(false);
1099 gpio_read
= GPIO_READ
;
1100 gpio1_read
= GPIO1_READ
;
1101 gpio_out
= GPIO_OUT
;
1102 gpio1_out
= GPIO1_OUT
;
1103 gpio_function
= GPIO_FUNCTION
;
1104 gpio1_function
= GPIO1_FUNCTION
;
1105 gpio_enable
= GPIO_ENABLE
;
1106 gpio1_enable
= GPIO1_ENABLE
;
1108 snprintf(buf
, sizeof(buf
), "GPIO_READ: %08x", gpio_read
);
1109 lcd_puts(0, line
++, buf
);
1110 snprintf(buf
, sizeof(buf
), "GPIO_OUT: %08x", gpio_out
);
1111 lcd_puts(0, line
++, buf
);
1112 snprintf(buf
, sizeof(buf
), "GPIO_FUNC: %08x", gpio_function
);
1113 lcd_puts(0, line
++, buf
);
1114 snprintf(buf
, sizeof(buf
), "GPIO_ENA: %08x", gpio_enable
);
1115 lcd_puts(0, line
++, buf
);
1117 snprintf(buf
, sizeof(buf
), "GPIO1_READ: %08x", gpio1_read
);
1118 lcd_puts(0, line
++, buf
);
1119 snprintf(buf
, sizeof(buf
), "GPIO1_OUT: %08x", gpio1_out
);
1120 lcd_puts(0, line
++, buf
);
1121 snprintf(buf
, sizeof(buf
), "GPIO1_FUNC: %08x", gpio1_function
);
1122 lcd_puts(0, line
++, buf
);
1123 snprintf(buf
, sizeof(buf
), "GPIO1_ENA: %08x", gpio1_enable
);
1124 lcd_puts(0, line
++, buf
);
1126 adc_buttons
= adc_read(ADC_BUTTONS
);
1127 adc_remote
= adc_read(ADC_REMOTE
);
1128 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1129 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1130 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS (%c): %02x",
1131 button_scan_enabled() ? '+' : '-', adc_buttons
);
1133 snprintf(buf
, sizeof(buf
), "ADC_BUTTONS: %02x", adc_buttons
);
1135 lcd_puts(0, line
++, buf
);
1136 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1137 snprintf(buf
, sizeof(buf
), "ADC_REMOTE (%c): %02x",
1138 remote_detect() ? '+' : '-', adc_remote
);
1140 snprintf(buf
, sizeof(buf
), "ADC_REMOTE: %02x", adc_remote
);
1142 lcd_puts(0, line
++, buf
);
1143 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1144 snprintf(buf
, sizeof(buf
), "ADC_REMOTEDETECT: %02x",
1145 adc_read(ADC_REMOTEDETECT
));
1146 lcd_puts(0, line
++, buf
);
1149 snprintf(buf
, 32, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1150 adc_battery_voltage
% 1000, adc_battery_level
);
1151 lcd_puts(0, line
++, buf
);
1153 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1154 snprintf(buf
, sizeof(buf
), "remotetype: %d", remote_type());
1155 lcd_puts(0, line
++, buf
);
1159 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1161 viewportmanager_set_statusbar(true);
1166 #elif defined(CPU_PP502x)
1171 lcd_clear_display();
1172 lcd_setfont(FONT_SYSFIXED
);
1173 viewportmanager_set_statusbar(false);
1178 lcd_puts(0, line
++, "GPIO STATES:");
1179 snprintf(buf
, sizeof(buf
), "A: %02x E: %02x I: %02x",
1180 (unsigned int)GPIOA_INPUT_VAL
,
1181 (unsigned int)GPIOE_INPUT_VAL
,
1182 (unsigned int)GPIOI_INPUT_VAL
);
1183 lcd_puts(0, line
++, buf
);
1184 snprintf(buf
, sizeof(buf
), "B: %02x F: %02x J: %02x",
1185 (unsigned int)GPIOB_INPUT_VAL
,
1186 (unsigned int)GPIOF_INPUT_VAL
,
1187 (unsigned int)GPIOJ_INPUT_VAL
);
1188 lcd_puts(0, line
++, buf
);
1189 snprintf(buf
, sizeof(buf
), "C: %02x G: %02x K: %02x",
1190 (unsigned int)GPIOC_INPUT_VAL
,
1191 (unsigned int)GPIOG_INPUT_VAL
,
1192 (unsigned int)GPIOK_INPUT_VAL
);
1193 lcd_puts(0, line
++, buf
);
1194 snprintf(buf
, sizeof(buf
), "D: %02x H: %02x L: %02x",
1195 (unsigned int)GPIOD_INPUT_VAL
,
1196 (unsigned int)GPIOH_INPUT_VAL
,
1197 (unsigned int)GPIOL_INPUT_VAL
);
1198 lcd_puts(0, line
++, buf
);
1200 snprintf(buf
, sizeof(buf
), "GPO32_VAL: %08lx", GPO32_VAL
);
1201 lcd_puts(0, line
++, buf
);
1202 snprintf(buf
, sizeof(buf
), "GPO32_EN: %08lx", GPO32_ENABLE
);
1203 lcd_puts(0, line
++, buf
);
1204 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1205 lcd_puts(0, line
++, buf
);
1206 snprintf(buf
, sizeof(buf
), "DEV_EN2: %08lx", DEV_EN2
);
1207 lcd_puts(0, line
++, buf
);
1208 snprintf(buf
, sizeof(buf
), "DEV_EN3: %08lx", inl(0x60006044));
1209 lcd_puts(0, line
++, buf
); /* to be verified */
1210 snprintf(buf
, sizeof(buf
), "DEV_INIT1: %08lx", DEV_INIT1
);
1211 lcd_puts(0, line
++, buf
);
1212 snprintf(buf
, sizeof(buf
), "DEV_INIT2: %08lx", DEV_INIT2
);
1213 lcd_puts(0, line
++, buf
);
1214 #ifdef ADC_ACCESSORY
1215 snprintf(buf
, sizeof(buf
), "ACCESSORY: %d", adc_read(ADC_ACCESSORY
));
1216 lcd_puts(0, line
++, buf
);
1219 #if defined(IPOD_ACCESSORY_PROTOCOL)
1220 extern unsigned char serbuf
[];
1221 snprintf(buf
, sizeof(buf
), "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x",
1222 serbuf
[0], serbuf
[1], serbuf
[2], serbuf
[3], serbuf
[4], serbuf
[5],
1223 serbuf
[6], serbuf
[7]);
1224 lcd_puts(0, line
++, buf
);
1227 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1229 snprintf(buf
, sizeof(buf
), "BATT: %03x UNK1: %03x",
1230 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1231 lcd_puts(0, line
++, buf
);
1232 snprintf(buf
, sizeof(buf
), "REM: %03x PAD: %03x",
1233 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1234 lcd_puts(0, line
++, buf
);
1235 #elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1236 snprintf(buf
, sizeof(buf
), "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1237 lcd_puts(0, line
++, buf
);
1238 snprintf(buf
, sizeof(buf
), "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1239 lcd_puts(0, line
++, buf
);
1240 snprintf(buf
, sizeof(buf
), "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1241 lcd_puts(0, line
++, buf
);
1242 snprintf(buf
, sizeof(buf
), "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1243 lcd_puts(0, line
++, buf
);
1244 snprintf(buf
, sizeof(buf
), "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1245 lcd_puts(0, line
++, buf
);
1246 snprintf(buf
, sizeof(buf
), "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1247 lcd_puts(0, line
++, buf
);
1248 snprintf(buf
, sizeof(buf
), "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1249 lcd_puts(0, line
++, buf
);
1250 snprintf(buf
, sizeof(buf
), "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1251 lcd_puts(0, line
++, buf
);
1252 snprintf(buf
, sizeof(buf
), "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1253 lcd_puts(0, line
++, buf
);
1254 snprintf(buf
, sizeof(buf
), "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1255 lcd_puts(0, line
++, buf
);
1256 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1257 lcd_puts(0, line
++, buf
);
1258 #if !defined(PHILIPS_SA9200)
1259 snprintf(buf
, sizeof(buf
), "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1260 lcd_puts(0, line
++, buf
);
1261 snprintf(buf
, sizeof(buf
), "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1262 lcd_puts(0, line
++, buf
);
1263 snprintf(buf
, sizeof(buf
), "CHARGER: %02X/%02X",
1264 ascodec_read(AS3514_CHARGER
),
1265 ascodec_read(AS3514_IRQ_ENRD0
));
1266 lcd_puts(0, line
++, buf
);
1270 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1272 viewportmanager_set_statusbar(true);
1277 #elif CONFIG_CPU == PP5002
1281 lcd_clear_display();
1282 lcd_setfont(FONT_SYSFIXED
);
1283 viewportmanager_set_statusbar(false);
1288 snprintf(buf
, sizeof(buf
), "GPIO_A: %02x GPIO_B: %02x",
1289 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1290 lcd_puts(0, line
++, buf
);
1291 snprintf(buf
, sizeof(buf
), "GPIO_C: %02x GPIO_D: %02x",
1292 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1293 lcd_puts(0, line
++, buf
);
1295 snprintf(buf
, sizeof(buf
), "DEV_EN: %08lx", DEV_EN
);
1296 lcd_puts(0, line
++, buf
);
1297 snprintf(buf
, sizeof(buf
), "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1298 lcd_puts(0, line
++, buf
);
1299 snprintf(buf
, sizeof(buf
), "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1300 lcd_puts(0, line
++, buf
);
1301 snprintf(buf
, sizeof(buf
), "PLL_CONTROL: %08lx", PLL_CONTROL
);
1302 lcd_puts(0, line
++, buf
);
1303 snprintf(buf
, sizeof(buf
), "PLL_DIV: %08lx", PLL_DIV
);
1304 lcd_puts(0, line
++, buf
);
1305 snprintf(buf
, sizeof(buf
), "PLL_MULT: %08lx", PLL_MULT
);
1306 lcd_puts(0, line
++, buf
);
1307 snprintf(buf
, sizeof(buf
), "TIMING1_CTL: %08lx", TIMING1_CTL
);
1308 lcd_puts(0, line
++, buf
);
1309 snprintf(buf
, sizeof(buf
), "TIMING2_CTL: %08lx", TIMING2_CTL
);
1310 lcd_puts(0, line
++, buf
);
1313 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1315 viewportmanager_set_statusbar(true);
1319 viewportmanager_set_statusbar(true);
1321 return __dbg_ports();
1325 #else /* !HAVE_LCD_BITMAP */
1326 bool dbg_ports(void)
1330 int adc_battery_voltage
;
1333 lcd_clear_display();
1334 viewportmanager_set_statusbar(false);
1341 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1344 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1347 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1350 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1353 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1356 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1359 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1362 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1365 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1368 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1371 lcd_puts(0, 0, buf
);
1373 battery_read_info(&adc_battery_voltage
, NULL
);
1374 snprintf(buf
, 32, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1375 adc_battery_voltage
% 1000);
1376 lcd_puts(0, 1, buf
);
1379 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1383 case ACTION_STD_CANCEL
:
1386 case ACTION_SETTINGS_DEC
:
1392 case ACTION_SETTINGS_INC
:
1399 viewportmanager_set_statusbar(true);
1402 #endif /* !HAVE_LCD_BITMAP */
1403 #endif /* !SIMULATOR */
1405 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1406 static bool dbg_pcf(void)
1411 #ifdef HAVE_LCD_BITMAP
1412 lcd_setfont(FONT_SYSFIXED
);
1414 lcd_clear_display();
1415 viewportmanager_set_statusbar(false);
1421 snprintf(buf
, sizeof(buf
), "DCDC1: %02x", pcf50605_read(0x1b));
1422 lcd_puts(0, line
++, buf
);
1423 snprintf(buf
, sizeof(buf
), "DCDC2: %02x", pcf50605_read(0x1c));
1424 lcd_puts(0, line
++, buf
);
1425 snprintf(buf
, sizeof(buf
), "DCDC3: %02x", pcf50605_read(0x1d));
1426 lcd_puts(0, line
++, buf
);
1427 snprintf(buf
, sizeof(buf
), "DCDC4: %02x", pcf50605_read(0x1e));
1428 lcd_puts(0, line
++, buf
);
1429 snprintf(buf
, sizeof(buf
), "DCDEC1: %02x", pcf50605_read(0x1f));
1430 lcd_puts(0, line
++, buf
);
1431 snprintf(buf
, sizeof(buf
), "DCDEC2: %02x", pcf50605_read(0x20));
1432 lcd_puts(0, line
++, buf
);
1433 snprintf(buf
, sizeof(buf
), "DCUDC1: %02x", pcf50605_read(0x21));
1434 lcd_puts(0, line
++, buf
);
1435 snprintf(buf
, sizeof(buf
), "DCUDC2: %02x", pcf50605_read(0x22));
1436 lcd_puts(0, line
++, buf
);
1437 snprintf(buf
, sizeof(buf
), "IOREGC: %02x", pcf50605_read(0x23));
1438 lcd_puts(0, line
++, buf
);
1439 snprintf(buf
, sizeof(buf
), "D1REGC: %02x", pcf50605_read(0x24));
1440 lcd_puts(0, line
++, buf
);
1441 snprintf(buf
, sizeof(buf
), "D2REGC: %02x", pcf50605_read(0x25));
1442 lcd_puts(0, line
++, buf
);
1443 snprintf(buf
, sizeof(buf
), "D3REGC: %02x", pcf50605_read(0x26));
1444 lcd_puts(0, line
++, buf
);
1445 snprintf(buf
, sizeof(buf
), "LPREG1: %02x", pcf50605_read(0x27));
1446 lcd_puts(0, line
++, buf
);
1449 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1451 viewportmanager_set_statusbar(true);
1456 viewportmanager_set_statusbar(true);
1461 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1462 static bool dbg_cpufreq(void)
1468 #ifdef HAVE_LCD_BITMAP
1469 lcd_setfont(FONT_SYSFIXED
);
1471 lcd_clear_display();
1472 viewportmanager_set_statusbar(false);
1478 snprintf(buf
, sizeof(buf
), "Frequency: %ld", FREQ
);
1479 lcd_puts(0, line
++, buf
);
1481 snprintf(buf
, sizeof(buf
), "boost_counter: %d", get_cpu_boost_counter());
1482 lcd_puts(0, line
++, buf
);
1485 button
= get_action(CONTEXT_STD
,HZ
/10);
1489 case ACTION_STD_PREV
:
1493 case ACTION_STD_NEXT
:
1498 while (get_cpu_boost_counter() > 0)
1500 set_cpu_frequency(CPUFREQ_DEFAULT
);
1503 case ACTION_STD_CANCEL
:
1504 viewportmanager_set_statusbar(true);
1508 viewportmanager_set_statusbar(true);
1511 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1513 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1514 #include "tsc2100.h"
1515 static char *itob(int n
, int len
)
1517 static char binary
[64];
1519 for (i
=1, j
=0;i
<=len
;i
++)
1521 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1528 static char* tsc2100_debug_getname(int selected_item
, void * data
,
1529 char *buffer
, size_t buffer_len
)
1531 int *page
= (int*)data
;
1532 bool reserved
= false;
1536 if ((selected_item
> 0x0a) ||
1537 (selected_item
== 0x04) ||
1538 (selected_item
== 0x08))
1542 if ((selected_item
> 0x05) ||
1543 (selected_item
== 0x02))
1547 if (selected_item
> 0x1e)
1552 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1554 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1555 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1558 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1560 int *page
= (int*)lists
->data
;
1561 if (action
== ACTION_STD_OK
)
1563 *page
= (*page
+1)%3;
1564 snprintf(lists
->title
, 32,
1565 "tsc2100 registers - Page %d", *page
);
1566 return ACTION_REDRAW
;
1570 static bool tsc2100_debug(void)
1573 char title
[32] = "tsc2100 registers - Page 0";
1574 struct simplelist_info info
;
1575 simplelist_info_init(&info
, title
, 32, &page
);
1576 info
.timeout
= HZ
/100;
1577 info
.get_name
= tsc2100_debug_getname
;
1578 info
.action_callback
= tsc2100debug_action_callback
;
1579 return simplelist_show_list(&info
);
1583 #ifdef HAVE_LCD_BITMAP
1585 * view_battery() shows a automatically scaled graph of the battery voltage
1586 * over time. Usable for estimating battery life / charging rate.
1587 * The power_history array is updated in power_thread of powermgmt.c.
1590 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1591 #define BAT_YSPACE (LCD_HEIGHT - 20)
1593 static bool view_battery(void)
1597 unsigned short maxv
, minv
;
1600 lcd_setfont(FONT_SYSFIXED
);
1601 viewportmanager_set_statusbar(false);
1605 lcd_clear_display();
1607 case 0: /* voltage history graph */
1608 /* Find maximum and minimum voltage for scaling */
1609 minv
= power_history
[0];
1611 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1612 if (power_history
[i
] > maxv
)
1613 maxv
= power_history
[i
];
1614 if (power_history
[i
] < minv
)
1615 minv
= power_history
[i
];
1618 snprintf(buf
, 30, "Battery %d.%03d", power_history
[0] / 1000,
1619 power_history
[0] % 1000);
1620 lcd_puts(0, 0, buf
);
1621 snprintf(buf
, 30, "scale %d.%03d-%d.%03dV",
1622 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1623 lcd_puts(0, 1, buf
);
1626 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1627 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1628 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1629 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1630 lcd_set_drawmode(DRMODE_SOLID
);
1631 lcd_vline(x
, LCD_HEIGHT
-1,
1632 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1638 case 1: /* status: */
1639 lcd_puts(0, 0, "Power status:");
1641 battery_read_info(&y
, NULL
);
1642 snprintf(buf
, 30, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1643 lcd_puts(0, 1, buf
);
1644 #ifdef ADC_EXT_POWER
1645 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1646 snprintf(buf
, 30, "External: %d.%03d V", y
/ 1000, y
% 1000);
1647 lcd_puts(0, 2, buf
);
1650 #if defined ARCHOS_RECORDER
1651 snprintf(buf
, 30, "Chgr: %s %s",
1652 charger_inserted() ? "present" : "absent",
1653 charger_enabled() ? "on" : "off");
1654 lcd_puts(0, 3, buf
);
1655 snprintf(buf
, 30, "short delta: %d", short_delta
);
1656 lcd_puts(0, 5, buf
);
1657 snprintf(buf
, 30, "long delta: %d", long_delta
);
1658 lcd_puts(0, 6, buf
);
1659 lcd_puts(0, 7, power_message
);
1660 snprintf(buf
, 30, "USB Inserted: %s",
1661 usb_inserted() ? "yes" : "no");
1662 lcd_puts(0, 8, buf
);
1663 #elif defined IRIVER_H300_SERIES
1664 snprintf(buf
, 30, "USB Charging Enabled: %s",
1665 usb_charging_enabled() ? "yes" : "no");
1666 lcd_puts(0, 9, buf
);
1667 #elif defined IPOD_NANO || defined IPOD_VIDEO
1668 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1669 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1670 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1671 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1672 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1674 snprintf(buf
, 30, "USB pwr: %s",
1675 usb_pwr
? "present" : "absent");
1676 lcd_puts(0, 3, buf
);
1677 snprintf(buf
, 30, "EXT pwr: %s",
1678 ext_pwr
? "present" : "absent");
1679 lcd_puts(0, 4, buf
);
1680 snprintf(buf
, 30, "Battery: %s",
1681 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1682 lcd_puts(0, 5, buf
);
1683 snprintf(buf
, 30, "Dock mode: %s",
1684 dock
? "enabled" : "disabled");
1685 lcd_puts(0, 6, buf
);
1686 snprintf(buf
, 30, "Headphone: %s",
1687 headphone
? "connected" : "disconnected");
1688 lcd_puts(0, 7, buf
);
1689 #elif defined TOSHIBA_GIGABEAT_S
1693 static const unsigned char * const chrgstate_strings
[] =
1704 snprintf(buf
, 30, "Charger: %s",
1705 charger_inserted() ? "present" : "absent");
1706 lcd_puts(0, line
++, buf
);
1708 st
= power_input_status() &
1709 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1710 snprintf(buf
, 30, "%s%s",
1711 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1712 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1713 lcd_puts(0, line
++, buf
);
1715 snprintf(buf
, 30, "IUSB Max: %d", usb_allowed_current());
1716 lcd_puts(0, line
++, buf
);
1718 y
= ARRAYLEN(chrgstate_strings
) - 1;
1720 switch (charge_state
)
1722 case CHARGE_STATE_DISABLED
: y
--;
1723 case CHARGE_STATE_ERROR
: y
--;
1724 case DISCHARGING
: y
--;
1731 snprintf(buf
, 30, "State: %s", chrgstate_strings
[y
]);
1732 lcd_puts(0, line
++, buf
);
1734 snprintf(buf
, 30, "Battery Switch: %s",
1735 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1736 lcd_puts(0, line
++, buf
);
1738 y
= chrgraw_adc_voltage();
1739 snprintf(buf
, 30, "CHRGRAW: %d.%03d V",
1740 y
/ 1000, y
% 1000);
1741 lcd_puts(0, line
++, buf
);
1743 y
= application_supply_adc_voltage();
1744 snprintf(buf
, 30, "BP : %d.%03d V",
1745 y
/ 1000, y
% 1000);
1746 lcd_puts(0, line
++, buf
);
1748 y
= battery_adc_charge_current();
1749 if (y
< 0) x
= '-', y
= -y
;
1751 snprintf(buf
, 30, "CHRGISN:%c%d mA", x
, y
);
1752 lcd_puts(0, line
++, buf
);
1754 y
= cccv_regulator_dissipation();
1755 snprintf(buf
, 30, "P CCCV : %d mW", y
);
1756 lcd_puts(0, line
++, buf
);
1758 y
= battery_charge_current();
1759 if (y
< 0) x
= '-', y
= -y
;
1761 snprintf(buf
, 30, "I Charge:%c%d mA", x
, y
);
1762 lcd_puts(0, line
++, buf
);
1764 y
= battery_adc_temp();
1767 snprintf(buf
, 30, "T Battery: %dC (%dF)", y
,
1770 /* Conversion disabled */
1771 snprintf(buf
, 30, "T Battery: ?");
1774 lcd_puts(0, line
++, buf
);
1776 snprintf(buf
, 30, "Charger: %s",
1777 charger_inserted() ? "present" : "absent");
1778 lcd_puts(0, 3, buf
);
1779 #endif /* target type */
1780 #endif /* CONFIG_CHARGING */
1783 case 2: /* voltage deltas: */
1784 lcd_puts(0, 0, "Voltage deltas:");
1786 for (i
= 0; i
<= 6; i
++) {
1787 y
= power_history
[i
] - power_history
[i
+1];
1788 snprintf(buf
, 30, "-%d min: %s%d.%03d V", i
,
1789 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1790 ((y
< 0) ? y
* -1 : y
) % 1000);
1791 lcd_puts(0, i
+1, buf
);
1795 case 3: /* remaining time estimation: */
1797 #ifdef ARCHOS_RECORDER
1798 snprintf(buf
, 30, "charge_state: %d", charge_state
);
1799 lcd_puts(0, 0, buf
);
1801 snprintf(buf
, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1802 lcd_puts(0, 1, buf
);
1804 snprintf(buf
, 30, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1805 lcd_puts(0, 2, buf
);
1807 snprintf(buf
, 30, "P=%2d I=%2d", pid_p
, pid_i
);
1808 lcd_puts(0, 3, buf
);
1810 snprintf(buf
, 30, "Trickle sec: %d/60", trickle_sec
);
1811 lcd_puts(0, 4, buf
);
1812 #endif /* ARCHOS_RECORDER */
1814 snprintf(buf
, 30, "Last PwrHist: %d.%03dV",
1815 power_history
[0] / 1000,
1816 power_history
[0] % 1000);
1817 lcd_puts(0, 5, buf
);
1819 snprintf(buf
, 30, "battery level: %d%%", battery_level());
1820 lcd_puts(0, 6, buf
);
1822 snprintf(buf
, 30, "Est. remain: %d m", battery_time());
1823 lcd_puts(0, 7, buf
);
1829 switch(get_action(CONTEXT_STD
,HZ
/2))
1831 case ACTION_STD_PREV
:
1836 case ACTION_STD_NEXT
:
1841 case ACTION_STD_CANCEL
:
1842 viewportmanager_set_statusbar(true);
1846 viewportmanager_set_statusbar(true);
1850 #endif /* HAVE_LCD_BITMAP */
1854 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1856 #if (CONFIG_STORAGE & STORAGE_MMC)
1857 #define CARDTYPE "MMC"
1858 #elif (CONFIG_STORAGE & STORAGE_SD)
1859 #define CARDTYPE "microSD"
1862 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1865 int *cardnum
= (int*)lists
->data
;
1866 unsigned char card_name
[7];
1867 unsigned char pbuf
[32];
1868 char *title
= lists
->title
;
1869 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1870 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1871 static const unsigned char *kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1872 static const unsigned char *nsec_units
[] = { "ns", "µs", "ms" };
1873 static const char *spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1874 "3.1-3.31", "4.0" };
1875 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1878 if (btn
== ACTION_STD_OK
)
1880 *cardnum
^= 0x1; /* change cards */
1884 simplelist_set_line_count(0);
1886 card
= card_get_info(*cardnum
);
1888 if (card
->initialized
> 0)
1890 card_name
[6] = '\0';
1891 strncpy(card_name
, ((unsigned char*)card
->cid
) + 3, 6);
1892 simplelist_addline(SIMPLELIST_ADD_LINE
,
1893 "%s Rev %d.%d", card_name
,
1894 (int) card_extract_bits(card
->cid
, 72, 4),
1895 (int) card_extract_bits(card
->cid
, 76, 4));
1896 simplelist_addline(SIMPLELIST_ADD_LINE
,
1898 (int) card_extract_bits(card
->cid
, 112, 4),
1899 (int) card_extract_bits(card
->cid
, 116, 4) + 1997);
1900 simplelist_addline(SIMPLELIST_ADD_LINE
,
1902 card_extract_bits(card
->cid
, 80, 32));
1903 simplelist_addline(SIMPLELIST_ADD_LINE
,
1905 (int) card_extract_bits(card
->cid
, 0, 8),
1906 (int) card_extract_bits(card
->cid
, 8, 16));
1907 int temp
= card_extract_bits(card
->csd
, 2, 4);
1908 simplelist_addline(SIMPLELIST_ADD_LINE
,
1909 CARDTYPE
" v%s", temp
< 5 ?
1910 spec_vers
[temp
] : "?.?");
1911 simplelist_addline(SIMPLELIST_ADD_LINE
,
1912 "Blocks: 0x%08lx", card
->numblocks
);
1913 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1915 simplelist_addline(SIMPLELIST_ADD_LINE
,
1917 output_dyn_value(pbuf
, sizeof pbuf
, card
->tsac
,
1919 simplelist_addline(SIMPLELIST_ADD_LINE
,
1921 simplelist_addline(SIMPLELIST_ADD_LINE
,
1922 "Nsac: %d clk", card
->nsac
);
1923 simplelist_addline(SIMPLELIST_ADD_LINE
,
1924 "R2W: *%d", card
->r2w_factor
);
1925 simplelist_addline(SIMPLELIST_ADD_LINE
,
1927 i_vmin
[card_extract_bits(card
->csd
, 66, 3)],
1928 i_vmax
[card_extract_bits(card
->csd
, 69, 3)]);
1929 simplelist_addline(SIMPLELIST_ADD_LINE
,
1931 i_vmin
[card_extract_bits(card
->csd
, 72, 3)],
1932 i_vmax
[card_extract_bits(card
->csd
, 75, 3)]);
1934 else if (card
->initialized
== 0)
1936 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1938 #if (CONFIG_STORAGE & STORAGE_SD)
1939 else /* card->initialized < 0 */
1941 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1944 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1945 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1946 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1947 gui_synclist_select_item(lists
, 0);
1948 btn
= ACTION_REDRAW
;
1952 #elif (CONFIG_STORAGE & STORAGE_ATA)
1953 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1958 unsigned short* identify_info
= ata_get_identify();
1959 bool timing_info_present
= false;
1962 simplelist_set_line_count(0);
1964 for (i
=0; i
< 20; i
++)
1965 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1967 /* kill trailing space */
1968 for (i
=39; i
&& buf
[i
]==' '; i
--)
1970 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1971 for (i
=0; i
< 4; i
++)
1972 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1974 simplelist_addline(SIMPLELIST_ADD_LINE
,
1975 "Firmware: %s", buf
);
1976 snprintf(buf
, sizeof buf
, "%ld MB",
1977 ((unsigned long)identify_info
[61] << 16 |
1978 (unsigned long)identify_info
[60]) / 2048 );
1979 simplelist_addline(SIMPLELIST_ADD_LINE
,
1982 fat_size( IF_MV2(0,) NULL
, &free
);
1983 simplelist_addline(SIMPLELIST_ADD_LINE
,
1984 "Free: %ld MB", free
/ 1024);
1985 simplelist_addline(SIMPLELIST_ADD_LINE
,
1986 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1987 i
= identify_info
[83] & (1<<3);
1988 simplelist_addline(SIMPLELIST_ADD_LINE
,
1989 "Power mgmt: %s", i
? "enabled" : "unsupported");
1990 i
= identify_info
[83] & (1<<9);
1991 simplelist_addline(SIMPLELIST_ADD_LINE
,
1992 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1993 i
= identify_info
[82] & (1<<6);
1994 simplelist_addline(SIMPLELIST_ADD_LINE
,
1995 "Read-ahead: %s", i
? "enabled" : "unsupported");
1996 timing_info_present
= identify_info
[53] & (1<<1);
1997 if(timing_info_present
) {
1998 char pio3
[2], pio4
[2];pio3
[1] = 0;
2000 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
2001 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
2002 simplelist_addline(SIMPLELIST_ADD_LINE
,
2003 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
2006 simplelist_addline(SIMPLELIST_ADD_LINE
,
2007 "No PIO mode info");
2009 timing_info_present
= identify_info
[53] & (1<<1);
2010 if(timing_info_present
) {
2011 simplelist_addline(SIMPLELIST_ADD_LINE
,
2012 "Cycle times %dns/%dns",
2014 identify_info
[68] );
2016 simplelist_addline(SIMPLELIST_ADD_LINE
,
2019 #if defined (TOSHIBA_GIGABEAT_F) || defined (TOSHIBA_GIGABEAT_S)
2020 if (identify_info
[63] & (1<<0)) {
2021 char mdma0
[2], mdma1
[2], mdma2
[2];
2022 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
2023 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
2024 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
2025 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
2026 simplelist_addline(SIMPLELIST_ADD_LINE
,
2027 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
2028 simplelist_addline(SIMPLELIST_ADD_LINE
,
2029 "MDMA Cycle times %dns/%dns",
2031 identify_info
[66] );
2034 simplelist_addline(SIMPLELIST_ADD_LINE
,
2035 "No MDMA mode info");
2037 if (identify_info
[88] & (1<<0)) {
2038 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2];
2039 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = 0;
2040 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
2041 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
2042 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
2043 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
2044 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
2045 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
2046 simplelist_addline(SIMPLELIST_ADD_LINE
,
2047 "UDMA modes: %s %s %s %s %s %s", udma0
, udma1
, udma2
,
2048 udma3
, udma4
, udma5
);
2051 simplelist_addline(SIMPLELIST_ADD_LINE
,
2052 "No UDMA mode info");
2054 #endif /* defined (TOSHIBA_GIGABEAT_F) || defined (TOSHIBA_GIGABEAT_S) */
2055 timing_info_present
= identify_info
[53] & (1<<1);
2056 if(timing_info_present
) {
2057 i
= identify_info
[49] & (1<<11);
2058 simplelist_addline(SIMPLELIST_ADD_LINE
,
2059 "IORDY support: %s", i
? "yes" : "no");
2060 i
= identify_info
[49] & (1<<10);
2061 simplelist_addline(SIMPLELIST_ADD_LINE
,
2062 "IORDY disable: %s", i
? "yes" : "no");
2064 simplelist_addline(SIMPLELIST_ADD_LINE
,
2067 simplelist_addline(SIMPLELIST_ADD_LINE
,
2068 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2071 #else /* No SD, MMC or ATA */
2072 static int disk_callback(int btn
, struct gui_synclist
*lists
)
2076 struct storage_info info
;
2077 storage_get_info(0,&info
);
2078 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
2079 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
2080 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
2081 simplelist_addline(SIMPLELIST_ADD_LINE
,
2082 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
2084 fat_size( IF_MV2(0,) NULL
, &free
);
2085 simplelist_addline(SIMPLELIST_ADD_LINE
,
2086 "Free: %ld MB", free
/ 1024);
2087 simplelist_addline(SIMPLELIST_ADD_LINE
,
2088 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
2093 #if (CONFIG_STORAGE & STORAGE_ATA)
2094 static bool dbg_identify_info(void)
2096 int fd
= creat("/identify_info.bin");
2099 #ifdef ROCKBOX_LITTLE_ENDIAN
2100 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
2102 write(fd
, ata_get_identify(), SECTOR_SIZE
);
2110 static bool dbg_disk_info(void)
2112 struct simplelist_info info
;
2113 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
2114 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
2117 info
.callback_data
= (void*)&card
;
2120 info
.action_callback
= disk_callback
;
2121 info
.hide_selection
= true;
2122 info
.scroll_all
= true;
2123 return simplelist_show_list(&info
);
2125 #endif /* !SIMULATOR */
2127 #ifdef HAVE_DIRCACHE
2128 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
2130 (void)btn
; (void)lists
;
2131 simplelist_set_line_count(0);
2132 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
2133 dircache_is_enabled() ? "Yes" : "No");
2134 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
2135 dircache_get_cache_size());
2136 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
2137 global_status
.dircache_size
);
2138 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
2140 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
2141 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
2142 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
2143 dircache_get_build_ticks() / HZ
);
2144 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
2145 dircache_get_entry_count());
2149 static bool dbg_dircache_info(void)
2151 struct simplelist_info info
;
2152 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
2153 info
.action_callback
= dircache_callback
;
2154 info
.hide_selection
= true;
2155 info
.scroll_all
= true;
2156 return simplelist_show_list(&info
);
2159 #endif /* HAVE_DIRCACHE */
2161 #ifdef HAVE_TAGCACHE
2162 static int database_callback(int btn
, struct gui_synclist
*lists
)
2165 struct tagcache_stat
*stat
= tagcache_get_stat();
2166 static bool synced
= false;
2168 simplelist_set_line_count(0);
2170 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
2171 stat
->initialized
? "Yes" : "No");
2172 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
2173 stat
->ready
? "Yes" : "No");
2174 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
2175 stat
->ramcache
? "Yes" : "No");
2176 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
2177 stat
->ramcache_used
, stat
->ramcache_allocated
);
2178 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
2179 stat
->progress
, stat
->processed_entries
);
2180 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
2181 stat
->curentry
? stat
->curentry
: "---");
2182 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
2184 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
2185 stat
->commit_delayed
? "Yes" : "No");
2187 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
2188 stat
->queue_length
);
2193 tagcache_screensync_event();
2196 if (!btn
&& stat
->curentry
)
2199 return ACTION_REDRAW
;
2202 if (btn
== ACTION_STD_CANCEL
)
2203 tagcache_screensync_enable(false);
2207 static bool dbg_tagcache_info(void)
2209 struct simplelist_info info
;
2210 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2211 info
.action_callback
= database_callback
;
2212 info
.hide_selection
= true;
2213 info
.scroll_all
= true;
2215 /* Don't do nonblock here, must give enough processing time
2216 for tagcache thread. */
2217 /* info.timeout = TIMEOUT_NOBLOCK; */
2219 tagcache_screensync_enable(true);
2220 return simplelist_show_list(&info
);
2224 #if CONFIG_CPU == SH7034
2225 static bool dbg_save_roms(void)
2228 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2230 fd
= creat("/internal_rom_0000-FFFF.bin");
2233 write(fd
, (void *)0, 0x10000);
2237 fd
= creat("/internal_rom_2000000-203FFFF.bin");
2240 write(fd
, (void *)0x2000000, 0x40000);
2244 system_memory_guard(oldmode
);
2247 #elif defined CPU_COLDFIRE
2248 static bool dbg_save_roms(void)
2251 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2253 #if defined(IRIVER_H100_SERIES)
2254 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2255 #elif defined(IRIVER_H300_SERIES)
2256 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2257 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2258 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2262 write(fd
, (void *)0, FLASH_SIZE
);
2265 system_memory_guard(oldmode
);
2268 fd
= creat("/internal_eeprom.bin");
2272 char buf
[EEPROM_SIZE
];
2275 old_irq_level
= disable_irq_save();
2277 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2279 restore_irq(old_irq_level
);
2282 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
2285 write(fd
, buf
, sizeof buf
);
2294 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
2295 static bool dbg_save_roms(void)
2299 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2302 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2312 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2315 if (btn
== ACTION_STD_CANCEL
)
2317 simplelist_set_line_count(1);
2319 #if (CONFIG_TUNER & LV24020LP)
2320 simplelist_addline(SIMPLELIST_ADD_LINE
,
2321 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2322 simplelist_addline(SIMPLELIST_ADD_LINE
,
2323 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2324 simplelist_addline(SIMPLELIST_ADD_LINE
,
2325 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2326 simplelist_addline(SIMPLELIST_ADD_LINE
,
2327 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2328 simplelist_addline(SIMPLELIST_ADD_LINE
,
2329 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2330 simplelist_addline(SIMPLELIST_ADD_LINE
,
2331 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2332 simplelist_addline(SIMPLELIST_ADD_LINE
,
2333 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2334 #endif /* LV24020LP */
2335 #if (CONFIG_TUNER & S1A0903X01)
2336 simplelist_addline(SIMPLELIST_ADD_LINE
,
2337 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2338 /* This one doesn't return dynamic data atm */
2339 #endif /* S1A0903X01 */
2340 #if (CONFIG_TUNER & TEA5767)
2341 struct tea5767_dbg_info nfo
;
2342 tea5767_dbg_info(&nfo
);
2343 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2344 simplelist_addline(SIMPLELIST_ADD_LINE
,
2345 " Read: %02X %02X %02X %02X %02X",
2346 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2347 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2348 (unsigned)nfo
.read_regs
[4]);
2349 simplelist_addline(SIMPLELIST_ADD_LINE
,
2350 " Write: %02X %02X %02X %02X %02X",
2351 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2352 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2353 (unsigned)nfo
.write_regs
[4]);
2354 #endif /* TEA5767 */
2355 #if (CONFIG_TUNER & SI4700)
2356 struct si4700_dbg_info nfo
;
2357 si4700_dbg_info(&nfo
);
2358 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
2360 simplelist_addline(SIMPLELIST_ADD_LINE
,
2361 "%04X %04X %04X %04X",
2362 (unsigned)nfo
.regs
[0], (unsigned)nfo
.regs
[1],
2363 (unsigned)nfo
.regs
[2], (unsigned)nfo
.regs
[3]);
2364 simplelist_addline(SIMPLELIST_ADD_LINE
,
2365 "%04X %04X %04X %04X",
2366 (unsigned)nfo
.regs
[4], (unsigned)nfo
.regs
[5],
2367 (unsigned)nfo
.regs
[6], (unsigned)nfo
.regs
[7]);
2368 simplelist_addline(SIMPLELIST_ADD_LINE
,
2369 "%04X %04X %04X %04X",
2370 (unsigned)nfo
.regs
[8], (unsigned)nfo
.regs
[9],
2371 (unsigned)nfo
.regs
[10], (unsigned)nfo
.regs
[11]);
2372 simplelist_addline(SIMPLELIST_ADD_LINE
,
2373 "%04X %04X %04X %04X",
2374 (unsigned)nfo
.regs
[12], (unsigned)nfo
.regs
[13],
2375 (unsigned)nfo
.regs
[14], (unsigned)nfo
.regs
[15]);
2377 return ACTION_REDRAW
;
2379 static bool dbg_fm_radio(void)
2381 struct simplelist_info info
;
2382 info
.scroll_all
= true;
2383 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2384 simplelist_set_line_count(0);
2385 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2386 radio_hardware_present() ? "yes" : "no");
2388 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2389 info
.hide_selection
= true;
2390 return simplelist_show_list(&info
);
2392 #endif /* CONFIG_TUNER */
2393 #endif /* !SIMULATOR */
2395 #ifdef HAVE_LCD_BITMAP
2396 extern bool do_screendump_instead_of_usb
;
2398 static bool dbg_screendump(void)
2400 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2401 splashf(HZ
, "Screendump %s",
2402 do_screendump_instead_of_usb
?"enabled":"disabled");
2405 #endif /* HAVE_LCD_BITMAP */
2407 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2408 static bool dbg_set_memory_guard(void)
2410 static const struct opt_items names
[MAXMEMGUARD
] = {
2412 { "Flash ROM writes", -1 },
2413 { "Zero area (all)", -1 }
2415 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2417 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2418 system_memory_guard(mode
);
2422 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2424 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2425 static bool dbg_write_eeprom(void)
2430 char buf
[EEPROM_SIZE
];
2433 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2437 rc
= read(fd
, buf
, EEPROM_SIZE
);
2439 if(rc
== EEPROM_SIZE
)
2441 old_irq_level
= disable_irq_save();
2443 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2445 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
2447 splash(HZ
*3, "Eeprom written successfully");
2449 restore_irq(old_irq_level
);
2453 splashf(HZ
*3, "File read error (%d)",rc
);
2459 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2464 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2465 #ifdef CPU_BOOST_LOGGING
2466 static bool cpu_boost_log(void)
2469 int count
= cpu_boost_log_getcount();
2470 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2473 lcd_setfont(FONT_SYSFIXED
);
2474 str
= cpu_boost_log_getlog_first();
2475 viewportmanager_set_statusbar(false);
2478 lcd_clear_display();
2479 for(j
=0; j
<lines
; j
++,i
++)
2482 str
= cpu_boost_log_getlog_next();
2493 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2496 case ACTION_STD_PREV
:
2497 case ACTION_STD_NEXT
:
2500 case ACTION_STD_CANCEL
:
2507 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2508 lcd_setfont(FONT_UI
);
2509 viewportmanager_set_statusbar(true);
2514 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2515 extern bool wheel_is_touched
;
2516 extern int old_wheel_value
;
2517 extern int new_wheel_value
;
2518 extern int wheel_delta
;
2519 extern unsigned int accumulated_wheel_delta
;
2520 extern unsigned int wheel_velocity
;
2522 static bool dbg_scrollwheel(void)
2527 lcd_setfont(FONT_SYSFIXED
);
2528 viewportmanager_set_statusbar(false);
2532 if (action_userabort(HZ
/10))
2535 lcd_clear_display();
2537 /* show internal variables of scrollwheel driver */
2538 snprintf(buf
, sizeof(buf
), "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2539 lcd_puts(0, 0, buf
);
2540 snprintf(buf
, sizeof(buf
), "new position: %2d", new_wheel_value
);
2541 lcd_puts(0, 1, buf
);
2542 snprintf(buf
, sizeof(buf
), "old position: %2d", old_wheel_value
);
2543 lcd_puts(0, 2, buf
);
2544 snprintf(buf
, sizeof(buf
), "wheel delta: %2d", wheel_delta
);
2545 lcd_puts(0, 3, buf
);
2546 snprintf(buf
, sizeof(buf
), "accumulated delta: %2d", accumulated_wheel_delta
);
2547 lcd_puts(0, 4, buf
);
2548 snprintf(buf
, sizeof(buf
), "velo [deg/s]: %4d", (int)wheel_velocity
);
2549 lcd_puts(0, 5, buf
);
2551 /* show effective accelerated scrollspeed */
2552 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2553 snprintf(buf
, sizeof(buf
), "accel. speed: %4d", speed
);
2554 lcd_puts(0, 6, buf
);
2558 viewportmanager_set_statusbar(true);
2563 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2564 static bool logf_usb_serial(void)
2566 bool serial_enabled
= !usb_core_driver_enabled(USB_DRIVER_SERIAL
);
2567 usb_core_enable_driver(USB_DRIVER_SERIAL
,serial_enabled
);
2568 splashf(HZ
, "USB logf %s",
2569 serial_enabled
?"enabled":"disabled");
2574 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2575 static bool usb_reconnect(void)
2577 splash(HZ
, "Reconnect mass storage");
2578 usb_storage_reconnect();
2583 #if CONFIG_USBOTG == USBOTG_ISP1583
2584 extern int dbg_usb_num_items(void);
2585 extern char* dbg_usb_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2587 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2590 if (action
== ACTION_NONE
)
2591 action
= ACTION_REDRAW
;
2595 static bool dbg_isp1583(void)
2597 struct simplelist_info isp1583
;
2598 isp1583
.scroll_all
= true;
2599 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2600 isp1583
.timeout
= HZ
/100;
2601 isp1583
.hide_selection
= true;
2602 isp1583
.get_name
= dbg_usb_item
;
2603 isp1583
.action_callback
= isp1583_action_callback
;
2604 return simplelist_show_list(&isp1583
);
2608 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2609 extern int pic_dbg_num_items(void);
2610 extern char* pic_dbg_item(int selected_item
, void *data
, char *buffer
, size_t buffer_len
);
2612 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2615 if (action
== ACTION_NONE
)
2616 action
= ACTION_REDRAW
;
2620 static bool dbg_pic(void)
2622 struct simplelist_info pic
;
2623 pic
.scroll_all
= true;
2624 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2625 pic
.timeout
= HZ
/100;
2626 pic
.hide_selection
= true;
2627 pic
.get_name
= pic_dbg_item
;
2628 pic
.action_callback
= pic_action_callback
;
2629 return simplelist_show_list(&pic
);
2634 /****** The menu *********/
2635 struct the_menu_item
{
2636 unsigned char *desc
; /* string or ID */
2637 bool (*function
) (void); /* return true if USB was connected */
2639 static const struct the_menu_item menuitems
[] = {
2640 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2641 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD))
2642 { "Dump ROM contents", dbg_save_roms
},
2644 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2645 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L
2646 { "View I/O ports", dbg_ports
},
2648 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2649 { "View PCF registers", dbg_pcf
},
2651 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2652 { "TSC2100 debug", tsc2100_debug
},
2654 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2655 { "CPU frequency", dbg_cpufreq
},
2657 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2658 { "S/PDIF analyzer", dbg_spdif
},
2660 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2661 { "Catch mem accesses", dbg_set_memory_guard
},
2663 { "View OS stacks", dbg_os
},
2664 #ifdef HAVE_LCD_BITMAP
2666 { "View battery", view_battery
},
2668 { "Screendump", dbg_screendump
},
2671 { "View HW info", dbg_hw_info
},
2674 { "View partitions", dbg_partitions
},
2677 { "View disk info", dbg_disk_info
},
2678 #if (CONFIG_STORAGE & STORAGE_ATA)
2679 { "Dump ATA identify info", dbg_identify_info
},
2682 #ifdef HAVE_DIRCACHE
2683 { "View dircache info", dbg_dircache_info
},
2685 #ifdef HAVE_TAGCACHE
2686 { "View database info", dbg_tagcache_info
},
2688 #ifdef HAVE_LCD_BITMAP
2689 #if CONFIG_CODEC == SWCODEC
2690 { "View buffering thread", dbg_buffering_thread
},
2691 #elif !defined(SIMULATOR)
2692 { "View audio thread", dbg_audio_thread
},
2695 { "pm histogram", peak_meter_histogram
},
2696 #endif /* PM_DEBUG */
2697 #endif /* HAVE_LCD_BITMAP */
2700 { "FM Radio", dbg_fm_radio
},
2703 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2704 { "Write back EEPROM", dbg_write_eeprom
},
2706 #if CONFIG_USBOTG == USBOTG_ISP1583
2707 { "View ISP1583 info", dbg_isp1583
},
2709 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2710 { "View PIC info", dbg_pic
},
2712 #ifdef ROCKBOX_HAS_LOGF
2713 {"logf", logfdisplay
},
2714 {"logfdump", logfdump
},
2716 #if defined(HAVE_USBSTACK) && defined(ROCKBOX_HAS_LOGF) && defined(USB_SERIAL)
2717 {"logf over usb",logf_usb_serial
},
2719 #if defined(HAVE_USBSTACK) && defined(USB_STORAGE)
2720 {"reconnect usb storage",usb_reconnect
},
2722 #ifdef CPU_BOOST_LOGGING
2723 {"cpu_boost log",cpu_boost_log
},
2725 #if (defined(HAVE_SCROLLWHEEL) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2726 {"Debug scrollwheel", dbg_scrollwheel
},
2729 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2731 if (btn
== ACTION_STD_OK
)
2733 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2734 btn
= ACTION_REDRAW
;
2738 static char* dbg_menu_getname(int item
, void * data
,
2739 char *buffer
, size_t buffer_len
)
2741 (void)data
; (void)buffer
; (void)buffer_len
;
2742 return menuitems
[item
].desc
;
2744 bool debug_menu(void)
2746 struct simplelist_info info
;
2748 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2749 info
.action_callback
= menu_action_callback
;
2750 info
.get_name
= dbg_menu_getname
;
2752 return simplelist_show_list(&info
);