Difference between revisions of "Start debug session with bootloader"

From SEGGER Wiki
Jump to: navigation, search
(How to)
(Redirected page to SEGGER Ozone)
Line 1: Line 1:
  +
#REDIRECT [[SEGGER_Ozone]]
__TOC__
 
 
Whenever a new project is created with Ozone, Ozone will assume that the .elf file you opened also points to the starting point of your application. This is usually the case. However should you have e.g. a bootloader that needs to be executed first the Ozone project must be edited accordingly.
 
 
= How to =
 
Each Ozone project is saved as a .jebug file. The Ozone project itself is written in a C-like scripting language and can be edited if needed. Per default functions ''AfterTargetDownload('') and ''AfterTargetReset()'' will be populated with the following code lines for Cortex-M:
 
 
<pre>
 
unsigned int SP;
 
unsigned int PC;
 
unsigned int VectorTableAddr;
 
 
VectorTableAddr = Elf.GetBaseAddr();
 
 
if (VectorTableAddr == 0xFFFFFFFF) {
 
Util.Log("Project file error: failed to get program base");
 
} else {
 
SP = Target.ReadU32(VectorTableAddr);
 
Target.SetReg("SP", SP);
 
 
PC = Target.ReadU32(VectorTableAddr + 4);
 
Target.SetReg("PC", PC);
 
}
 
</pre>
 
 
And the following for ARM or Cortex-A/R:
 
 
<pre>
 
unsigned int PC;
 
unsigned int CPSR;
 
 
PC = Elf.GetBaseAddr();
 
 
if (PC != 0xFFFFFFFF) {
 
Target.SetReg("PC", PC);
 
} else {
 
Util.Log("Project file error: failed to get program base");
 
}
 
</pre>
 
 
Either way the PC will be set to a wrong position if first a bootloader needs to be executed.
 
To counter this the .jdebug default values need to be edited as follows:
 
 
<pre>
 
unsigned int SP;
 
unsigned int PC;
 
 
SP = Target.ReadU32(<SPLocation>);
 
Target.SetReg("SP", SP);
 
 
PC = Target.ReadU32(<PCLocation>);
 
Target.SetReg("PC", PC);
 
</pre>
 
 
Where ''<PCLocation>'' and ''<SPLocation>'' are the addresses (e.g. 0x00000000) where PC and SP are stored. For Cortex-M target this is usually at ''BootloaderBaseAddr + 0x0'' for SP and ''BootloaderBaseAddr + 0x4'' for PC.
 
 
= Example project =
 
Example projects can be found for the following devices:
 

Revision as of 18:00, 23 October 2018

Redirect to: