📄 rom10.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 6.0.5">
<meta name="TEMPLATEBASE" content="book_html">
<meta name="LASTUPDATED" content="12/04/03 16:05:52">
<title>9.3.2 Debugging multiple programs on a ROM </title>
<STYLE TYPE="text/css">
<!--
span.Signal { text-transform: uppercase; font-family: Verdana }
-->
</STYLE>
</head>
<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">
<p><img src="images/stlogo.gif" width="106" height="83" align="left"
alt="logo here!"> </p>
<table width="331" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="a_refman.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="rom9.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="rom11.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="a_refmaa.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<p><br clear="all">
</p>
<hr align="left">
<blockquote>
<h3>
<a name="1204591"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">9.3.2 Debugging multiple programs on a ROM</font>
</h3>
<p>
<a name="1204592"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">for each program on the ROM being debugged, specify the debug information (<font size=2 face=Courier><strong>.dbg</strong></font>) file with the command <font size=2 face=Courier><strong>program new</strong></font>.</font>
</p>
<p>
<a name="1204593"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Multiple programs may share a single region of RAM for their data and for their code. This poses a problem for the debugger because it cannot determine which program is using a shared region of memory at a given point in time. As an example, if a breakpoint is hit while the target is executing, the target returns the value of the current <span class=Signal>Iptr</span> to the debugger. The debugger searches its list of programs for source code which corresponds to this address. If more than one program has code or data at this address during the system's life span, there will be a symbolic information conflict between each program.</font>
</p>
<p>
<a name="1204594"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">This is resolved by the notion of a "current" program, which is the program currently executing at a given instant in time. The current program is searched first by the debugger when performing symbolic lookups. If a match is not found, any remaining enabled programs are then searched.</font>
</p>
<p>
<a name="1204595"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The <font size=2 face=Courier><strong>program</strong></font> command has a <font size=2 face=Courier><strong>current</strong></font> option to cater for specifying the current program. Programs may also be disabled from symbolic lookup and re-enabled with the <font size=2 face=Courier><strong>disable</strong></font> and <font size=2 face=Courier><strong>enable</strong></font> options. The enabled/disabled state of a program may be displayed with the <font size=2 face=Courier><strong>detail</strong></font> option. The current program may be displayed with the <font size=2 face=Courier><strong>context</strong></font> command.</font>
</p>
<h5>
<a name="1204598"> </a><i><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">The program key</font></i>
</h5>
<p>
<a name="1204599"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">A 32 bit un3ique program key is generated by the linker every time it is invoked, and this program key is placed in a global integer in the application program with the name <font size=2 face=Courier><strong>_ST_ProgramIdentifier</strong></font>. The C-startup sequence for a ROM image executes an <font size=2 face=Courier><strong>ST_onstartup</strong></font> function which issues the remote debug command, where <font size=2 face=Courier><strong><em>x</em></strong></font> is the hexadecimal value of <font size=2 face=Courier><strong>_ST_ProgramIdentifier</strong></font>:</font>
</p>
<a name="1204600"> </a><font size=2 face=Courier><strong>program -current -uid 0x<font size=2 face=Courier><strong><em>x</em></strong></font><br></strong></font>
<p>
<a name="1204601"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">This command notifies the debugger of the current program and ensures the debugger starts using this newly executing program for symbolic cross-referencing as early on in the program's life span as is practicably possible.</font>
</p>
<p>
<a name="1204602"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The program key may also be specified with the <font size=2 face=Courier><strong>program</strong></font> command options <font size=2 face=Courier><strong>enable</strong></font> and <font size=2 face=Courier><strong>disable</strong></font>, for example:</font>
</p>
<a name="1204603"> </a><font size=2 face=Courier><strong>program -enable -uid 0x1234abcd<br></strong></font>
<h5>
<a name="1204604"> </a><i><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">Preventing program notification</font></i>
</h5>
<p>
<a name="1204605"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The <font size=2 face=Courier><strong>ST_onstartup</strong></font> function described above may be omitted from a ROM system by using the following option with <strong>st20cc</strong>:</font>
</p>
<a name="1204606"> </a><font size=2 face=Courier><strong>-W1 p_ST_NoProgramNotify=1<br></strong></font>
<h5>
<a name="1204609"> </a><i><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">Setting the value of the program key</font></i>
</h5>
<p>
<a name="1204610"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The value of the program key may be explicitly specified at link time, instead of being given a unique value by the linker. This is done by providing the following option to <strong>st20cc</strong>, where <font size=2 face=Courier><strong><em>x</em></strong></font> is the value to be given to the program key:</font>
</p>
<a name="1204611"> </a><font size=2 face=Courier><strong>-W1 p_ST_ProgramIdValue=<font size=2 face=Courier><strong><em>x</em></strong></font><br></strong></font>
<h5>
<a name="1204613"> </a><i><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">Disabling programs</font></i>
</h5>
<p>
<a name="1204614"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">It may be useful in some circumstances to disable a program when the memory it uses is reused by a program which cannot identify itself as the current program. A typical example is an arrangement with a booter program, a main program and one or more relocatable code units (RCUs) loaded by the main program. The booter program and the RCUs share the same RAM. Just before the booter program calls the main program, it issues the following remote command, where <font size=2 face=Courier><strong><em>x</em></strong></font> is the value of <font size=2 face=Courier><strong>_ST_ProgramIdentifier</strong></font>.</font>
</p>
<a name="1204615"> </a><font size=2 face=Courier><strong>program -disable -uid 0x<font size=2 face=Courier><strong><em>x</em></strong></font><br></strong></font>
<p>
<a name="1204616"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">When Relocatable Code Units (RCU[s]) are loaded later by the main program, there is no symbolic conflict for the memory shared by the booter and one or more RCUs. It is recommended that booter programs always disable themselves in the above manner to aid future compatibility. If the processor is restarted, the booter program will need to be re-enabled.</font>
</p>
<h5>
<a name="1204619"> </a><i><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">Compatibility with earlier toolsets</font></i>
</h5>
<p>
<a name="1204620"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The debugger handles ROM images built with ST20 Embedded Toolset version R1.6.2 upwards. However, it may need assistance where multiple programs exist on a ROM, of which some are built with toolsets earlier than R1.8.1. This is because these do not issue a <font size=2 face=Courier><strong>program current</strong></font> command as an <font size=2 face=Courier><strong>ST_onstartup</strong></font> function. Assistance is in the form of either modifying current code or interaction with the program call mechanism. Assistance may not be necessary when the code from multiple programs is executed from ROM because all <span class=Signal>Iptr</span> values will be unique.</font>
</p>
<p>
<a name="1204621"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">If the code is modifiable, the best approach is to create an instance of the variable <font size=2 face=Courier><strong>int _ST_ProgramIdentifier</strong></font> for each program which is built with any toolset earlier than version R1.8.1, and place a "unique" value in each. Each program should be provided with an <font size=2 face=Courier><strong>ST_onstartup</strong></font> function which issues a remote debug command, where <font size=2 face=Courier><strong><em>x</em></strong></font> is the hexadecimal value of <font size=2 face=Courier><strong>_ST_ProgramIdentifier</strong></font>:</font>
</p>
<a name="1204622"> </a><font size=2 face=Courier><strong>program -current -uid 0x<font size=2 face=Courier><strong><em>x</em></strong></font><br></strong></font>
<p>
<a name="1208567"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">Each function should have a startorder value of at least 100000 to be executed before any system <font size=2 face=Courier><strong>ST_onstartup</strong></font> functions and to allow for future toolset development (see<font size=2 face=Courier><strong> </strong></font><a href="commands.htm#1212189"><font color="#0000ff" face="Verdana, Arial, Helvetica, sans-serif"><i>Chapter
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -