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"
103 #include "appevents.h"
105 #if CONFIG_CPU == DM320 || CONFIG_CPU == S3C2440 || CONFIG_CPU == TCC7801 \
106 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 || CONFIG_CPU == JZ4732 \
107 || defined(CPU_S5L870X)
108 #include "debug-target.h"
111 #if defined(SANSA_E200) || defined(SANSA_C200) || defined(PHILIPS_SA9200) \
112 || defined(SANSA_CLIP) || defined(SANSA_FUZE)
118 #include "pmu-target.h"
122 #include "usb_core.h"
125 /* wrapper function to format a string and print it */
126 void debug_printf(int y
, const unsigned char *fmt
, ...)
131 vsnprintf(buf
, sizeof (buf
), fmt
, ap
);
136 /*---------------------------------------------------*/
137 /* SPECIAL DEBUG STUFF */
138 /*---------------------------------------------------*/
139 extern struct thread_entry threads
[MAXTHREADS
];
141 static char thread_status_char(unsigned status
)
143 static const char thread_status_chars
[THREAD_NUM_STATES
+1] =
145 [0 ... THREAD_NUM_STATES
] = '?',
146 [STATE_RUNNING
] = 'R',
147 [STATE_BLOCKED
] = 'B',
148 [STATE_SLEEPING
] = 'S',
149 [STATE_BLOCKED_W_TMO
] = 'T',
150 [STATE_FROZEN
] = 'F',
151 [STATE_KILLED
] = 'K',
154 if (status
> THREAD_NUM_STATES
)
155 status
= THREAD_NUM_STATES
;
157 return thread_status_chars
[status
];
160 static const char* threads_getname(int selected_item
, void *data
,
161 char *buffer
, size_t buffer_len
)
164 struct thread_entry
*thread
;
168 if (selected_item
< (int)NUM_CORES
)
170 snprintf(buffer
, buffer_len
, "Idle (%d): %2d%%", selected_item
,
171 idle_stack_usage(selected_item
));
175 selected_item
-= NUM_CORES
;
178 thread
= &threads
[selected_item
];
180 if (thread
->state
== STATE_KILLED
)
182 snprintf(buffer
, buffer_len
, "%2d: ---", selected_item
);
186 thread_get_name(name
, 32, thread
);
188 snprintf(buffer
, buffer_len
,
189 "%2d: " IF_COP("(%d) ") "%c%c " IF_PRIO("%d %d ") "%2d%% %s",
191 IF_COP(thread
->core
,)
192 #ifdef HAVE_SCHEDULER_BOOSTCTRL
193 (thread
->cpu_boost
) ? '+' :
195 ((thread
->state
== STATE_RUNNING
) ? '*' : ' '),
196 thread_status_char(thread
->state
),
197 IF_PRIO(thread
->base_priority
, thread
->priority
, )
198 thread_stack_usage(thread
), name
);
203 static int dbg_threads_action_callback(int action
, struct gui_synclist
*lists
)
206 #ifdef ROCKBOX_HAS_LOGF
207 if (action
== ACTION_STD_OK
)
209 int selpos
= gui_synclist_get_sel_pos(lists
);
211 if (selpos
>= NUM_CORES
)
212 remove_thread(threads
[selpos
- NUM_CORES
].id
);
214 remove_thread(threads
[selpos
].id
);
216 return ACTION_REDRAW
;
218 #endif /* ROCKBOX_HAS_LOGF */
219 if (action
== ACTION_NONE
)
220 action
= ACTION_REDRAW
;
224 static bool dbg_os(void)
226 struct simplelist_info info
;
227 simplelist_info_init(&info
, IF_COP("Core and ") "Stack usage:",
231 MAXTHREADS
+NUM_CORES
,
234 #ifndef ROCKBOX_HAS_LOGF
235 info
.hide_selection
= true;
236 info
.scroll_all
= true;
238 info
.action_callback
= dbg_threads_action_callback
;
239 info
.get_name
= threads_getname
;
240 return simplelist_show_list(&info
);
243 #ifdef HAVE_LCD_BITMAP
244 #if CONFIG_CODEC != SWCODEC
246 static bool dbg_audio_thread(void)
248 struct audio_debug d
;
250 lcd_setfont(FONT_SYSFIXED
);
254 if (action_userabort(HZ
/5))
257 audio_get_debugdata(&d
);
261 debug_printf(0, "read: %x", d
.audiobuf_read
);
262 debug_printf(1, "write: %x", d
.audiobuf_write
);
263 debug_printf(2, "swap: %x", d
.audiobuf_swapwrite
);
264 debug_printf(3, "playing: %d", d
.playing
);
265 debug_printf(4, "playable: %x", d
.playable_space
);
266 debug_printf(5, "unswapped: %x", d
.unswapped_space
);
268 /* Playable space left */
269 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8, 112, 4, d
.audiobuflen
, 0,
270 d
.playable_space
, HORIZONTAL
);
272 /* Show the watermark limit */
273 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, 6*8+4, 112, 4, d
.audiobuflen
, 0,
274 d
.low_watermark_level
, HORIZONTAL
);
276 debug_printf(7, "wm: %x - %x",
277 d
.low_watermark_level
, d
.lowest_watermark_level
);
281 lcd_setfont(FONT_UI
);
284 #endif /* !SIMULATOR */
285 #else /* CONFIG_CODEC == SWCODEC */
286 extern size_t filebuflen
;
287 /* This is a size_t, but call it a long so it puts a - when it's bad. */
289 static unsigned int ticks
, boost_ticks
, freq_sum
;
291 static void dbg_audio_task(void)
294 if(FREQ
> CPUFREQ_NORMAL
)
296 freq_sum
+= FREQ
/1000000; /* in MHz */
301 static bool dbg_buffering_thread(void)
307 size_t bufsize
= pcmbuf_get_bufsize();
308 int pcmbufdescs
= pcmbuf_descs();
309 struct buffering_debug d
;
311 ticks
= boost_ticks
= freq_sum
= 0;
313 tick_add_task(dbg_audio_task
);
315 lcd_setfont(FONT_SYSFIXED
);
318 button
= get_action(CONTEXT_STD
,HZ
/5);
321 case ACTION_STD_NEXT
:
324 case ACTION_STD_PREV
:
327 case ACTION_STD_CANCEL
:
332 buffering_get_debugdata(&d
);
337 bufused
= bufsize
- pcmbuf_free();
339 debug_printf(line
++, "pcm: %6ld/%ld", (long) bufused
, (long) bufsize
);
341 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
342 bufsize
, 0, bufused
, HORIZONTAL
);
345 debug_printf(line
++, "alloc: %6ld/%ld", audio_filebufused(),
349 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
350 filebuflen
, 0, audio_filebufused(), HORIZONTAL
);
353 debug_printf(line
++, "real: %6ld/%ld", (long)d
.buffered_data
,
356 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
357 filebuflen
, 0, (long)d
.buffered_data
, HORIZONTAL
);
361 debug_printf(line
++, "usefl: %6ld/%ld", (long)(d
.useful_data
),
365 gui_scrollbar_draw(&screens
[SCREEN_MAIN
],0, line
*8, LCD_WIDTH
, 6,
366 filebuflen
, 0, d
.useful_data
, HORIZONTAL
);
370 debug_printf(line
++, "data_rem: %ld", (long)d
.data_rem
);
372 debug_printf(line
++, "track count: %2d", audio_track_count());
374 debug_printf(line
++, "handle count: %d", (int)d
.num_handles
);
377 debug_printf(line
++, "cpu freq: %3dMHz",
378 (int)((FREQ
+ 500000) / 1000000));
383 int boostquota
= boost_ticks
* 1000 / ticks
; /* in 0.1 % */
384 int avgclock
= freq_sum
* 10 / ticks
; /* in 100 kHz */
385 debug_printf(line
++, "boost:%3d.%d%% (%d.%dMHz)",
386 boostquota
/10, boostquota
%10, avgclock
/10, avgclock
%10);
389 debug_printf(line
++, "pcmbufdesc: %2d/%2d",
390 pcmbuf_used_descs(), pcmbufdescs
);
391 debug_printf(line
++, "watermark: %6d",
397 tick_remove_task(dbg_audio_task
);
398 lcd_setfont(FONT_UI
);
402 #endif /* CONFIG_CODEC */
403 #endif /* HAVE_LCD_BITMAP */
406 #if (CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE))
407 /* Tool function to read the flash manufacturer and type, if available.
408 Only chips which could be reprogrammed in system will return values.
409 (The mode switch addresses vary between flash manufacturers, hence addr1/2) */
410 /* In IRAM to avoid problems when running directly from Flash */
411 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
412 unsigned addr1
, unsigned addr2
)
413 ICODE_ATTR
__attribute__((noinline
));
414 static bool dbg_flash_id(unsigned* p_manufacturer
, unsigned* p_device
,
415 unsigned addr1
, unsigned addr2
)
418 unsigned not_manu
, not_id
; /* read values before switching to ID mode */
419 unsigned manu
, id
; /* read values when in ID mode */
421 #if CONFIG_CPU == SH7034
422 volatile unsigned char* flash
= (unsigned char*)0x2000000; /* flash mapping */
423 #elif defined(CPU_COLDFIRE)
424 volatile unsigned short* flash
= (unsigned short*)0; /* flash mapping */
426 int old_level
; /* saved interrupt level */
428 not_manu
= flash
[0]; /* read the normal content */
429 not_id
= flash
[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */
431 /* disable interrupts, prevent any stray flash access */
432 old_level
= disable_irq_save();
434 flash
[addr1
] = 0xAA; /* enter command mode */
436 flash
[addr1
] = 0x90; /* ID command */
437 /* Atmel wants 20ms pause here */
438 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
440 manu
= flash
[0]; /* read the IDs */
443 flash
[0] = 0xF0; /* reset flash (back to normal read mode) */
444 /* Atmel wants 20ms pause here */
445 /* sleep(HZ/50); no sleeping possible while interrupts are disabled */
447 restore_irq(old_level
); /* enable interrupts again */
449 /* I assume success if the obtained values are different from
450 the normal flash content. This is not perfectly bulletproof, they
451 could theoretically be the same by chance, causing us to fail. */
452 if (not_manu
!= manu
|| not_id
!= id
) /* a value has changed */
454 *p_manufacturer
= manu
; /* return the results */
456 return true; /* success */
458 return false; /* fail */
460 #endif /* (CONFIG_CPU == SH7034 || CPU_COLDFIRE) */
464 static int perfcheck(void)
470 "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */
473 "ldr r0, [%[timr]] \n"
474 "add r0, r0, %[tmo] \n"
476 "add %[res], %[res], #1 \n"
477 "ldr r1, [%[timr]] \n"
480 "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */
484 [timr
]"r"(&USEC_TIMER
),
486 #if CONFIG_CPU == PP5002
488 #else /* PP5020/5022/5024 */
499 #ifdef HAVE_LCD_BITMAP
500 static bool dbg_hw_info(void)
502 #if CONFIG_CPU == SH7034
503 int bitmask
= HW_MASK
;
504 int rom_version
= ROM_VERSION
;
505 unsigned manu
, id
; /* flash IDs */
506 bool got_id
; /* flag if we managed to get the flash IDs */
507 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
508 bool has_bootrom
; /* flag for boot ROM present */
509 int oldmode
; /* saved memory guard mode */
511 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
513 /* get flash ROM type */
514 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
516 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
518 /* check if the boot ROM area is a flash mirror */
519 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
520 if (has_bootrom
) /* if ROM and Flash different */
522 /* calculate CRC16 checksum of boot ROM */
523 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
526 system_memory_guard(oldmode
); /* re-enable memory guard */
528 lcd_setfont(FONT_SYSFIXED
);
531 lcd_puts(0, 0, "[Hardware info]");
533 debug_printf(1, "ROM: %d.%02d", rom_version
/100, rom_version
%100);
535 debug_printf(2, "Mask: 0x%04x", bitmask
);
538 debug_printf(3, "Flash: M=%02x D=%02x", manu
, id
);
540 lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */
544 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
545 lcd_puts(0, 4, "Boot ROM: V1");
547 debug_printf(4, "ROMcrc: 0x%08x", rom_crc
);
551 lcd_puts(0, 4, "Boot ROM: none");
556 while (!(action_userabort(TIMEOUT_BLOCK
)));
558 #elif CONFIG_CPU == MCF5249 || CONFIG_CPU == MCF5250
559 unsigned manu
, id
; /* flash IDs */
560 int got_id
; /* flag if we managed to get the flash IDs */
561 int oldmode
; /* saved memory guard mode */
564 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
566 /* get flash ROM type */
567 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
569 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
571 system_memory_guard(oldmode
); /* re-enable memory guard */
573 lcd_setfont(FONT_SYSFIXED
);
576 lcd_puts(0, line
++, "[Hardware info]");
579 debug_printf(line
++, "Flash: M=%04x D=%04x", manu
, id
);
581 lcd_puts(0, line
++, "Flash: M=???? D=????"); /* unknown, sorry */
587 lcd_puts(0, ++line
, "Serial Number:");
589 got_id
= ds2411_read_id(&id
);
591 if (got_id
== DS2411_OK
)
593 debug_printf(++line
, " FC=%02x", (unsigned)id
.family_code
);
594 debug_printf(++line
, " ID=%02X %02X %02X %02X %02X %02X",
595 (unsigned)id
.uid
[0], (unsigned)id
.uid
[1], (unsigned)id
.uid
[2],
596 (unsigned)id
.uid
[3], (unsigned)id
.uid
[4], (unsigned)id
.uid
[5]);
597 debug_printf(++line
, " CRC=%02X", (unsigned)id
.crc
);
601 debug_printf(++line
, "READ ERR=%d", got_id
);
608 while (!(action_userabort(TIMEOUT_BLOCK
)));
610 #elif defined(CPU_PP502x)
612 char pp_version
[] = { (PP_VER2
>> 24) & 0xff, (PP_VER2
>> 16) & 0xff,
613 (PP_VER2
>> 8) & 0xff, (PP_VER2
) & 0xff,
614 (PP_VER1
>> 24) & 0xff, (PP_VER1
>> 16) & 0xff,
615 (PP_VER1
>> 8) & 0xff, (PP_VER1
) & 0xff, '\0' };
617 lcd_setfont(FONT_SYSFIXED
);
620 lcd_puts(0, line
++, "[Hardware info]");
623 debug_printf(line
++, "HW rev: 0x%08lx", IPOD_HW_REVISION
);
627 extern int lcd_type
; /* Defined in lcd-colornano.c */
629 debug_printf(line
++, "LCD type: %d", lcd_type
);
632 debug_printf(line
++, "PP version: %s", pp_version
);
634 debug_printf(line
++, "Est. clock (kHz): %d", perfcheck());
638 while (!(action_userabort(TIMEOUT_BLOCK
)));
640 #elif CONFIG_CPU == PP5002
642 char pp_version
[] = { (PP_VER4
>> 8) & 0xff, PP_VER4
& 0xff,
643 (PP_VER3
>> 8) & 0xff, PP_VER3
& 0xff,
644 (PP_VER2
>> 8) & 0xff, PP_VER2
& 0xff,
645 (PP_VER1
>> 8) & 0xff, PP_VER1
& 0xff, '\0' };
648 lcd_setfont(FONT_SYSFIXED
);
651 lcd_puts(0, line
++, "[Hardware info]");
654 debug_printf(line
++, "HW rev: 0x%08lx", IPOD_HW_REVISION
);
657 debug_printf(line
++, "PP version: %s", pp_version
);
659 debug_printf(line
++, "Est. clock (kHz): %d", perfcheck());
663 while (!(action_userabort(TIMEOUT_BLOCK
)));
666 /* Define this function in your target tree */
667 return __dbg_hw_info();
668 #endif /* CONFIG_CPU */
669 lcd_setfont(FONT_UI
);
672 #else /* !HAVE_LCD_BITMAP */
673 static bool dbg_hw_info(void)
677 int rom_version
= ROM_VERSION
;
678 unsigned manu
, id
; /* flash IDs */
679 bool got_id
; /* flag if we managed to get the flash IDs */
680 unsigned rom_crc
= 0xffffffff; /* CRC32 of the boot ROM */
681 bool has_bootrom
; /* flag for boot ROM present */
682 int oldmode
; /* saved memory guard mode */
684 oldmode
= system_memory_guard(MEMGUARD_NONE
); /* disable memory guard */
686 /* get flash ROM type */
687 got_id
= dbg_flash_id(&manu
, &id
, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
689 got_id
= dbg_flash_id(&manu
, &id
, 0x555, 0x2AA); /* try AMD, Macronix */
691 /* check if the boot ROM area is a flash mirror */
692 has_bootrom
= (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0);
693 if (has_bootrom
) /* if ROM and Flash different */
695 /* calculate CRC16 checksum of boot ROM */
696 rom_crc
= crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff);
699 system_memory_guard(oldmode
); /* re-enable memory guard */
703 lcd_puts(0, 0, "[HW Info]");
709 debug_printf(1, "ROM: %d.%02d",
710 rom_version
/100, rom_version
%100);
714 debug_printf(1, "Flash:%02x,%02x", manu
, id
);
716 lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */
721 if (rom_crc
== 0x56DBA4EE) /* known Version 1 */
722 lcd_puts(0, 1, "BootROM: V1");
723 else if (rom_crc
== 0x358099E8)
724 lcd_puts(0, 1, "BootROM: V2");
725 /* alternative boot ROM found in one single player so far */
727 debug_printf(1, "R: %08x", rom_crc
);
730 lcd_puts(0, 1, "BootROM: no");
735 button
= get_action(CONTEXT_SETTINGS
,TIMEOUT_BLOCK
);
739 case ACTION_STD_CANCEL
:
742 case ACTION_SETTINGS_DEC
:
748 case ACTION_SETTINGS_INC
:
757 #endif /* !HAVE_LCD_BITMAP */
758 #endif /* !SIMULATOR */
761 static const char* dbg_partitions_getname(int selected_item
, void *data
,
762 char *buffer
, size_t buffer_len
)
765 int partition
= selected_item
/2;
766 struct partinfo
* p
= disk_partinfo(partition
);
769 snprintf(buffer
, buffer_len
, " T:%x %ld MB", p
->type
, p
->size
/ 2048);
773 snprintf(buffer
, buffer_len
, "P%d: S:%lx", partition
, p
->start
);
778 bool dbg_partitions(void)
780 struct simplelist_info info
;
781 simplelist_info_init(&info
, "Partition Info", 4, NULL
);
782 info
.selection_size
= 2;
783 info
.hide_selection
= true;
784 info
.scroll_all
= true;
785 info
.get_name
= dbg_partitions_getname
;
786 return simplelist_show_list(&info
);
790 #if defined(CPU_COLDFIRE) && defined(HAVE_SPDIF_OUT)
791 static bool dbg_spdif(void)
794 unsigned int control
;
799 unsigned int interruptstat
;
800 bool valnogood
, symbolerr
, parityerr
;
803 int spdif_source
= spdif_get_output_source(&spdif_src_on
);
804 spdif_set_output_source(AUDIO_SRC_SPDIF
IF_SPDIF_POWER_(, true));
807 lcd_setfont(FONT_SYSFIXED
);
809 #ifdef HAVE_SPDIF_POWER
810 spdif_power_enable(true); /* We need SPDIF power for both sending & receiving */
817 control
= EBU1RCVCCHANNEL1
;
818 interruptstat
= INTERRUPTSTAT
;
819 INTERRUPTCLEAR
= 0x03c00000;
821 valnogood
= (interruptstat
& 0x01000000)?true:false;
822 symbolerr
= (interruptstat
& 0x00800000)?true:false;
823 parityerr
= (interruptstat
& 0x00400000)?true:false;
825 debug_printf(line
++, "Val: %s Sym: %s Par: %s",
828 parityerr
?"--":"OK");
830 debug_printf(line
++, "Status word: %08x", (int)control
);
835 debug_printf(line
++, "PRO: %d (%s)",
836 x
, x
?"Professional":"Consumer");
838 x
= (control
>> 30) & 1;
839 debug_printf(line
++, "Audio: %d (%s)",
840 x
, x
?"Non-PCM":"PCM");
842 x
= (control
>> 29) & 1;
843 debug_printf(line
++, "Copy: %d (%s)",
844 x
, x
?"Permitted":"Inhibited");
846 x
= (control
>> 27) & 7;
859 debug_printf(line
++, "Preemphasis: %d (%s)", x
, s
);
861 x
= (control
>> 24) & 3;
862 debug_printf(line
++, "Mode: %d", x
);
864 category
= (control
>> 17) & 127;
876 debug_printf(line
++, "Category: 0x%02x (%s)", category
, s
);
878 x
= (control
>> 16) & 1;
880 if(((category
& 0x70) == 0x10) ||
881 ((category
& 0x70) == 0x40) ||
882 ((category
& 0x78) == 0x38))
884 generation
= !generation
;
886 debug_printf(line
++, "Generation: %d (%s)",
887 x
, generation
?"Original":"No ind.");
889 x
= (control
>> 12) & 15;
890 debug_printf(line
++, "Source: %d", x
);
893 x
= (control
>> 8) & 15;
909 debug_printf(line
++, "Channel: %d (%s)", x
, s
);
911 x
= (control
>> 4) & 15;
924 debug_printf(line
++, "Frequency: %d (%s)", x
, s
);
926 x
= (control
>> 2) & 3;
927 debug_printf(line
++, "Clock accuracy: %d", x
);
931 debug_printf(line
++, "Measured freq: %ldHz",
932 spdif_measure_frequency());
937 if (action_userabort(HZ
/10))
941 spdif_set_output_source(spdif_source
IF_SPDIF_POWER_(, spdif_src_on
));
943 #ifdef HAVE_SPDIF_POWER
944 spdif_power_enable(global_settings
.spdif_enable
);
947 lcd_setfont(FONT_UI
);
950 #endif /* CPU_COLDFIRE */
953 #ifdef HAVE_LCD_BITMAP
954 /* button definitions */
955 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
956 (CONFIG_KEYPAD == IRIVER_H300_PAD)
957 # define DEBUG_CANCEL BUTTON_OFF
959 #elif CONFIG_KEYPAD == RECORDER_PAD
960 # define DEBUG_CANCEL BUTTON_OFF
962 #elif CONFIG_KEYPAD == ONDIO_PAD
963 # define DEBUG_CANCEL BUTTON_MENU
965 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) || \
966 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
967 (CONFIG_KEYPAD == IPOD_4G_PAD)
968 # define DEBUG_CANCEL BUTTON_MENU
970 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
971 # define DEBUG_CANCEL BUTTON_PLAY
973 #elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
974 # define DEBUG_CANCEL BUTTON_REC
976 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
977 # define DEBUG_CANCEL BUTTON_RC_REC
979 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
980 # define DEBUG_CANCEL BUTTON_REW
982 #elif (CONFIG_KEYPAD == MROBE100_PAD)
983 # define DEBUG_CANCEL BUTTON_MENU
985 #elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \
986 (CONFIG_KEYPAD == SANSA_C200_PAD) || \
987 (CONFIG_KEYPAD == SANSA_FUZE_PAD)
988 # define DEBUG_CANCEL BUTTON_LEFT
990 /* This is temporary until the SA9200 touchpad works */
991 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD) || \
992 (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD)
993 # define DEBUG_CANCEL BUTTON_POWER
995 #elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
996 # define DEBUG_CANCEL BUTTON_PLAY
998 #endif /* key definitions */
1001 bool dbg_ports(void)
1003 #if CONFIG_CPU == SH7034
1004 int adc_battery_voltage
, adc_battery_level
;
1006 lcd_setfont(FONT_SYSFIXED
);
1007 lcd_clear_display();
1011 debug_printf(0, "PADR: %04x", (unsigned short)PADR
);
1012 debug_printf(1, "PBDR: %04x", (unsigned short)PBDR
);
1014 debug_printf(2, "AN0: %03x AN4: %03x", adc_read(0), adc_read(4));
1015 debug_printf(3, "AN1: %03x AN5: %03x", adc_read(1), adc_read(5));
1016 debug_printf(4, "AN2: %03x AN6: %03x", adc_read(2), adc_read(6));
1017 debug_printf(5, "AN3: %03x AN7: %03x", adc_read(3), adc_read(7));
1019 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1020 debug_printf(6, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1021 adc_battery_voltage
% 1000, adc_battery_level
);
1024 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1026 lcd_setfont(FONT_UI
);
1030 #elif defined(CPU_COLDFIRE)
1031 unsigned int gpio_out
;
1032 unsigned int gpio1_out
;
1033 unsigned int gpio_read
;
1034 unsigned int gpio1_read
;
1035 unsigned int gpio_function
;
1036 unsigned int gpio1_function
;
1037 unsigned int gpio_enable
;
1038 unsigned int gpio1_enable
;
1039 int adc_buttons
, adc_remote
;
1040 int adc_battery_voltage
, adc_battery_level
;
1043 lcd_clear_display();
1044 lcd_setfont(FONT_SYSFIXED
);
1049 gpio_read
= GPIO_READ
;
1050 gpio1_read
= GPIO1_READ
;
1051 gpio_out
= GPIO_OUT
;
1052 gpio1_out
= GPIO1_OUT
;
1053 gpio_function
= GPIO_FUNCTION
;
1054 gpio1_function
= GPIO1_FUNCTION
;
1055 gpio_enable
= GPIO_ENABLE
;
1056 gpio1_enable
= GPIO1_ENABLE
;
1058 debug_printf(line
++, "GPIO_READ: %08x", gpio_read
);
1059 debug_printf(line
++, "GPIO_OUT: %08x", gpio_out
);
1060 debug_printf(line
++, "GPIO_FUNC: %08x", gpio_function
);
1061 debug_printf(line
++, "GPIO_ENA: %08x", gpio_enable
);
1063 debug_printf(line
++, "GPIO1_READ: %08x", gpio1_read
);
1064 debug_printf(line
++, "GPIO1_OUT: %08x", gpio1_out
);
1065 debug_printf(line
++, "GPIO1_FUNC: %08x", gpio1_function
);
1066 debug_printf(line
++, "GPIO1_ENA: %08x", gpio1_enable
);
1068 adc_buttons
= adc_read(ADC_BUTTONS
);
1069 adc_remote
= adc_read(ADC_REMOTE
);
1070 battery_read_info(&adc_battery_voltage
, &adc_battery_level
);
1071 #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IRIVER_H300_SERIES)
1072 debug_printf(line
++, "ADC_BUTTONS (%c): %02x",
1073 button_scan_enabled() ? '+' : '-', adc_buttons
);
1075 debug_printf(line
++, "ADC_BUTTONS: %02x", adc_buttons
);
1077 #if defined(IAUDIO_X5) || defined(IAUDIO_M5)
1078 debug_printf(line
++, "ADC_REMOTE (%c): %02x",
1079 remote_detect() ? '+' : '-', adc_remote
);
1081 debug_printf(line
++, "ADC_REMOTE: %02x", adc_remote
);
1083 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1084 debug_printf(line
++, "ADC_REMOTEDETECT: %02x",
1085 adc_read(ADC_REMOTEDETECT
));
1088 debug_printf(line
++, "Batt: %d.%03dV %d%% ", adc_battery_voltage
/ 1000,
1089 adc_battery_voltage
% 1000, adc_battery_level
);
1091 #if defined(IRIVER_H100_SERIES) || defined(IRIVER_H300_SERIES)
1092 debug_printf(line
++, "remotetype: %d", remote_type());
1096 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1098 lcd_setfont(FONT_UI
);
1103 #elif defined(CPU_PP502x)
1106 lcd_clear_display();
1107 lcd_setfont(FONT_SYSFIXED
);
1112 lcd_puts(0, line
++, "GPIO STATES:");
1113 debug_printf(line
++, "A: %02x E: %02x I: %02x",
1114 (unsigned int)GPIOA_INPUT_VAL
,
1115 (unsigned int)GPIOE_INPUT_VAL
,
1116 (unsigned int)GPIOI_INPUT_VAL
);
1117 debug_printf(line
++, "B: %02x F: %02x J: %02x",
1118 (unsigned int)GPIOB_INPUT_VAL
,
1119 (unsigned int)GPIOF_INPUT_VAL
,
1120 (unsigned int)GPIOJ_INPUT_VAL
);
1121 debug_printf(line
++, "C: %02x G: %02x K: %02x",
1122 (unsigned int)GPIOC_INPUT_VAL
,
1123 (unsigned int)GPIOG_INPUT_VAL
,
1124 (unsigned int)GPIOK_INPUT_VAL
);
1125 debug_printf(line
++, "D: %02x H: %02x L: %02x",
1126 (unsigned int)GPIOD_INPUT_VAL
,
1127 (unsigned int)GPIOH_INPUT_VAL
,
1128 (unsigned int)GPIOL_INPUT_VAL
);
1130 debug_printf(line
++, "GPO32_VAL: %08lx", GPO32_VAL
);
1131 debug_printf(line
++, "GPO32_EN: %08lx", GPO32_ENABLE
);
1132 debug_printf(line
++, "DEV_EN: %08lx", DEV_EN
);
1133 debug_printf(line
++, "DEV_EN2: %08lx", DEV_EN2
);
1134 debug_printf(line
++, "DEV_EN3: %08lx", inl(0x60006044)); /* to be verified */
1135 debug_printf(line
++, "DEV_INIT1: %08lx", DEV_INIT1
);
1136 debug_printf(line
++, "DEV_INIT2: %08lx", DEV_INIT2
);
1137 #ifdef ADC_ACCESSORY
1138 debug_printf(line
++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY
));
1141 #if defined(IPOD_ACCESSORY_PROTOCOL)
1142 extern unsigned char serbuf
[];
1143 debug_printf(line
++, "IAP PACKET: %02x %02x %02x %02x %02x %02x %02x %02x",
1144 serbuf
[0], serbuf
[1], serbuf
[2], serbuf
[3], serbuf
[4], serbuf
[5],
1145 serbuf
[6], serbuf
[7]);
1148 #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB)
1150 debug_printf(line
++, "BATT: %03x UNK1: %03x",
1151 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1152 debug_printf(line
++, "REM: %03x PAD: %03x",
1153 adc_read(ADC_REMOTE
), adc_read(ADC_SCROLLPAD
));
1154 #elif defined(PHILIPS_HDD1630)
1156 debug_printf(line
++, "BATT: %03x UNK1: %03x",
1157 adc_read(ADC_BATTERY
), adc_read(ADC_UNKNOWN_1
));
1158 #elif defined(SANSA_E200) || defined(PHILIPS_SA9200)
1159 debug_printf(line
++, "ADC_BVDD: %4d", adc_read(ADC_BVDD
));
1160 debug_printf(line
++, "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP
));
1161 debug_printf(line
++, "ADC_UVDD: %4d", adc_read(ADC_UVDD
));
1162 debug_printf(line
++, "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN
));
1163 debug_printf(line
++, "ADC_CVDD: %4d", adc_read(ADC_CVDD
));
1164 debug_printf(line
++, "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP
));
1165 debug_printf(line
++, "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1
));
1166 debug_printf(line
++, "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2
));
1167 debug_printf(line
++, "ADC_VBE1: %4d", adc_read(ADC_VBE1
));
1168 debug_printf(line
++, "ADC_VBE2: %4d", adc_read(ADC_VBE2
));
1169 debug_printf(line
++, "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1
));
1170 #if !defined(PHILIPS_SA9200)
1171 debug_printf(line
++, "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2
));
1172 debug_printf(line
++, "ADC_VBAT: %4d", adc_read(ADC_VBAT
));
1176 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1178 lcd_setfont(FONT_UI
);
1183 #elif CONFIG_CPU == PP5002
1186 lcd_clear_display();
1187 lcd_setfont(FONT_SYSFIXED
);
1192 debug_printf(line
++, "GPIO_A: %02x GPIO_B: %02x",
1193 (unsigned int)GPIOA_INPUT_VAL
, (unsigned int)GPIOB_INPUT_VAL
);
1194 debug_printf(line
++, "GPIO_C: %02x GPIO_D: %02x",
1195 (unsigned int)GPIOC_INPUT_VAL
, (unsigned int)GPIOD_INPUT_VAL
);
1197 debug_printf(line
++, "DEV_EN: %08lx", DEV_EN
);
1198 debug_printf(line
++, "CLOCK_ENABLE: %08lx", CLOCK_ENABLE
);
1199 debug_printf(line
++, "CLOCK_SOURCE: %08lx", CLOCK_SOURCE
);
1200 debug_printf(line
++, "PLL_CONTROL: %08lx", PLL_CONTROL
);
1201 debug_printf(line
++, "PLL_DIV: %08lx", PLL_DIV
);
1202 debug_printf(line
++, "PLL_MULT: %08lx", PLL_MULT
);
1203 debug_printf(line
++, "TIMING1_CTL: %08lx", TIMING1_CTL
);
1204 debug_printf(line
++, "TIMING2_CTL: %08lx", TIMING2_CTL
);
1207 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1209 lcd_setfont(FONT_UI
);
1213 lcd_setfont(FONT_UI
);
1215 return __dbg_ports();
1219 #else /* !HAVE_LCD_BITMAP */
1220 bool dbg_ports(void)
1224 int adc_battery_voltage
;
1227 lcd_clear_display();
1234 snprintf(buf
, 32, "PADR: %04x", (unsigned short)PADR
);
1237 snprintf(buf
, 32, "PBDR: %04x", (unsigned short)PBDR
);
1240 snprintf(buf
, 32, "AN0: %03x", adc_read(0));
1243 snprintf(buf
, 32, "AN1: %03x", adc_read(1));
1246 snprintf(buf
, 32, "AN2: %03x", adc_read(2));
1249 snprintf(buf
, 32, "AN3: %03x", adc_read(3));
1252 snprintf(buf
, 32, "AN4: %03x", adc_read(4));
1255 snprintf(buf
, 32, "AN5: %03x", adc_read(5));
1258 snprintf(buf
, 32, "AN6: %03x", adc_read(6));
1261 snprintf(buf
, 32, "AN7: %03x", adc_read(7));
1264 lcd_puts(0, 0, buf
);
1266 battery_read_info(&adc_battery_voltage
, NULL
);
1267 debug_printf(1, "Batt: %d.%03dV", adc_battery_voltage
/ 1000,
1268 adc_battery_voltage
% 1000);
1271 button
= get_action(CONTEXT_SETTINGS
,HZ
/5);
1275 case ACTION_STD_CANCEL
:
1278 case ACTION_SETTINGS_DEC
:
1284 case ACTION_SETTINGS_INC
:
1293 #endif /* !HAVE_LCD_BITMAP */
1294 #endif /* !SIMULATOR */
1296 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
1297 static bool dbg_pcf(void)
1301 #ifdef HAVE_LCD_BITMAP
1302 lcd_setfont(FONT_SYSFIXED
);
1304 lcd_clear_display();
1310 debug_printf(line
++, "DCDC1: %02x", pcf50605_read(0x1b));
1311 debug_printf(line
++, "DCDC2: %02x", pcf50605_read(0x1c));
1312 debug_printf(line
++, "DCDC3: %02x", pcf50605_read(0x1d));
1313 debug_printf(line
++, "DCDC4: %02x", pcf50605_read(0x1e));
1314 debug_printf(line
++, "DCDEC1: %02x", pcf50605_read(0x1f));
1315 debug_printf(line
++, "DCDEC2: %02x", pcf50605_read(0x20));
1316 debug_printf(line
++, "DCUDC1: %02x", pcf50605_read(0x21));
1317 debug_printf(line
++, "DCUDC2: %02x", pcf50605_read(0x22));
1318 debug_printf(line
++, "IOREGC: %02x", pcf50605_read(0x23));
1319 debug_printf(line
++, "D1REGC: %02x", pcf50605_read(0x24));
1320 debug_printf(line
++, "D2REGC: %02x", pcf50605_read(0x25));
1321 debug_printf(line
++, "D3REGC: %02x", pcf50605_read(0x26));
1322 debug_printf(line
++, "LPREG1: %02x", pcf50605_read(0x27));
1324 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))
1326 lcd_setfont(FONT_UI
);
1331 lcd_setfont(FONT_UI
);
1336 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
1337 static bool dbg_cpufreq(void)
1342 #ifdef HAVE_LCD_BITMAP
1343 lcd_setfont(FONT_SYSFIXED
);
1345 lcd_clear_display();
1351 debug_printf(line
++, "Frequency: %ld", FREQ
);
1352 debug_printf(line
++, "boost_counter: %d", get_cpu_boost_counter());
1355 button
= get_action(CONTEXT_STD
,HZ
/10);
1359 case ACTION_STD_PREV
:
1363 case ACTION_STD_NEXT
:
1368 while (get_cpu_boost_counter() > 0)
1370 set_cpu_frequency(CPUFREQ_DEFAULT
);
1373 case ACTION_STD_CANCEL
:
1374 lcd_setfont(FONT_UI
);
1378 lcd_setfont(FONT_UI
);
1381 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
1383 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
1384 #include "tsc2100.h"
1385 static char *itob(int n
, int len
)
1387 static char binary
[64];
1389 for (i
=1, j
=0;i
<=len
;i
++)
1391 binary
[j
++] = n
&(1<<(len
-i
))?'1':'0';
1399 static const char* tsc2100_debug_getname(int selected_item
, void * data
,
1400 char *buffer
, size_t buffer_len
)
1402 int *page
= (int*)data
;
1403 bool reserved
= false;
1407 if ((selected_item
> 0x0a) ||
1408 (selected_item
== 0x04) ||
1409 (selected_item
== 0x08))
1413 if ((selected_item
> 0x05) ||
1414 (selected_item
== 0x02))
1418 if (selected_item
> 0x1e)
1423 snprintf(buffer
, buffer_len
, "%02x: RESERVED", selected_item
);
1425 snprintf(buffer
, buffer_len
, "%02x: %s", selected_item
,
1426 itob(tsc2100_readreg(*page
, selected_item
)&0xffff,16));
1429 static int tsc2100debug_action_callback(int action
, struct gui_synclist
*lists
)
1431 int *page
= (int*)lists
->data
;
1432 if (action
== ACTION_STD_OK
)
1434 *page
= (*page
+1)%3;
1435 snprintf(lists
->title
, 32,
1436 "tsc2100 registers - Page %d", *page
);
1437 return ACTION_REDRAW
;
1441 static bool tsc2100_debug(void)
1444 char title
[32] = "tsc2100 registers - Page 0";
1445 struct simplelist_info info
;
1446 simplelist_info_init(&info
, title
, 32, &page
);
1447 info
.timeout
= HZ
/100;
1448 info
.get_name
= tsc2100_debug_getname
;
1449 info
.action_callback
= tsc2100debug_action_callback
;
1450 return simplelist_show_list(&info
);
1454 #ifdef HAVE_LCD_BITMAP
1456 * view_battery() shows a automatically scaled graph of the battery voltage
1457 * over time. Usable for estimating battery life / charging rate.
1458 * The power_history array is updated in power_thread of powermgmt.c.
1461 #define BAT_LAST_VAL MIN(LCD_WIDTH, POWER_HISTORY_LEN)
1462 #define BAT_YSPACE (LCD_HEIGHT - 20)
1464 static bool view_battery(void)
1468 unsigned short maxv
, minv
;
1470 lcd_setfont(FONT_SYSFIXED
);
1474 lcd_clear_display();
1476 case 0: /* voltage history graph */
1477 /* Find maximum and minimum voltage for scaling */
1478 minv
= power_history
[0];
1480 for (i
= 1; i
< BAT_LAST_VAL
&& power_history
[i
]; i
++) {
1481 if (power_history
[i
] > maxv
)
1482 maxv
= power_history
[i
];
1483 if (power_history
[i
] < minv
)
1484 minv
= power_history
[i
];
1487 debug_printf(0, "Battery %d.%03d", power_history
[0] / 1000,
1488 power_history
[0] % 1000);
1489 debug_printf(1, "scale %d.%03d-%d.%03dV",
1490 minv
/ 1000, minv
% 1000, maxv
/ 1000, maxv
% 1000);
1493 for (i
= BAT_LAST_VAL
- 1; i
>= 0; i
--) {
1494 y
= (power_history
[i
] - minv
) * BAT_YSPACE
/ (maxv
- minv
);
1495 lcd_set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
1496 lcd_vline(x
, LCD_HEIGHT
-1, 20);
1497 lcd_set_drawmode(DRMODE_SOLID
);
1498 lcd_vline(x
, LCD_HEIGHT
-1,
1499 MIN(MAX(LCD_HEIGHT
-1 - y
, 20), LCD_HEIGHT
-1));
1505 case 1: /* status: */
1506 lcd_puts(0, 0, "Power status:");
1508 battery_read_info(&y
, NULL
);
1509 debug_printf(1, "Battery: %d.%03d V", y
/ 1000, y
% 1000);
1510 #ifdef ADC_EXT_POWER
1511 y
= (adc_read(ADC_EXT_POWER
) * EXT_SCALE_FACTOR
) / 1000;
1512 debug_printf(2, "External: %d.%03d V", y
/ 1000, y
% 1000);
1515 #if defined ARCHOS_RECORDER
1516 debug_printf(3, "Chgr: %s %s",
1517 charger_inserted() ? "present" : "absent",
1518 charger_enabled() ? "on" : "off");
1519 debug_printf(5, "short delta: %d", short_delta
);
1520 debug_printf(6, "long delta: %d", long_delta
);
1521 lcd_puts(0, 7, power_message
);
1522 debug_printf(8, "USB Inserted: %s",
1523 usb_inserted() ? "yes" : "no");
1524 #elif defined IRIVER_H300_SERIES
1525 debug_printf(9, "USB Charging Enabled: %s",
1526 usb_charging_enabled() ? "yes" : "no");
1527 #elif defined IPOD_NANO || defined IPOD_VIDEO
1528 int usb_pwr
= (GPIOL_INPUT_VAL
& 0x10)?true:false;
1529 int ext_pwr
= (GPIOL_INPUT_VAL
& 0x08)?false:true;
1530 int dock
= (GPIOA_INPUT_VAL
& 0x10)?true:false;
1531 int charging
= (GPIOB_INPUT_VAL
& 0x01)?false:true;
1532 int headphone
= (GPIOA_INPUT_VAL
& 0x80)?true:false;
1534 debug_printf(3, "USB pwr: %s",
1535 usb_pwr
? "present" : "absent");
1536 debug_printf(4, "EXT pwr: %s",
1537 ext_pwr
? "present" : "absent");
1538 debug_printf(5, "Battery: %s",
1539 charging
? "charging" : (usb_pwr
||ext_pwr
) ? "charged" : "discharging");
1540 debug_printf(6, "Dock mode: %s",
1541 dock
? "enabled" : "disabled");
1542 debug_printf(7, "Headphone: %s",
1543 headphone
? "connected" : "disconnected");
1544 #elif defined TOSHIBA_GIGABEAT_S
1548 static const unsigned char * const chrgstate_strings
[] =
1559 debug_printf(line
++, "Charger: %s",
1560 charger_inserted() ? "present" : "absent");
1562 st
= power_input_status() &
1563 (POWER_INPUT_CHARGER
| POWER_INPUT_BATTERY
);
1564 debug_printf(line
++, "%s%s",
1565 (st
& POWER_INPUT_MAIN_CHARGER
) ? " Main" : "",
1566 (st
& POWER_INPUT_USB_CHARGER
) ? " USB" : "");
1568 debug_printf(line
++, "IUSB Max: %d", usb_allowed_current());
1570 y
= ARRAYLEN(chrgstate_strings
) - 1;
1572 switch (charge_state
)
1574 case CHARGE_STATE_DISABLED
: y
--;
1575 case CHARGE_STATE_ERROR
: y
--;
1576 case DISCHARGING
: y
--;
1583 debug_printf(line
++, "State: %s", chrgstate_strings
[y
]);
1585 debug_printf(line
++, "Battery Switch: %s",
1586 (st
& POWER_INPUT_BATTERY
) ? "On" : "Off");
1588 y
= chrgraw_adc_voltage();
1589 debug_printf(line
++, "CHRGRAW: %d.%03d V",
1590 y
/ 1000, y
% 1000);
1592 y
= application_supply_adc_voltage();
1593 debug_printf(line
++, "BP : %d.%03d V",
1594 y
/ 1000, y
% 1000);
1596 y
= battery_adc_charge_current();
1597 if (y
< 0) x
= '-', y
= -y
;
1599 debug_printf(line
++, "CHRGISN:%c%d mA", x
, y
);
1601 y
= cccv_regulator_dissipation();
1602 debug_printf(line
++, "P CCCV : %d mW", y
);
1604 y
= battery_charge_current();
1605 if (y
< 0) x
= '-', y
= -y
;
1607 debug_printf(line
++, "I Charge:%c%d mA", x
, y
);
1609 y
= battery_adc_temp();
1612 debug_printf(line
++, "T Battery: %dC (%dF)", y
,
1615 /* Conversion disabled */
1616 lcd_puts(0, line
++, "T Battery: ?");
1619 #elif defined(SANSA_E200) || defined(SANSA_C200) || defined(SANSA_CLIP) || defined(SANSA_FUZE)
1620 const int first
= CHARGE_STATE_DISABLED
;
1621 static const char * const chrgstate_strings
[] =
1623 [CHARGE_STATE_DISABLED
-first
] = "Disabled",
1624 [CHARGE_STATE_ERROR
-first
] = "Error",
1625 [DISCHARGING
-first
] = "Discharging",
1626 [CHARGING
-first
] = "Charging",
1628 const char *str
= NULL
;
1630 debug_printf(3, "Charger: %s",
1631 charger_inserted() ? "present" : "absent");
1633 y
= charge_state
- first
;
1634 if ((unsigned)y
< ARRAYLEN(chrgstate_strings
))
1635 str
= chrgstate_strings
[y
];
1637 debug_printf(4, "State: %s",
1638 str
? str
: "<unknown>");
1640 debug_printf(5, "CHARGER: %02X",
1641 ascodec_read(AS3514_CHARGER
));
1642 #elif defined(IPOD_NANO2G)
1643 y
= pmu_read_battery_current();
1644 debug_printf(2, "Battery current: %d mA", y
);
1646 debug_printf(3, "Charger: %s",
1647 charger_inserted() ? "present" : "absent");
1648 #endif /* target type */
1649 #endif /* CONFIG_CHARGING */
1652 case 2: /* voltage deltas: */
1653 lcd_puts(0, 0, "Voltage deltas:");
1655 for (i
= 0; i
<= 6; i
++) {
1656 y
= power_history
[i
] - power_history
[i
+1];
1657 debug_printf(i
+1, "-%d min: %s%d.%03d V", i
,
1658 (y
< 0) ? "-" : "", ((y
< 0) ? y
* -1 : y
) / 1000,
1659 ((y
< 0) ? y
* -1 : y
) % 1000);
1663 case 3: /* remaining time estimation: */
1665 #ifdef ARCHOS_RECORDER
1666 debug_printf(0, "charge_state: %d", charge_state
);
1668 debug_printf(1, "Cycle time: %d m", powermgmt_last_cycle_startstop_min
);
1670 debug_printf(2, "Lvl@cyc st: %d%%", powermgmt_last_cycle_level
);
1672 debug_printf(3, "P=%2d I=%2d", pid_p
, pid_i
);
1674 debug_printf(4, "Trickle sec: %d/60", trickle_sec
);
1675 #endif /* ARCHOS_RECORDER */
1677 debug_printf(5, "Last PwrHist: %d.%03dV",
1678 power_history
[0] / 1000,
1679 power_history
[0] % 1000);
1681 debug_printf(6, "battery level: %d%%", battery_level());
1683 debug_printf(7, "Est. remain: %d m", battery_time());
1689 switch(get_action(CONTEXT_STD
,HZ
/2))
1691 case ACTION_STD_PREV
:
1696 case ACTION_STD_NEXT
:
1701 case ACTION_STD_CANCEL
:
1702 lcd_setfont(FONT_UI
);
1706 lcd_setfont(FONT_UI
);
1710 #endif /* HAVE_LCD_BITMAP */
1714 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
1716 #if (CONFIG_STORAGE & STORAGE_MMC)
1717 #define CARDTYPE "MMC"
1718 #elif (CONFIG_STORAGE & STORAGE_SD)
1719 #define CARDTYPE "microSD"
1722 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1725 int *cardnum
= (int*)lists
->data
;
1726 unsigned char card_name
[7];
1727 unsigned char pbuf
[32];
1728 char *title
= lists
->title
;
1729 static const unsigned char i_vmin
[] = { 0, 1, 5, 10, 25, 35, 60, 100 };
1730 static const unsigned char i_vmax
[] = { 1, 5, 10, 25, 35, 45, 80, 200 };
1731 static const unsigned char * const kbit_units
[] = { "kBit/s", "MBit/s", "GBit/s" };
1732 static const unsigned char * const nsec_units
[] = { "ns", "µs", "ms" };
1733 #if (CONFIG_STORAGE & STORAGE_MMC)
1734 static const char * const mmc_spec_vers
[] = { "1.0-1.2", "1.4", "2.0-2.2",
1735 "3.1-3.31", "4.0" };
1738 if ((btn
== ACTION_STD_OK
) || (btn
== SYS_FS_CHANGED
) || (btn
== ACTION_REDRAW
))
1741 if (btn
== ACTION_STD_OK
)
1743 *cardnum
^= 0x1; /* change cards */
1747 simplelist_set_line_count(0);
1749 card
= card_get_info(*cardnum
);
1751 if (card
->initialized
> 0)
1753 strlcpy(card_name
, ((unsigned char*)card
->cid
) + 3, sizeof(card_name
));
1754 simplelist_addline(SIMPLELIST_ADD_LINE
,
1755 "%s Rev %d.%d", card_name
,
1756 (int) card_extract_bits(card
->cid
, 55, 4),
1757 (int) card_extract_bits(card
->cid
, 51, 4));
1758 simplelist_addline(SIMPLELIST_ADD_LINE
,
1760 #if (CONFIG_STORAGE & STORAGE_SD)
1761 (int) card_extract_bits(card
->cid
, 11, 3),
1762 (int) card_extract_bits(card
->cid
, 19, 8) + 2000
1763 #elif (CONFIG_STORAGE & STORAGE_MMC)
1764 (int) card_extract_bits(card
->cid
, 15, 4),
1765 (int) card_extract_bits(card
->cid
, 11, 4) + 1997
1768 simplelist_addline(SIMPLELIST_ADD_LINE
,
1769 #if (CONFIG_STORAGE & STORAGE_SD)
1771 card_extract_bits(card
->cid
, 55, 32)
1772 #elif (CONFIG_STORAGE & STORAGE_MMC)
1774 card_extract_bits(card
->cid
, 47, 16)
1778 simplelist_addline(SIMPLELIST_ADD_LINE
, "M=%02x, "
1779 #if (CONFIG_STORAGE & STORAGE_SD)
1781 (int) card_extract_bits(card
->cid
, 127, 8),
1782 card_extract_bits(card
->cid
, 119, 8),
1783 card_extract_bits(card
->cid
, 111, 8)
1784 #elif (CONFIG_STORAGE & STORAGE_MMC)
1786 (int) card_extract_bits(card
->cid
, 127, 8),
1787 (int) card_extract_bits(card
->cid
, 119, 16)
1791 #if (CONFIG_STORAGE & STORAGE_MMC)
1792 int temp
= card_extract_bits(card
->csd
, 125, 4);
1793 simplelist_addline(SIMPLELIST_ADD_LINE
,
1794 "MMC v%s", temp
< 5 ?
1795 mmc_spec_vers
[temp
] : "?.?");
1797 simplelist_addline(SIMPLELIST_ADD_LINE
,
1798 "Blocks: 0x%08lx", card
->numblocks
);
1799 output_dyn_value(pbuf
, sizeof pbuf
, card
->speed
/ 1000,
1801 simplelist_addline(SIMPLELIST_ADD_LINE
,
1803 output_dyn_value(pbuf
, sizeof pbuf
, card
->taac
,
1805 simplelist_addline(SIMPLELIST_ADD_LINE
,
1807 simplelist_addline(SIMPLELIST_ADD_LINE
,
1808 "Nsac: %d clk", card
->nsac
);
1809 simplelist_addline(SIMPLELIST_ADD_LINE
,
1810 "R2W: *%d", card
->r2w_factor
);
1811 simplelist_addline(SIMPLELIST_ADD_LINE
,
1813 i_vmin
[card_extract_bits(card
->csd
, 61, 3)],
1814 i_vmax
[card_extract_bits(card
->csd
, 58, 3)]);
1815 simplelist_addline(SIMPLELIST_ADD_LINE
,
1817 i_vmin
[card_extract_bits(card
->csd
, 55, 3)],
1818 i_vmax
[card_extract_bits(card
->csd
, 52, 3)]);
1820 else if (card
->initialized
== 0)
1822 simplelist_addline(SIMPLELIST_ADD_LINE
, "Not Found!");
1824 #if (CONFIG_STORAGE & STORAGE_SD)
1825 else /* card->initialized < 0 */
1827 simplelist_addline(SIMPLELIST_ADD_LINE
, "Init Error! (%d)", card
->initialized
);
1830 snprintf(title
, 16, "[" CARDTYPE
" %d]", *cardnum
);
1831 gui_synclist_set_title(lists
, title
, Icon_NOICON
);
1832 gui_synclist_set_nb_items(lists
, simplelist_get_line_count());
1833 gui_synclist_select_item(lists
, 0);
1834 btn
= ACTION_REDRAW
;
1838 #elif (CONFIG_STORAGE & STORAGE_ATA)
1839 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1844 unsigned short* identify_info
= ata_get_identify();
1845 bool timing_info_present
= false;
1848 simplelist_set_line_count(0);
1850 for (i
=0; i
< 20; i
++)
1851 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
1853 /* kill trailing space */
1854 for (i
=39; i
&& buf
[i
]==' '; i
--)
1856 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", buf
);
1857 for (i
=0; i
< 4; i
++)
1858 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+23]);
1860 simplelist_addline(SIMPLELIST_ADD_LINE
,
1861 "Firmware: %s", buf
);
1862 snprintf(buf
, sizeof buf
, "%ld MB",
1863 ((unsigned long)identify_info
[61] << 16 |
1864 (unsigned long)identify_info
[60]) / 2048 );
1865 simplelist_addline(SIMPLELIST_ADD_LINE
,
1868 fat_size( IF_MV2(0,) NULL
, &free
);
1869 simplelist_addline(SIMPLELIST_ADD_LINE
,
1870 "Free: %ld MB", free
/ 1024);
1871 simplelist_addline(SIMPLELIST_ADD_LINE
,
1872 "Spinup time: %d ms", storage_spinup_time() * (1000/HZ
));
1873 i
= identify_info
[83] & (1<<3);
1874 simplelist_addline(SIMPLELIST_ADD_LINE
,
1875 "Power mgmt: %s", i
? "enabled" : "unsupported");
1876 i
= identify_info
[83] & (1<<9);
1877 simplelist_addline(SIMPLELIST_ADD_LINE
,
1878 "Noise mgmt: %s", i
? "enabled" : "unsupported");
1879 i
= identify_info
[82] & (1<<6);
1880 simplelist_addline(SIMPLELIST_ADD_LINE
,
1881 "Read-ahead: %s", i
? "enabled" : "unsupported");
1882 timing_info_present
= identify_info
[53] & (1<<1);
1883 if(timing_info_present
) {
1884 char pio3
[2], pio4
[2];pio3
[1] = 0;
1886 pio3
[0] = (identify_info
[64] & (1<<0)) ? '3' : 0;
1887 pio4
[0] = (identify_info
[64] & (1<<1)) ? '4' : 0;
1888 simplelist_addline(SIMPLELIST_ADD_LINE
,
1889 "PIO modes: 0 1 2 %s %s", pio3
, pio4
);
1892 simplelist_addline(SIMPLELIST_ADD_LINE
,
1893 "No PIO mode info");
1895 timing_info_present
= identify_info
[53] & (1<<1);
1896 if(timing_info_present
) {
1897 simplelist_addline(SIMPLELIST_ADD_LINE
,
1898 "Cycle times %dns/%dns",
1900 identify_info
[68] );
1902 simplelist_addline(SIMPLELIST_ADD_LINE
,
1906 if (identify_info
[63] & (1<<0)) {
1907 char mdma0
[2], mdma1
[2], mdma2
[2];
1908 mdma0
[1] = mdma1
[1] = mdma2
[1] = 0;
1909 mdma0
[0] = (identify_info
[63] & (1<<0)) ? '0' : 0;
1910 mdma1
[0] = (identify_info
[63] & (1<<1)) ? '1' : 0;
1911 mdma2
[0] = (identify_info
[63] & (1<<2)) ? '2' : 0;
1912 simplelist_addline(SIMPLELIST_ADD_LINE
,
1913 "MDMA modes: %s %s %s", mdma0
, mdma1
, mdma2
);
1914 simplelist_addline(SIMPLELIST_ADD_LINE
,
1915 "MDMA Cycle times %dns/%dns",
1917 identify_info
[66] );
1920 simplelist_addline(SIMPLELIST_ADD_LINE
,
1921 "No MDMA mode info");
1923 if (identify_info
[53] & (1<<2)) {
1924 char udma0
[2], udma1
[2], udma2
[2], udma3
[2], udma4
[2], udma5
[2], udma6
[2];
1925 udma0
[1] = udma1
[1] = udma2
[1] = udma3
[1] = udma4
[1] = udma5
[1] = udma6
[1] = 0;
1926 udma0
[0] = (identify_info
[88] & (1<<0)) ? '0' : 0;
1927 udma1
[0] = (identify_info
[88] & (1<<1)) ? '1' : 0;
1928 udma2
[0] = (identify_info
[88] & (1<<2)) ? '2' : 0;
1929 udma3
[0] = (identify_info
[88] & (1<<3)) ? '3' : 0;
1930 udma4
[0] = (identify_info
[88] & (1<<4)) ? '4' : 0;
1931 udma5
[0] = (identify_info
[88] & (1<<5)) ? '5' : 0;
1932 udma6
[0] = (identify_info
[88] & (1<<6)) ? '6' : 0;
1933 simplelist_addline(SIMPLELIST_ADD_LINE
,
1934 "UDMA modes: %s %s %s %s %s %s %s", udma0
, udma1
, udma2
,
1935 udma3
, udma4
, udma5
, udma6
);
1938 simplelist_addline(SIMPLELIST_ADD_LINE
,
1939 "No UDMA mode info");
1941 #endif /* HAVE_ATA_DMA */
1942 timing_info_present
= identify_info
[53] & (1<<1);
1943 if(timing_info_present
) {
1944 i
= identify_info
[49] & (1<<11);
1945 simplelist_addline(SIMPLELIST_ADD_LINE
,
1946 "IORDY support: %s", i
? "yes" : "no");
1947 i
= identify_info
[49] & (1<<10);
1948 simplelist_addline(SIMPLELIST_ADD_LINE
,
1949 "IORDY disable: %s", i
? "yes" : "no");
1951 simplelist_addline(SIMPLELIST_ADD_LINE
,
1954 simplelist_addline(SIMPLELIST_ADD_LINE
,
1955 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1957 i
= ata_get_dma_mode();
1959 simplelist_addline(SIMPLELIST_ADD_LINE
,
1962 simplelist_addline(SIMPLELIST_ADD_LINE
,
1964 (i
& 0x40) ? "UDMA" : "MDMA",
1967 #endif /* HAVE_ATA_DMA */
1970 #else /* No SD, MMC or ATA */
1971 static int disk_callback(int btn
, struct gui_synclist
*lists
)
1975 struct storage_info info
;
1976 storage_get_info(0,&info
);
1977 simplelist_addline(SIMPLELIST_ADD_LINE
, "Vendor: %s", info
.vendor
);
1978 simplelist_addline(SIMPLELIST_ADD_LINE
, "Model: %s", info
.product
);
1979 simplelist_addline(SIMPLELIST_ADD_LINE
, "Firmware: %s", info
.revision
);
1980 simplelist_addline(SIMPLELIST_ADD_LINE
,
1981 "Size: %ld MB", info
.num_sectors
*(info
.sector_size
/512)/2024);
1983 fat_size( IF_MV2(0,) NULL
, &free
);
1984 simplelist_addline(SIMPLELIST_ADD_LINE
,
1985 "Free: %ld MB", free
/ 1024);
1986 simplelist_addline(SIMPLELIST_ADD_LINE
,
1987 "Cluster size: %d bytes", fat_get_cluster_size(IF_MV(0)));
1992 #if (CONFIG_STORAGE & STORAGE_ATA)
1993 static bool dbg_identify_info(void)
1995 int fd
= creat("/identify_info.bin");
1998 #ifdef ROCKBOX_LITTLE_ENDIAN
1999 ecwrite(fd
, ata_get_identify(), SECTOR_SIZE
/2, "s", true);
2001 write(fd
, ata_get_identify(), SECTOR_SIZE
);
2009 static bool dbg_disk_info(void)
2011 struct simplelist_info info
;
2012 simplelist_info_init(&info
, "Disk Info", 1, NULL
);
2013 #if (CONFIG_STORAGE & STORAGE_MMC) || (CONFIG_STORAGE & STORAGE_SD)
2016 info
.callback_data
= (void*)&card
;
2019 info
.action_callback
= disk_callback
;
2020 info
.hide_selection
= true;
2021 info
.scroll_all
= true;
2022 return simplelist_show_list(&info
);
2024 #endif /* !SIMULATOR */
2026 #ifdef HAVE_DIRCACHE
2027 static int dircache_callback(int btn
, struct gui_synclist
*lists
)
2029 (void)btn
; (void)lists
;
2030 simplelist_set_line_count(0);
2031 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache initialized: %s",
2032 dircache_is_enabled() ? "Yes" : "No");
2033 simplelist_addline(SIMPLELIST_ADD_LINE
, "Cache size: %d B",
2034 dircache_get_cache_size());
2035 simplelist_addline(SIMPLELIST_ADD_LINE
, "Last size: %d B",
2036 global_status
.dircache_size
);
2037 simplelist_addline(SIMPLELIST_ADD_LINE
, "Limit: %d B",
2039 simplelist_addline(SIMPLELIST_ADD_LINE
, "Reserve: %d/%d B",
2040 dircache_get_reserve_used(), DIRCACHE_RESERVE
);
2041 simplelist_addline(SIMPLELIST_ADD_LINE
, "Scanning took: %d s",
2042 dircache_get_build_ticks() / HZ
);
2043 simplelist_addline(SIMPLELIST_ADD_LINE
, "Entry count: %d",
2044 dircache_get_entry_count());
2048 static bool dbg_dircache_info(void)
2050 struct simplelist_info info
;
2051 simplelist_info_init(&info
, "Dircache Info", 7, NULL
);
2052 info
.action_callback
= dircache_callback
;
2053 info
.hide_selection
= true;
2054 info
.scroll_all
= true;
2055 return simplelist_show_list(&info
);
2058 #endif /* HAVE_DIRCACHE */
2060 #ifdef HAVE_TAGCACHE
2061 static int database_callback(int btn
, struct gui_synclist
*lists
)
2064 struct tagcache_stat
*stat
= tagcache_get_stat();
2065 static bool synced
= false;
2067 simplelist_set_line_count(0);
2069 simplelist_addline(SIMPLELIST_ADD_LINE
, "Initialized: %s",
2070 stat
->initialized
? "Yes" : "No");
2071 simplelist_addline(SIMPLELIST_ADD_LINE
, "DB Ready: %s",
2072 stat
->ready
? "Yes" : "No");
2073 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM Cache: %s",
2074 stat
->ramcache
? "Yes" : "No");
2075 simplelist_addline(SIMPLELIST_ADD_LINE
, "RAM: %d/%d B",
2076 stat
->ramcache_used
, stat
->ramcache_allocated
);
2077 simplelist_addline(SIMPLELIST_ADD_LINE
, "Progress: %d%% (%d entries)",
2078 stat
->progress
, stat
->processed_entries
);
2079 simplelist_addline(SIMPLELIST_ADD_LINE
, "Curfile: %s",
2080 stat
->curentry
? stat
->curentry
: "---");
2081 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit step: %d",
2083 simplelist_addline(SIMPLELIST_ADD_LINE
, "Commit delayed: %s",
2084 stat
->commit_delayed
? "Yes" : "No");
2086 simplelist_addline(SIMPLELIST_ADD_LINE
, "Queue length: %d",
2087 stat
->queue_length
);
2092 tagcache_screensync_event();
2095 if (!btn
&& stat
->curentry
)
2098 return ACTION_REDRAW
;
2101 if (btn
== ACTION_STD_CANCEL
)
2102 tagcache_screensync_enable(false);
2106 static bool dbg_tagcache_info(void)
2108 struct simplelist_info info
;
2109 simplelist_info_init(&info
, "Database Info", 8, NULL
);
2110 info
.action_callback
= database_callback
;
2111 info
.hide_selection
= true;
2112 info
.scroll_all
= true;
2114 /* Don't do nonblock here, must give enough processing time
2115 for tagcache thread. */
2116 /* info.timeout = TIMEOUT_NOBLOCK; */
2118 tagcache_screensync_enable(true);
2119 return simplelist_show_list(&info
);
2123 #if CONFIG_CPU == SH7034
2124 static bool dbg_save_roms(void)
2127 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2129 fd
= creat("/internal_rom_0000-FFFF.bin");
2132 write(fd
, (void *)0, 0x10000);
2136 fd
= creat("/internal_rom_2000000-203FFFF.bin");
2139 write(fd
, (void *)0x2000000, 0x40000);
2143 system_memory_guard(oldmode
);
2146 #elif defined CPU_COLDFIRE
2147 static bool dbg_save_roms(void)
2150 int oldmode
= system_memory_guard(MEMGUARD_NONE
);
2152 #if defined(IRIVER_H100_SERIES)
2153 fd
= creat("/internal_rom_000000-1FFFFF.bin");
2154 #elif defined(IRIVER_H300_SERIES)
2155 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2156 #elif defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(IAUDIO_M3)
2157 fd
= creat("/internal_rom_000000-3FFFFF.bin");
2161 write(fd
, (void *)0, FLASH_SIZE
);
2164 system_memory_guard(oldmode
);
2167 fd
= creat("/internal_eeprom.bin");
2171 char buf
[EEPROM_SIZE
];
2174 old_irq_level
= disable_irq_save();
2176 err
= eeprom_24cxx_read(0, buf
, sizeof buf
);
2178 restore_irq(old_irq_level
);
2181 splashf(HZ
*3, "Eeprom read failure (%d)", err
);
2184 write(fd
, buf
, sizeof buf
);
2193 #elif defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)
2194 static bool dbg_save_roms(void)
2198 fd
= creat("/internal_rom_000000-0FFFFF.bin");
2201 write(fd
, (void *)0x20000000, FLASH_SIZE
);
2207 #elif CONFIG_CPU == IMX31L
2208 static bool dbg_save_roms(void)
2212 fd
= creat("/flash_rom_A0000000-A01FFFFF.bin");
2215 write(fd
, (void*)0xa0000000, FLASH_SIZE
);
2225 static int radio_callback(int btn
, struct gui_synclist
*lists
)
2228 if (btn
== ACTION_STD_CANCEL
)
2230 simplelist_set_line_count(1);
2232 #if (CONFIG_TUNER & LV24020LP)
2233 simplelist_addline(SIMPLELIST_ADD_LINE
,
2234 "CTRL_STAT: %02X", lv24020lp_get(LV24020LP_CTRL_STAT
) );
2235 simplelist_addline(SIMPLELIST_ADD_LINE
,
2236 "RADIO_STAT: %02X", lv24020lp_get(LV24020LP_REG_STAT
) );
2237 simplelist_addline(SIMPLELIST_ADD_LINE
,
2238 "MSS_FM: %d kHz", lv24020lp_get(LV24020LP_MSS_FM
) );
2239 simplelist_addline(SIMPLELIST_ADD_LINE
,
2240 "MSS_IF: %d Hz", lv24020lp_get(LV24020LP_MSS_IF
) );
2241 simplelist_addline(SIMPLELIST_ADD_LINE
,
2242 "MSS_SD: %d Hz", lv24020lp_get(LV24020LP_MSS_SD
) );
2243 simplelist_addline(SIMPLELIST_ADD_LINE
,
2244 "if_set: %d Hz", lv24020lp_get(LV24020LP_IF_SET
) );
2245 simplelist_addline(SIMPLELIST_ADD_LINE
,
2246 "sd_set: %d Hz", lv24020lp_get(LV24020LP_SD_SET
) );
2247 #endif /* LV24020LP */
2248 #if (CONFIG_TUNER & S1A0903X01)
2249 simplelist_addline(SIMPLELIST_ADD_LINE
,
2250 "Samsung regs: %08X", s1a0903x01_get(RADIO_ALL
));
2251 /* This one doesn't return dynamic data atm */
2252 #endif /* S1A0903X01 */
2253 #if (CONFIG_TUNER & TEA5767)
2254 struct tea5767_dbg_info nfo
;
2255 tea5767_dbg_info(&nfo
);
2256 simplelist_addline(SIMPLELIST_ADD_LINE
, "Philips regs:");
2257 simplelist_addline(SIMPLELIST_ADD_LINE
,
2258 " Read: %02X %02X %02X %02X %02X",
2259 (unsigned)nfo
.read_regs
[0], (unsigned)nfo
.read_regs
[1],
2260 (unsigned)nfo
.read_regs
[2], (unsigned)nfo
.read_regs
[3],
2261 (unsigned)nfo
.read_regs
[4]);
2262 simplelist_addline(SIMPLELIST_ADD_LINE
,
2263 " Write: %02X %02X %02X %02X %02X",
2264 (unsigned)nfo
.write_regs
[0], (unsigned)nfo
.write_regs
[1],
2265 (unsigned)nfo
.write_regs
[2], (unsigned)nfo
.write_regs
[3],
2266 (unsigned)nfo
.write_regs
[4]);
2267 #endif /* TEA5767 */
2268 #if (CONFIG_TUNER & SI4700)
2269 struct si4700_dbg_info nfo
;
2270 si4700_dbg_info(&nfo
);
2271 simplelist_addline(SIMPLELIST_ADD_LINE
, "SI4700 regs:");
2273 simplelist_addline(SIMPLELIST_ADD_LINE
,
2274 "%04X %04X %04X %04X",
2275 (unsigned)nfo
.regs
[0], (unsigned)nfo
.regs
[1],
2276 (unsigned)nfo
.regs
[2], (unsigned)nfo
.regs
[3]);
2277 simplelist_addline(SIMPLELIST_ADD_LINE
,
2278 "%04X %04X %04X %04X",
2279 (unsigned)nfo
.regs
[4], (unsigned)nfo
.regs
[5],
2280 (unsigned)nfo
.regs
[6], (unsigned)nfo
.regs
[7]);
2281 simplelist_addline(SIMPLELIST_ADD_LINE
,
2282 "%04X %04X %04X %04X",
2283 (unsigned)nfo
.regs
[8], (unsigned)nfo
.regs
[9],
2284 (unsigned)nfo
.regs
[10], (unsigned)nfo
.regs
[11]);
2285 simplelist_addline(SIMPLELIST_ADD_LINE
,
2286 "%04X %04X %04X %04X",
2287 (unsigned)nfo
.regs
[12], (unsigned)nfo
.regs
[13],
2288 (unsigned)nfo
.regs
[14], (unsigned)nfo
.regs
[15]);
2290 return ACTION_REDRAW
;
2292 static bool dbg_fm_radio(void)
2294 struct simplelist_info info
;
2295 info
.scroll_all
= true;
2296 simplelist_info_init(&info
, "FM Radio", 1, NULL
);
2297 simplelist_set_line_count(0);
2298 simplelist_addline(SIMPLELIST_ADD_LINE
, "HW detected: %s",
2299 radio_hardware_present() ? "yes" : "no");
2301 info
.action_callback
= radio_hardware_present()?radio_callback
: NULL
;
2302 info
.hide_selection
= true;
2303 return simplelist_show_list(&info
);
2305 #endif /* CONFIG_TUNER */
2306 #endif /* !SIMULATOR */
2308 #ifdef HAVE_LCD_BITMAP
2309 extern bool do_screendump_instead_of_usb
;
2311 static bool dbg_screendump(void)
2313 do_screendump_instead_of_usb
= !do_screendump_instead_of_usb
;
2314 splashf(HZ
, "Screendump %s",
2315 do_screendump_instead_of_usb
?"enabled":"disabled");
2318 #endif /* HAVE_LCD_BITMAP */
2320 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2321 static bool dbg_set_memory_guard(void)
2323 static const struct opt_items names
[MAXMEMGUARD
] = {
2325 { "Flash ROM writes", -1 },
2326 { "Zero area (all)", -1 }
2328 int mode
= system_memory_guard(MEMGUARD_KEEP
);
2330 set_option( "Catch mem accesses", &mode
, INT
, names
, MAXMEMGUARD
, NULL
);
2331 system_memory_guard(mode
);
2335 #endif /* CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) */
2337 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2338 static bool dbg_write_eeprom(void)
2343 char buf
[EEPROM_SIZE
];
2346 fd
= open("/internal_eeprom.bin", O_RDONLY
);
2350 rc
= read(fd
, buf
, EEPROM_SIZE
);
2352 if(rc
== EEPROM_SIZE
)
2354 old_irq_level
= disable_irq_save();
2356 err
= eeprom_24cxx_write(0, buf
, sizeof buf
);
2358 splashf(HZ
*3, "Eeprom write failure (%d)", err
);
2360 splash(HZ
*3, "Eeprom written successfully");
2362 restore_irq(old_irq_level
);
2366 splashf(HZ
*3, "File read error (%d)",rc
);
2372 splash(HZ
*3, "Failed to open 'internal_eeprom.bin'");
2377 #endif /* defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS) */
2378 #ifdef CPU_BOOST_LOGGING
2379 static bool cpu_boost_log(void)
2382 int count
= cpu_boost_log_getcount();
2383 int lines
= LCD_HEIGHT
/SYSFONT_HEIGHT
;
2386 lcd_setfont(FONT_SYSFIXED
);
2387 str
= cpu_boost_log_getlog_first();
2390 lcd_clear_display();
2391 for(j
=0; j
<lines
; j
++,i
++)
2394 str
= cpu_boost_log_getlog_next();
2397 if(strlen(str
) > LCD_WIDTH
/SYSFONT_WIDTH
)
2398 lcd_puts_scroll(0, j
, str
);
2408 switch(get_action(CONTEXT_STD
,TIMEOUT_BLOCK
))
2411 case ACTION_STD_PREV
:
2412 case ACTION_STD_NEXT
:
2415 case ACTION_STD_CANCEL
:
2422 get_action(CONTEXT_STD
,TIMEOUT_BLOCK
);
2423 lcd_setfont(FONT_UI
);
2428 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2429 extern bool wheel_is_touched
;
2430 extern int old_wheel_value
;
2431 extern int new_wheel_value
;
2432 extern int wheel_delta
;
2433 extern unsigned int accumulated_wheel_delta
;
2434 extern unsigned int wheel_velocity
;
2436 static bool dbg_scrollwheel(void)
2440 lcd_setfont(FONT_SYSFIXED
);
2444 if (action_userabort(HZ
/10))
2447 lcd_clear_display();
2449 /* show internal variables of scrollwheel driver */
2450 debug_printf(0, "wheel touched: %s", (wheel_is_touched
) ? "true" : "false");
2451 debug_printf(1, "new position: %2d", new_wheel_value
);
2452 debug_printf(2, "old position: %2d", old_wheel_value
);
2453 debug_printf(3, "wheel delta: %2d", wheel_delta
);
2454 debug_printf(4, "accumulated delta: %2d", accumulated_wheel_delta
);
2455 debug_printf(5, "velo [deg/s]: %4d", (int)wheel_velocity
);
2457 /* show effective accelerated scrollspeed */
2458 speed
= button_apply_acceleration( (1<<31)|(1<<24)|wheel_velocity
);
2459 debug_printf(6, "accel. speed: %4d", speed
);
2463 lcd_setfont(FONT_UI
);
2468 #if defined (HAVE_USBSTACK)
2470 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2471 static bool toggle_usb_core_driver(int driver
, char *msg
)
2473 bool enabled
= !usb_core_driver_enabled(driver
);
2475 usb_core_enable_driver(driver
,enabled
);
2476 splashf(HZ
, "%s %s", msg
, enabled
?"enabled":"disabled");
2481 static bool toggle_usb_serial(void)
2483 return toggle_usb_core_driver(USB_DRIVER_SERIAL
,"USB Serial");
2489 #if CONFIG_USBOTG == USBOTG_ISP1583
2490 extern int dbg_usb_num_items(void);
2491 extern const char* dbg_usb_item(int selected_item
, void *data
,
2492 char *buffer
, size_t buffer_len
);
2494 static int isp1583_action_callback(int action
, struct gui_synclist
*lists
)
2497 if (action
== ACTION_NONE
)
2498 action
= ACTION_REDRAW
;
2502 static bool dbg_isp1583(void)
2504 struct simplelist_info isp1583
;
2505 isp1583
.scroll_all
= true;
2506 simplelist_info_init(&isp1583
, "ISP1583", dbg_usb_num_items(), NULL
);
2507 isp1583
.timeout
= HZ
/100;
2508 isp1583
.hide_selection
= true;
2509 isp1583
.get_name
= dbg_usb_item
;
2510 isp1583
.action_callback
= isp1583_action_callback
;
2511 return simplelist_show_list(&isp1583
);
2515 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2516 extern int pic_dbg_num_items(void);
2517 extern const char* pic_dbg_item(int selected_item
, void *data
,
2518 char *buffer
, size_t buffer_len
);
2520 static int pic_action_callback(int action
, struct gui_synclist
*lists
)
2523 if (action
== ACTION_NONE
)
2524 action
= ACTION_REDRAW
;
2528 static bool dbg_pic(void)
2530 struct simplelist_info pic
;
2531 pic
.scroll_all
= true;
2532 simplelist_info_init(&pic
, "PIC", pic_dbg_num_items(), NULL
);
2533 pic
.timeout
= HZ
/100;
2534 pic
.hide_selection
= true;
2535 pic
.get_name
= pic_dbg_item
;
2536 pic
.action_callback
= pic_action_callback
;
2537 return simplelist_show_list(&pic
);
2542 /****** The menu *********/
2543 struct the_menu_item
{
2544 unsigned char *desc
; /* string or ID */
2545 bool (*function
) (void); /* return true if USB was connected */
2547 static const struct the_menu_item menuitems
[] = {
2548 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \
2549 (defined(CPU_PP) && !(CONFIG_STORAGE & STORAGE_SD)) || \
2550 CONFIG_CPU == IMX31L
2551 { "Dump ROM contents", dbg_save_roms
},
2553 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) \
2554 || CONFIG_CPU == S3C2440 || CONFIG_CPU == IMX31L || CONFIG_CPU == AS3525 \
2555 || CONFIG_CPU == DM320 || defined(CPU_S5L870X)
2556 { "View I/O ports", dbg_ports
},
2558 #if (CONFIG_RTC == RTC_PCF50605) && !defined(SIMULATOR)
2559 { "View PCF registers", dbg_pcf
},
2561 #if defined(HAVE_TSC2100) && !defined(SIMULATOR)
2562 { "TSC2100 debug", tsc2100_debug
},
2564 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
2565 { "CPU frequency", dbg_cpufreq
},
2567 #if defined(IRIVER_H100_SERIES) && !defined(SIMULATOR)
2568 { "S/PDIF analyzer", dbg_spdif
},
2570 #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE)
2571 { "Catch mem accesses", dbg_set_memory_guard
},
2573 { "View OS stacks", dbg_os
},
2574 #ifdef HAVE_LCD_BITMAP
2576 { "View battery", view_battery
},
2578 { "Screendump", dbg_screendump
},
2581 { "View HW info", dbg_hw_info
},
2584 { "View partitions", dbg_partitions
},
2587 { "View disk info", dbg_disk_info
},
2588 #if (CONFIG_STORAGE & STORAGE_ATA)
2589 { "Dump ATA identify info", dbg_identify_info
},
2592 #ifdef HAVE_DIRCACHE
2593 { "View dircache info", dbg_dircache_info
},
2595 #ifdef HAVE_TAGCACHE
2596 { "View database info", dbg_tagcache_info
},
2598 #ifdef HAVE_LCD_BITMAP
2599 #if CONFIG_CODEC == SWCODEC
2600 { "View buffering thread", dbg_buffering_thread
},
2601 #elif !defined(SIMULATOR)
2602 { "View audio thread", dbg_audio_thread
},
2605 { "pm histogram", peak_meter_histogram
},
2606 #endif /* PM_DEBUG */
2607 #endif /* HAVE_LCD_BITMAP */
2610 { "FM Radio", dbg_fm_radio
},
2613 #if defined(HAVE_EEPROM) && !defined(HAVE_EEPROM_SETTINGS)
2614 { "Write back EEPROM", dbg_write_eeprom
},
2616 #if CONFIG_USBOTG == USBOTG_ISP1583
2617 { "View ISP1583 info", dbg_isp1583
},
2619 #if defined(CREATIVE_ZVx) && !defined(SIMULATOR)
2620 { "View PIC info", dbg_pic
},
2622 #ifdef ROCKBOX_HAS_LOGF
2623 {"logf", logfdisplay
},
2624 {"logfdump", logfdump
},
2626 #if defined(HAVE_USBSTACK)
2627 #if defined(ROCKBOX_HAS_LOGF) && defined(USB_ENABLE_SERIAL)
2628 {"USB Serial driver (logf)", toggle_usb_serial
},
2630 #endif /* HAVE_USBSTACK */
2631 #ifdef CPU_BOOST_LOGGING
2632 {"cpu_boost log",cpu_boost_log
},
2634 #if (defined(HAVE_WHEEL_ACCELERATION) && (CONFIG_KEYPAD==IPOD_4G_PAD) && !defined(SIMULATOR))
2635 {"Debug scrollwheel", dbg_scrollwheel
},
2638 static int menu_action_callback(int btn
, struct gui_synclist
*lists
)
2640 if (btn
== ACTION_STD_OK
)
2642 int oldbars
= viewportmanager_set_statusbar(VP_SB_HIDE_ALL
);
2643 menuitems
[gui_synclist_get_sel_pos(lists
)].function();
2644 btn
= ACTION_REDRAW
;
2645 send_event(GUI_EVENT_REFRESH
, NULL
);
2646 viewportmanager_set_statusbar(oldbars
);
2651 static const char* dbg_menu_getname(int item
, void * data
,
2652 char *buffer
, size_t buffer_len
)
2654 (void)data
; (void)buffer
; (void)buffer_len
;
2655 return menuitems
[item
].desc
;
2658 bool debug_menu(void)
2660 struct simplelist_info info
;
2662 simplelist_info_init(&info
, "Debug Menu", ARRAYLEN(menuitems
), NULL
);
2663 info
.action_callback
= menu_action_callback
;
2664 info
.get_name
= dbg_menu_getname
;
2665 return simplelist_show_list(&info
);