1# this method initializes debug modules which are not affected by software reset 2# register names should be referenced including the register group name to improve performance 3 4proc init_debug_modules {} { 5 # initialize LR to avoid invalid stack after reset 6 reg "User\\/System Mode Registers/LR" = 0xFFFFFFFF 7 8 # clear DWT function registers 9 reg "Core Debug Registers/DEMCR" = 0x1000001 10 reg "Data Watchpoint and Trace Unit Registers/DWT_FUNCTION0" = 0x0 11 reg "Data Watchpoint and Trace Unit Registers/DWT_FUNCTION1" = 0x0 12 reg "Data Watchpoint and Trace Unit Registers/DWT_FUNCTION2" = 0x0 13 reg "Data Watchpoint and Trace Unit Registers/DWT_FUNCTION3" = 0x0 14 # clear FPB comparators 15 reg "Flash Patch and Breakpoint Unit Registers/FP_COMP0" = 0x0 16 reg "Flash Patch and Breakpoint Unit Registers/FP_COMP1" = 0x0 17 reg "Flash Patch and Breakpoint Unit Registers/FP_COMP2" = 0x0 18 reg "Flash Patch and Breakpoint Unit Registers/FP_COMP3" = 0x0 19 reg "Flash Patch and Breakpoint Unit Registers/FP_COMP4" = 0x0 20 reg "Flash Patch and Breakpoint Unit Registers/FP_COMP5" = 0x0 21} 22 23proc init_trace_modules {} { 24 # clear DWT registers 25 reg "Data Watchpoint and Trace Unit Registers/DWT_CTRL" =0x40000000 26 reg "Data Watchpoint and Trace Unit Registers/DWT_CYCCNT" =0x0 27 reg "Data Watchpoint and Trace Unit Registers/DWT_CPICNT" =0x0 28 reg "Data Watchpoint and Trace Unit Registers/DWT_EXCCNT" =0x0 29 reg "Data Watchpoint and Trace Unit Registers/DWT_SLEEPCNT" =0x0 30 reg "Data Watchpoint and Trace Unit Registers/DWT_LSUCNT" =0x0 31 reg "Data Watchpoint and Trace Unit Registers/DWT_FOLDCNT" =0x0 32 reg "Data Watchpoint and Trace Unit Registers/DWT_COMP0" =0x0 33 reg "Data Watchpoint and Trace Unit Registers/DWT_COMP1" =0x0 34 reg "Data Watchpoint and Trace Unit Registers/DWT_COMP2" =0x0 35 reg "Data Watchpoint and Trace Unit Registers/DWT_COMP3" =0x0 36 reg "Data Watchpoint and Trace Unit Registers/DWT_MASK0" =0x0 37 reg "Data Watchpoint and Trace Unit Registers/DWT_MASK1" =0x0 38 reg "Data Watchpoint and Trace Unit Registers/DWT_MASK2" =0x0 39 reg "Data Watchpoint and Trace Unit Registers/DWT_MASK3" =0x0 40 # clear ITM registers 41 reg "Instrumentation Trace Macrocell Registers/ITM_LAR" =0xc5acce55 42 reg "Instrumentation Trace Macrocell Registers/ITM_TER" =0x0 43 reg "Instrumentation Trace Macrocell Registers/ITM_TPR" =0x0 44 reg "Instrumentation Trace Macrocell Registers/ITM_TCR" =0x0 45 reg "Instrumentation Trace Macrocell Registers/ITM_LAR" =0x1 46 # reset Funnel registers 47 reg "Embedded Trace Funnel Registers/ETF_FCR" =0x300 48 # clear MCM registers 49 reg "Core Platform Miscellaneous Control Module (MCM) Registers/MCM_ETBCC" =0x0 50 reg "Core Platform Miscellaneous Control Module (MCM) Registers/MCM_ETBRL" =0x0 51 # set SCB_VTOR register for RAM 52 reg "System Control Registers/SCB_VTOR" =0x20000000 53} 54 55proc envsetup {} { 56 # Environment Setup 57 radix x 58 config hexprefix 0x 59 config MemIdentifier p 60 config MemWidth 32 61 config MemAccess 32 62 config MemSwap off 63} 64 65#------------------------------------------------------------------------------- 66# Main 67#------------------------------------------------------------------------------- 68 69 envsetup 70 init_debug_modules 71 init_trace_modules 72