1 2/********************************************************************* 3* 4* OnProjectLoad 5* 6* Function description 7* Project load routine. Required. 8* 9********************************************************************** 10*/ 11void OnProjectLoad (void) { 12 // 13 // Dialog-generated settings 14 // 15 Project.SetDevice ("STM32F407VG"); 16 Project.SetHostIF ("USB", ""); 17 Project.SetTargetIF ("SWD"); 18 Project.SetTIFSpeed ("50 MHz"); 19 Project.AddSvdFile ("$(InstallDir)/Config/CPU/Cortex-M4F.svd"); 20 Project.AddPathSubstitute ("/Projects/btstack/port/stm32-f4discovery-cc256x/cubemx-f4discovery-cc256x", "$(ProjectDir)"); 21 Project.AddPathSubstitute ("/projects/btstack/port/stm32-f4discovery-cc256x/cubemx-f4discovery-cc256x", "$(ProjectDir)"); 22 // 23 // User settings 24 // 25 File.Open ("$(ProjectDir)/EXAMPLE.elf"); 26} 27 28/********************************************************************* 29* 30* TargetReset 31* 32* Function description 33* Replaces the default target device reset routine. Optional. 34* 35* Notes 36* This example demonstrates the usage when 37* debugging a RAM program on a Cortex-M target device 38* 39********************************************************************** 40*/ 41//void TargetReset (void) { 42// 43// unsigned int SP; 44// unsigned int PC; 45// unsigned int VectorTableAddr; 46// 47// Exec.Reset(); 48// 49// VectorTableAddr = Elf.GetBaseAddr(); 50// 51// if (VectorTableAddr != 0xFFFFFFFF) { 52// 53// Util.Log("Resetting Program."); 54// 55// SP = Target.ReadU32(VectorTableAddr); 56// Target.SetReg("SP", SP); 57// 58// PC = Target.ReadU32(VectorTableAddr + 4); 59// Target.SetReg("PC", PC); 60// } 61//} 62 63/********************************************************************* 64* 65* BeforeTargetReset 66* 67* Function description 68* Event handler routine. Optional. 69* 70********************************************************************** 71*/ 72//void BeforeTargetReset (void) { 73//} 74 75/********************************************************************* 76* 77* AfterTargetReset 78* 79* Function description 80* Event handler routine. 81* - Sets the PC register to program reset value. 82* - Sets the SP register to program reset value on Cortex-M. 83* 84********************************************************************** 85*/ 86void AfterTargetReset (void) { 87 unsigned int SP; 88 unsigned int PC; 89 unsigned int VectorTableAddr; 90 91 VectorTableAddr = Elf.GetBaseAddr(); 92 93 if (VectorTableAddr == 0xFFFFFFFF) { 94 Util.Log("Project file error: failed to get program base"); 95 } else { 96 SP = Target.ReadU32(VectorTableAddr); 97 Target.SetReg("SP", SP); 98 99 PC = Target.ReadU32(VectorTableAddr + 4); 100 Target.SetReg("PC", PC); 101 } 102} 103 104/********************************************************************* 105* 106* DebugStart 107* 108* Function description 109* Replaces the default debug session startup routine. Optional. 110* 111********************************************************************** 112*/ 113//void DebugStart (void) { 114//} 115 116/********************************************************************* 117* 118* TargetConnect 119* 120* Function description 121* Replaces the default target IF connection routine. Optional. 122* 123********************************************************************** 124*/ 125//void TargetConnect (void) { 126//} 127 128/********************************************************************* 129* 130* BeforeTargetConnect 131* 132* Function description 133* Event handler routine. Optional. 134* 135********************************************************************** 136*/ 137//void BeforeTargetConnect (void) { 138//} 139 140/********************************************************************* 141* 142* AfterTargetConnect 143* 144* Function description 145* Event handler routine. Optional. 146* 147********************************************************************** 148*/ 149//void AfterTargetConnect (void) { 150//} 151 152/********************************************************************* 153* 154* TargetDownload 155* 156* Function description 157* Replaces the default program download routine. Optional. 158* 159********************************************************************** 160*/ 161//void TargetDownload (void) { 162//} 163 164/********************************************************************* 165* 166* BeforeTargetDownload 167* 168* Function description 169* Event handler routine. Optional. 170* 171********************************************************************** 172*/ 173//void BeforeTargetDownload (void) { 174//} 175 176/********************************************************************* 177* 178* AfterTargetDownload 179* 180* Function description 181* Event handler routine. 182* - Sets the PC register to program reset value. 183* - Sets the SP register to program reset value on Cortex-M. 184* 185********************************************************************** 186*/ 187void AfterTargetDownload (void) { 188 unsigned int SP; 189 unsigned int PC; 190 unsigned int VectorTableAddr; 191 192 VectorTableAddr = Elf.GetBaseAddr(); 193 194 if (VectorTableAddr == 0xFFFFFFFF) { 195 Util.Log("Project file error: failed to get program base"); 196 } else { 197 SP = Target.ReadU32(VectorTableAddr); 198 Target.SetReg("SP", SP); 199 200 PC = Target.ReadU32(VectorTableAddr + 4); 201 Target.SetReg("PC", PC); 202 } 203} 204 205/********************************************************************* 206* 207* BeforeTargetDisconnect 208* 209* Function description 210* Event handler routine. Optional. 211* 212********************************************************************** 213*/ 214//void BeforeTargetDisconnect (void) { 215//} 216 217/********************************************************************* 218* 219* AfterTargetDisconnect 220* 221* Function description 222* Event handler routine. Optional. 223* 224********************************************************************** 225*/ 226//void AfterTargetDisconnect (void) { 227//} 228 229/********************************************************************* 230* 231* AfterTargetHalt 232* 233* Function description 234* Event handler routine. Optional. 235* 236********************************************************************** 237*/ 238//void AfterTargetHalt (void) { 239//} 240