Difference between revisions of "ConfigTargetSettings()"

From SEGGER Wiki
Jump to: navigation, search
 
(9 intermediate revisions by the same user not shown)
Line 4: Line 4:
 
May also be used to specify the device name in case debugger does not pass it to the DLL.
 
May also be used to specify the device name in case debugger does not pass it to the DLL.
   
  +
__TOC__
___TOC___
 
   
 
== Prototype ==
 
== Prototype ==
Line 11: Line 11:
 
May not, under absolutely NO circumstances, call any API functions that perform target communication.
 
May not, under absolutely NO circumstances, call any API functions that perform target communication.
 
* Should only set some global DLL variables
 
* Should only set some global DLL variables
==Defining the JTAG chain==
+
== Use cases ==
  +
===Defining the JTAG chain===
<source lang="c">
 
  +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
  +
<div style="font-weight:bold;line-height:1.6;">Example code</div>
  +
<div class="mw-collapsible-content">
  +
<syntaxhighlight lang="c" class="collapsible">
 
int ConfigTargetSettings(void) {
 
int ConfigTargetSettings(void) {
 
JLINK_JTAG_DRPre = 0;
 
JLINK_JTAG_DRPre = 0;
Line 21: Line 25:
 
JLINK_JTAG_SetDeviceId(0, 0x1BB6402F);
 
JLINK_JTAG_SetDeviceId(0, 0x1BB6402F);
 
return 0;
 
return 0;
  +
}
}</source>
 
  +
</syntaxhighlight>
==Defining the AP map==
 
  +
</div></div>
<source lang="c">
 
  +
  +
===Defining the AP map===
  +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
  +
<div style="font-weight:bold;line-height:1.6;">Example code</div>
  +
<div class="mw-collapsible-content">
  +
<syntaxhighlight lang="c" class="collapsible">
 
int ConfigTargetSettings(void) {
 
int ConfigTargetSettings(void) {
 
JLINK_CORESIGHT_AddAP(0, CORESIGHT_AHB_AP); // AP0
 
JLINK_CORESIGHT_AddAP(0, CORESIGHT_AHB_AP); // AP0
Line 29: Line 39:
 
JLINK_CORESIGHT_AddAP(2, CORESIGHT_APB_AP); // AP2
 
JLINK_CORESIGHT_AddAP(2, CORESIGHT_APB_AP); // AP2
 
return 0;
 
return 0;
  +
}
}</source>
 
  +
</syntaxhighlight>
==Selecting a specific AP==
 
  +
</div></div>
<source lang="c">
 
  +
  +
===Selecting a specific AP===
  +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
  +
<div style="font-weight:bold;line-height:1.6;">Example code</div>
  +
<div class="mw-collapsible-content">
  +
<syntaxhighlight lang="c" class="collapsible">
 
int ConfigTargetSettings(void) {
 
int ConfigTargetSettings(void) {
 
JLINK_CORESIGHT_IndexAHBAPToUse = 0; // Select AP0 as AHB-AP
 
JLINK_CORESIGHT_IndexAHBAPToUse = 0; // Select AP0 as AHB-AP
 
JLINK_CORESIGHT_IndexAPBAPToUse = 2; // Select AP2 as APB-AP
 
JLINK_CORESIGHT_IndexAPBAPToUse = 2; // Select AP2 as APB-AP
 
return 0;
 
return 0;
  +
}
}</source>
 
  +
</syntaxhighlight>
  +
</div></div>
  +
  +
===Exclude illegal regions===
  +
The map region command can be used to exclude certain memory region(s). The J-Link DLL will ignore all read / write accesses to the specified region(s). This can be used if an IDE for example accesses an illegal memory address for some reason.
  +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
  +
<div style="font-weight:bold;line-height:1.6;">Example code</div>
  +
<div class="mw-collapsible-content">
  +
<syntaxhighlight lang="c" class="collapsible">
  +
int ConfigTargetSettings(void) {
  +
JLINK_ExecCommand("map region 0xC0000000-0xC000FFFF X");
  +
return 0;
  +
}
  +
</syntaxhighlight>
  +
</div></div>
  +
  +
===Initialize work RAM on connect===
  +
ECC RAM needs to be initialized to be used by the J-Link as work RAM. This code makes sure that the RAM is initialized on Connect.
  +
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;">
  +
<div style="font-weight:bold;line-height:1.6;">Example code</div>
  +
<div class="mw-collapsible-content">
  +
<syntaxhighlight lang="c" class="collapsible">
  +
int ConfigTargetSettings(void) {
  +
JLINK_ExecCommand("SetInitWorkRAMOnConnect = 1");
  +
return 0;
  +
}
  +
</syntaxhighlight>
  +
</div></div>

Latest revision as of 12:04, 22 April 2024

Called before InitTarget(). Mainly used to set some global DLL variables to customize the normal connect procedure. For ARM CoreSight devices this may be specifying the base address of some CoreSight components (ETM, CTI, ...) that cannot be auto-detected by J-Link due to erroneous ROM tables etc. May also be used to specify the device name in case debugger does not pass it to the DLL.

Prototype

int ConfigTargetSettings(void);

Notes and Limitations

May not, under absolutely NO circumstances, call any API functions that perform target communication.

  • Should only set some global DLL variables

Use cases

Defining the JTAG chain

Example code
int ConfigTargetSettings(void) {
  JLINK_JTAG_DRPre  = 0;
  JLINK_JTAG_DRPost = 0;
  JLINK_JTAG_IRPre  = 0;
  JLINK_JTAG_IRPost = 0;
  JLINK_JTAG_IRLen  = 4;
  JLINK_JTAG_SetDeviceId(0, 0x1BB6402F);
  return 0;
}

Defining the AP map

Example code
int ConfigTargetSettings(void) { 
  JLINK_CORESIGHT_AddAP(0, CORESIGHT_AHB_AP);  // AP0
  JLINK_CORESIGHT_AddAP(1, CORESIGHT_AHB_AP);  // AP1
  JLINK_CORESIGHT_AddAP(2, CORESIGHT_APB_AP);  // AP2
  return 0;
}

Selecting a specific AP

Example code
int ConfigTargetSettings(void) { 
  JLINK_CORESIGHT_IndexAHBAPToUse = 0; // Select AP0 as AHB-AP
  JLINK_CORESIGHT_IndexAPBAPToUse = 2; // Select AP2 as APB-AP
  return 0;
}

Exclude illegal regions

The map region command can be used to exclude certain memory region(s). The J-Link DLL will ignore all read / write accesses to the specified region(s). This can be used if an IDE for example accesses an illegal memory address for some reason.

Example code
int ConfigTargetSettings(void) {
  JLINK_ExecCommand("map region 0xC0000000-0xC000FFFF X");
  return 0;
}

Initialize work RAM on connect

ECC RAM needs to be initialized to be used by the J-Link as work RAM. This code makes sure that the RAM is initialized on Connect.

Example code
int ConfigTargetSettings(void) {
  JLINK_ExecCommand("SetInitWorkRAMOnConnect = 1");
  return 0;
}