summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 2b14de8714..c5f79a075f 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -132,6 +132,10 @@
132#include "rb-loader.h" 132#include "rb-loader.h"
133#endif 133#endif
134 134
135#if defined(IPOD_6G)
136#include "nor-target.h"
137#endif
138
135#define SCREEN_MAX_CHARS (LCD_WIDTH / SYSFONT_WIDTH) 139#define SCREEN_MAX_CHARS (LCD_WIDTH / SYSFONT_WIDTH)
136 140
137static const char* threads_getname(int selected_item, void *data, 141static const char* threads_getname(int selected_item, void *data,
@@ -2581,6 +2585,95 @@ static bool dbg_boot_data(void)
2581} 2585}
2582#endif /* defined(HAVE_BOOTDATA) && !defined(SIMULATOR) */ 2586#endif /* defined(HAVE_BOOTDATA) && !defined(SIMULATOR) */
2583 2587
2588#if defined(IPOD_6G)
2589#define SYSCFG_MAX_ENTRIES 10 // 9 on iPod Classic/6G
2590
2591static bool dbg_syscfg(void) {
2592 struct simplelist_info info;
2593 struct SysCfgHeader syscfg_hdr;
2594 size_t syscfg_hdr_size = sizeof(struct SysCfgHeader);
2595 size_t syscfg_entry_size = sizeof(struct SysCfgEntry);
2596 struct SysCfgEntry syscfg_entries[SYSCFG_MAX_ENTRIES];
2597
2598 simplelist_info_init(&info, "SysCfg NOR contents", 1, NULL);
2599 simplelist_set_line_count(0);
2600
2601 bootflash_init(SPI_PORT);
2602 bootflash_read(SPI_PORT, 0, syscfg_hdr_size, &syscfg_hdr);
2603
2604 if (syscfg_hdr.magic != SYSCFG_MAGIC) {
2605 simplelist_addline("SCfg magic not found");
2606 bootflash_close(SPI_PORT);
2607 return simplelist_show_list(&info);
2608 }
2609
2610 simplelist_addline("Total size: %u bytes", syscfg_hdr.size);
2611 simplelist_addline("Entries: %u", syscfg_hdr.num_entries);
2612
2613 size_t calculated_syscfg_size = syscfg_hdr_size + syscfg_entry_size * syscfg_hdr.num_entries;
2614
2615 if (syscfg_hdr.size != calculated_syscfg_size) {
2616 simplelist_addline("Wrong size: expected %u, got %u", calculated_syscfg_size, syscfg_hdr.size);
2617 bootflash_close(SPI_PORT);
2618 return simplelist_show_list(&info);
2619 }
2620
2621 if (syscfg_hdr.num_entries > SYSCFG_MAX_ENTRIES) {
2622 simplelist_addline("Too many entries, showing first %u", syscfg_hdr.num_entries);
2623 }
2624
2625 size_t syscfg_num_entries = MIN(syscfg_hdr.num_entries, SYSCFG_MAX_ENTRIES);
2626 size_t syscfg_entries_size = syscfg_entry_size * syscfg_num_entries;
2627
2628 bootflash_read(SPI_PORT, syscfg_hdr_size, syscfg_entries_size, &syscfg_entries);
2629 bootflash_close(SPI_PORT);
2630
2631 for (size_t i = 0; i < syscfg_num_entries; i++) {
2632 struct SysCfgEntry* entry = &syscfg_entries[i];
2633 char* tag = (char *)&entry->tag;
2634 uint32_t* data32 = (uint32_t *)entry->data;
2635
2636 switch (entry->tag) {
2637 case SYSCFG_TAG_SRNM:
2638 simplelist_addline("Serial number (SrNm): %s", entry->data);
2639 break;
2640 case SYSCFG_TAG_FWID:
2641 simplelist_addline("Firmware ID (FwId): %07X", data32[1] & 0x0FFFFFFF);
2642 break;
2643 case SYSCFG_TAG_HWID:
2644 simplelist_addline("Hardware ID (HwId): %08X", data32[0]);
2645 break;
2646 case SYSCFG_TAG_HWVR:
2647 simplelist_addline("Hardware version (HwVr): %06X", data32[1]);
2648 break;
2649 case SYSCFG_TAG_CODC:
2650 simplelist_addline("Codec (Codc): %s", entry->data);
2651 break;
2652 case SYSCFG_TAG_SWVR:
2653 simplelist_addline("Software version (SwVr): %s", entry->data);
2654 break;
2655 case SYSCFG_TAG_MLBN:
2656 simplelist_addline("Logic board serial number (MLBN): %s", entry->data);
2657 break;
2658 case SYSCFG_TAG_MODN:
2659 simplelist_addline("Model number (Mod#): %s", entry->data);
2660 break;
2661 case SYSCFG_TAG_REGN:
2662 simplelist_addline("Sales region (Regn): %08X %08X", data32[0], data32[1]);
2663 break;
2664 default:
2665 simplelist_addline("%c%c%c%c: %08X %08X %08X %08X",
2666 tag[3], tag[2], tag[1], tag[0],
2667 data32[0], data32[1], data32[2], data32[3]
2668 );
2669 break;
2670 }
2671 }
2672
2673 return simplelist_show_list(&info);
2674}
2675#endif
2676
2584/****** The menu *********/ 2677/****** The menu *********/
2585static const struct { 2678static const struct {
2586 unsigned char *desc; /* string or ID */ 2679 unsigned char *desc; /* string or ID */
@@ -2691,6 +2784,9 @@ static const struct {
2691#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) 2784#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR)
2692 {"Boot data", dbg_boot_data }, 2785 {"Boot data", dbg_boot_data },
2693#endif 2786#endif
2787#if defined(IPOD_6G)
2788 {"View SysCfg", dbg_syscfg },
2789#endif
2694}; 2790};
2695 2791
2696static int menu_action_callback(int btn, struct gui_synclist *lists) 2792static int menu_action_callback(int btn, struct gui_synclist *lists)