Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

echoplayer: allow enabling system debug in normal builds

Allow toggling the system debug state from the debug menu
in Rockbox, or by holding a button combo at boot, so that
an SWD/JTAG debugger can be attached to normal non-debug
builds without too much hassle.

Change-Id: Iee47ef916ade2e5ec1094a63c68e48f1b27b0bbb

authored by

Aidan MacDonald and committed by
Solomon Peachy
19af7131 02648abb

+131 -1
+16
bootloader/echoplayer.c
··· 34 34 #include "rbversion.h" 35 35 #include "system-echoplayer.h" 36 36 #include "gpio-stm32h7.h" 37 + #include "regs/cortex-m/cm_debug.h" 37 38 38 39 #define SDRAM_SIZE (MEMORYSIZE * 1024 * 1024) 39 40 ··· 134 135 static bool is_usbmode_button_pressed(void) 135 136 { 136 137 return button_status() & BUTTON_DOWN; 138 + } 139 + 140 + static bool is_sysdebug_button_pressed(void) 141 + { 142 + const int mask = BUTTON_A | BUTTON_B; 143 + 144 + /* Both buttons must be held */ 145 + return (button_status() & mask) == mask; 137 146 } 138 147 139 148 static int send_event_on_tmo(struct timeout *tmo) ··· 369 378 kernel_init(); 370 379 power_init(); 371 380 button_init(); 381 + 382 + /* Enable system debugging if button combo held or debugger attached */ 383 + if (reg_readf(CM_DEBUG_DHCSR, C_DEBUGEN) || 384 + is_sysdebug_button_pressed()) 385 + { 386 + system_debug_enable(true); 387 + } 372 388 373 389 /* Start monitoring power button / usb state */ 374 390 monitor_init();
+2
firmware/SOURCES
··· 1943 1943 target/arm/stm32/crt0-stm32h7.S 1944 1944 target/arm/stm32/vectors-stm32h7.S 1945 1945 target/arm/stm32/adc-stm32h7.c 1946 + #ifndef BOOTLOADER 1946 1947 target/arm/stm32/debug-stm32h7.c 1948 + #endif 1947 1949 target/arm/stm32/gpio-stm32h7.c 1948 1950 target/arm/stm32/i2c-stm32h7.c 1949 1951 target/arm/stm32/pcm-stm32h7.c
+7
firmware/reggen/cortex-m.regs
··· 168 168 23 00 TENMS 169 169 } 170 170 } 171 + 172 + // Debug 173 + CM_DEBUG @ 0xe000edf0 : block { 174 + DHCSR @ 0x00 : reg { 175 + 0 C_DEBUGEN 176 + } 177 + }
+106 -1
firmware/target/arm/stm32/debug-stm32h7.c
··· 19 19 * 20 20 ****************************************************************************/ 21 21 #include "system.h" 22 + #include "kernel.h" 23 + #include "button.h" 24 + #include "lcd.h" 25 + #include "font.h" 26 + #include "action.h" 27 + #include "list.h" 28 + #include "regs/stm32h743/dbgmcu.h" 29 + #include "regs/cortex-m/cm_debug.h" 30 + #include <stdio.h> 31 + 32 + enum 33 + { 34 + SWD_MENU_IS_ENABLED, 35 + SWD_MENU_IS_ATTACHED, 36 + SWD_MENU_NUM_ENTRIES 37 + }; 38 + 39 + static int swd_menu_action_cb(int action, struct gui_synclist *lists) 40 + { 41 + int sel = gui_synclist_get_sel_pos(lists); 42 + 43 + if (sel == SWD_MENU_IS_ENABLED && action == ACTION_STD_OK) 44 + { 45 + if (reg_readf(DBGMCU_CR, DBGSLEEP_D1)) 46 + system_debug_enable(false); 47 + else 48 + system_debug_enable(true); 49 + 50 + action = ACTION_REDRAW; 51 + } 52 + 53 + if (action == ACTION_NONE) 54 + action = ACTION_REDRAW; 55 + 56 + return action; 57 + } 58 + 59 + static const char *swd_menu_get_name(int item, void *data, char *buf, size_t bufsz) 60 + { 61 + (void)data; 62 + 63 + switch (item) 64 + { 65 + case SWD_MENU_IS_ENABLED: 66 + snprintf(buf, bufsz, "System debug enabled: %d", 67 + (int)!!reg_readf(DBGMCU_CR, DBGSLEEP_D1)); 68 + return buf; 69 + 70 + case SWD_MENU_IS_ATTACHED: 71 + snprintf(buf, bufsz, "DHCSR.C_DEBUGEN bit: %d", 72 + (int)!!reg_readf(CM_DEBUG_DHCSR, C_DEBUGEN)); 73 + return buf; 74 + 75 + default: 76 + return ""; 77 + } 78 + } 79 + 80 + static bool swd_menu(void) 81 + { 82 + struct simplelist_info info; 83 + simplelist_info_init(&info, "SWD/JTAG", SWD_MENU_NUM_ENTRIES, NULL); 84 + info.action_callback = swd_menu_action_cb; 85 + info.get_name = swd_menu_get_name; 86 + return simplelist_show_list(&info); 87 + } 88 + 89 + /* Menu definition */ 90 + static const struct { 91 + const char *name; 92 + bool (*function) (void); 93 + } menuitems[] = { 94 + {"SWD/JTAG", swd_menu}, 95 + }; 96 + 97 + static int hw_info_menu_action_cb(int btn, struct gui_synclist *lists) 98 + { 99 + if (btn == ACTION_STD_OK) 100 + { 101 + int sel = gui_synclist_get_sel_pos(lists); 102 + FOR_NB_SCREENS(i) 103 + viewportmanager_theme_enable(i, false, NULL); 104 + 105 + menuitems[sel].function(); 106 + btn = ACTION_REDRAW; 107 + 108 + FOR_NB_SCREENS(i) 109 + viewportmanager_theme_undo(i, false); 110 + } 111 + 112 + return btn; 113 + } 114 + 115 + static const char* hw_info_menu_get_name(int item, void *data, char *buf, size_t bufsz) 116 + { 117 + (void)buf; 118 + (void)bufsz; 119 + (void)data; 120 + return menuitems[item].name; 121 + } 22 122 23 123 bool dbg_hw_info(void) 24 124 { 25 - return false; 125 + struct simplelist_info info; 126 + simplelist_info_init(&info, MODEL_NAME " debug menu", 127 + ARRAYLEN(menuitems), NULL); 128 + info.action_callback = hw_info_menu_action_cb; 129 + info.get_name = hw_info_menu_get_name; 130 + return simplelist_show_list(&info); 26 131 } 27 132 28 133 bool dbg_ports(void)