flashAlgorithm.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>Flash Programming</title>
  7. <title>CMSIS-Pack: Flash Programming</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <link href="cmsis.css" rel="stylesheet" type="text/css" />
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <script type="text/javascript" src="printComponentTabs.js"></script>
  13. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  14. <script type="text/javascript" src="resize.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <script type="text/javascript">
  17. $(document).ready(initResizable);
  18. $(window).load(resizeHeight);
  19. </script>
  20. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  21. <script type="text/javascript" src="search/search.js"></script>
  22. <script type="text/javascript">
  23. $(document).ready(function() { searchBox.OnSelectItem(0); });
  24. </script>
  25. </head>
  26. <body>
  27. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  28. <div id="titlearea">
  29. <table cellspacing="0" cellpadding="0">
  30. <tbody>
  31. <tr style="height: 46px;">
  32. <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  33. <td style="padding-left: 0.5em;">
  34. <div id="projectname">CMSIS-Pack
  35. &#160;<span id="projectnumber">Version 1.5.0</span>
  36. </div>
  37. <div id="projectbrief">Delivery Mechanism for Software Packs</div>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. <!-- end header part -->
  44. <div id="CMSISnav" class="tabs1">
  45. <ul class="tablist">
  46. <script type="text/javascript">
  47. <!--
  48. writeComponentTabs.call(this);
  49. //-->
  50. </script>
  51. </ul>
  52. </div>
  53. <!-- Generated by Doxygen 1.8.6 -->
  54. <script type="text/javascript">
  55. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  56. </script>
  57. <div id="navrow1" class="tabs">
  58. <ul class="tablist">
  59. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  60. <li class="current"><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
  61. <li>
  62. <div id="MSearchBox" class="MSearchBoxInactive">
  63. <span class="left">
  64. <img id="MSearchSelect" src="search/mag_sel.png"
  65. onmouseover="return searchBox.OnSearchSelectShow()"
  66. onmouseout="return searchBox.OnSearchSelectHide()"
  67. alt=""/>
  68. <input type="text" id="MSearchField" value="Search" accesskey="S"
  69. onfocus="searchBox.OnSearchFieldFocus(true)"
  70. onblur="searchBox.OnSearchFieldFocus(false)"
  71. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  72. </span><span class="right">
  73. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  74. </span>
  75. </div>
  76. </li>
  77. </ul>
  78. </div>
  79. </div><!-- top -->
  80. <div id="side-nav" class="ui-resizable side-nav-resizable">
  81. <div id="nav-tree">
  82. <div id="nav-tree-contents">
  83. <div id="nav-sync" class="sync"></div>
  84. </div>
  85. </div>
  86. <div id="splitbar" style="-moz-user-select:none;"
  87. class="ui-resizable-handle">
  88. </div>
  89. </div>
  90. <script type="text/javascript">
  91. $(document).ready(function(){initNavTree('flashAlgorithm.html','');});
  92. </script>
  93. <div id="doc-content">
  94. <!-- window showing the filter options -->
  95. <div id="MSearchSelectWindow"
  96. onmouseover="return searchBox.OnSearchSelectShow()"
  97. onmouseout="return searchBox.OnSearchSelectHide()"
  98. onkeydown="return searchBox.OnSearchSelectKey(event)">
  99. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  100. <!-- iframe showing the search results (closed by default) -->
  101. <div id="MSearchResultsWindow">
  102. <iframe src="javascript:void(0)" frameborder="0"
  103. name="MSearchResults" id="MSearchResults">
  104. </iframe>
  105. </div>
  106. <div class="header">
  107. <div class="headertitle">
  108. <div class="title">Flash Programming </div> </div>
  109. </div><!--header-->
  110. <div class="contents">
  111. <div class="textblock"><p><b>Flash Programming Algorithms</b> are a piece of software to erase or download applications to Flash devices. A <a class="el" href="createPack_DFP.html">Pack with Device Support</a> usually contains predefined Flash algorithms for programming the devices that are supported by the DFP. A template for creating new algorithms are available in the <b>ARM:CMSIS</b> Pack. The following section describes the process in more detail.</p>
  112. <h1><a class="anchor" id="CreateFPA"></a>
  113. Creating a new Algorithm</h1>
  114. <p>Flash programming algorithms are defined with functions to erase and program the Flash device. Special compiler and linker settings are required. Follow these steps to create and configure a new Flash programming algorithm:</p>
  115. <ol type="1">
  116. <li>Copy the content from the <b>ARM:CMSIS</b> Pack folder (usually C:\Keil\ARM\Pack\ARM\CMSIS\<em>version</em>\Device\_Template_Flash) to a new folder.</li>
  117. <li>Rename the project file <b>NewDevice.uvprojx</b> to represent the new Flash ROM device name, for example <b>MyDevice.uvprojx</b>.</li>
  118. <li>Open the project with uVision. From the toolbar, use the drop-down <b>Select Target</b> to define the processor architecture. <b>Cortex-M</b> fits for all Cortex-M0/M0+, M3, and M4 devices. The configuration assumes a little-endian microcontroller. In case of a big-endian microcontroller, select the correct processor core with <b>Project</b> - <b>Options for Target</b> - <b>Device</b>.</li>
  119. <li>Open the dialog <b>Project</b> - <b>Options for Target</b> - <b>Output</b> and change the content of the field <b>Name of Executable</b> to represent the device, for example <b>MyDevice</b>.</li>
  120. <li>Adapt the programming algorithms in the file <a class="el" href="flashAlgorithm.html#FlashPrg">FlashPrg</a>.</li>
  121. <li>Adapt the device parameters in the file <a class="el" href="flashAlgorithm.html#FlashDev">FlashDev</a>.</li>
  122. <li>Use <b>Project</b> - <b>Build Target</b> to generate the new Flash programming algorithm. The output file (for example <b>MyDevice.FLM</b>) has to be <a class="el" href="flashAlgorithm.html#AddFPA">added</a> to the <b>DFP</b>.</li>
  123. </ol>
  124. <dl class="section note"><dt>Note</dt><dd><ul>
  125. <li>Creating a Flash programming algorithm with <a href="http://www.keil.com/arm/selector.asp" class="el" target="_blank">MDK-Lite</a> is not supported.</li>
  126. <li>Flash programming algorithms use <b>Read-Only Position Independent</b> and <b>Read-Write Position Independent</b> program code. These options are set in the dialogs <b>Project</b> - <b>Options for Target</b> - <b>C/C++</b> and <b>Project</b> - <b>Options for Target</b> - <b>Asm</b>.</li>
  127. <li>The dialog <b>Project</b> - <b>Options for Target</b> - <b>Linker</b> defines the linker scatter file <b>Target.lin</b>. The error L6305 is disabled with <code>&ndash;diag_suppress</code> <code>L6305</code>.</li>
  128. <li>The <a class="el" href="algorithmFunc.html">Flash Algorithm Functions</a> section contains reference for all the available functions.</li>
  129. </ul>
  130. </dd></dl>
  131. <p><a class="anchor" id="FlashPrg"></a></p>
  132. <h2>FlashPrg.c </h2>
  133. <p>The file <b>FlashPrg.c</b> contains the mandatory Flash programming functions <a class="el" href="algorithmFunc.html#Init">Init</a>, <a class="el" href="algorithmFunc.html#UnInit">UnInit</a>, <a class="el" href="algorithmFunc.html#EraseSector">EraseSector</a>, and <a class="el" href="algorithmFunc.html#ProgramPage">ProgramPage</a>. Optionally, depending on the device features (or to speed-up execution), the functions <a class="el" href="algorithmFunc.html#EraseChip">EraseChip</a>, <a class="el" href="algorithmFunc.html#BlankCheck">BlankCheck</a>, and <a class="el" href="algorithmFunc.html#Verify">Verify</a> can be implemented.</p>
  134. <p><a class="anchor" id="FlashDev"></a></p>
  135. <h2>FlashDev.c </h2>
  136. <p>The file <b>FlashDev.c</b> contains parameter definitions for:</p>
  137. <ol type="1">
  138. <li>the Flash programming functions.</li>
  139. <li>the <b>FlashDevice</b> structure: <div class="fragment"><div class="line"><span class="keyword">struct </span>FlashDevice const FlashDevice = {</div>
  140. <div class="line"> FLASH_DRV_VERS, <span class="comment">// Driver Version, do not modify!</span></div>
  141. <div class="line"> <span class="stringliteral">&quot;New Device 256kB Flash&quot;</span>, <span class="comment">// Device Name </span></div>
  142. <div class="line"> ONCHIP, <span class="comment">// Device Type</span></div>
  143. <div class="line"> 0x00000000, <span class="comment">// Device Start Address</span></div>
  144. <div class="line"> 0x00040000, <span class="comment">// Device Size in Bytes (256kB)</span></div>
  145. <div class="line"> 1024, <span class="comment">// Programming Page Size</span></div>
  146. <div class="line"> 0, <span class="comment">// Reserved, must be 0</span></div>
  147. <div class="line"> 0xFF, <span class="comment">// Initial Content of Erased Memory</span></div>
  148. <div class="line"> 100, <span class="comment">// Program Page Timeout 100 mSec</span></div>
  149. <div class="line"> 3000, <span class="comment">// Erase Sector Timeout 3000 mSec</span></div>
  150. <div class="line"> </div>
  151. <div class="line"><span class="comment">// Specify Size and Address of Sectors</span></div>
  152. <div class="line"> 0x002000, 0x000000, <span class="comment">// Sector Size 8kB (8 Sectors)</span></div>
  153. <div class="line"> 0x010000, 0x010000, <span class="comment">// Sector Size 64kB (2 Sectors) </span></div>
  154. <div class="line"> 0x002000, 0x030000, <span class="comment">// Sector Size 8kB (8 Sectors)</span></div>
  155. <div class="line"> SECTOR_END</div>
  156. <div class="line">};</div>
  157. </div><!-- fragment --></li>
  158. </ol>
  159. <dl class="section note"><dt>Note</dt><dd>The <b>Device Name</b> will usually be shown in tools to identify the Flash algorithm. Make sure that this is changed to the correct device name from the DFP.</dd></dl>
  160. <h1><a class="anchor" id="AddFPA"></a>
  161. Adding an Algorithm to a Pack</h1>
  162. <p>The generated <b>*.FLM</b> file needs to be added to the <a class="el" href="createPack_DFP.html">Pack with Device Support</a>, so that it is available to the tool user for programming his device. Usually, a directory <b>Flash</b> is created and the algorithm is saved in this directory.</p>
  163. <p>The algorithm is specified within the the <a class="el" href="pdsc_family_pg.html#element_family">/package/devices/family</a> level: </p>
  164. <div class="fragment"><div class="line">&lt;family Dfamily=<span class="stringliteral">&quot;STM32F4&quot;</span> Dvendor=<span class="stringliteral">&quot;STMicroelectronics:13&quot;</span>&gt;</div>
  165. <div class="line"> ...</div>
  166. <div class="line"> &lt;algorithm name=<span class="stringliteral">&quot;Flash/STM32F2xx_512.flm&quot;</span> start=0x08000000 size=0x10000 <span class="keywordflow">default</span>=<span class="stringliteral">&quot;1&quot;</span>/&gt; &lt;!-- valid <span class="keywordflow">for</span> all devices of the family --&gt;</div>
  167. <div class="line"> </div>
  168. <div class="line"> &lt;subFamily DsubFamily=<span class="stringliteral">&quot;STM32F405&quot;</span>&gt;</div>
  169. <div class="line"> &lt;algorithm name=<span class="stringliteral">&quot;Flash/STM32F2xx_1024.flm&quot;</span> start=0x08000000 size=0x20000 <span class="keywordflow">default</span>=<span class="stringliteral">&quot;1&quot;</span>/&gt; &lt;!-- valid <span class="keywordflow">for</span> all devices of a subFamily --&gt;</div>
  170. <div class="line"> </div>
  171. <div class="line"> &lt;device Dname=<span class="stringliteral">&quot;STM32F405OE&quot;</span>&gt;</div>
  172. <div class="line"> &lt;algorithm name=<span class="stringliteral">&quot;Flash/STM32F2xx_2048.flm&quot;</span> start=0x08000000 size=0x40000 <span class="keywordflow">default</span>=<span class="stringliteral">&quot;1&quot;</span>/&gt; &lt;!-- <span class="keywordflow">finally</span>, <span class="keyword">this</span> is the <span class="keywordflow">default</span> <span class="keywordflow">for</span> the device --&gt;</div>
  173. <div class="line"> &lt;/device&gt;</div>
  174. <div class="line"> ...</div>
  175. <div class="line">&lt;/family&gt;</div>
  176. </div><!-- fragment --><p>The argument <em>start</em> specifies the base address for the Flash programming algorithm.</p>
  177. <p>The argument <em>size</em> specifies the size covered by the Flash programming algorithm. End address = start + size - 1.</p>
  178. <p>The argument <em>default</em> specifies whether a Flash programming algorithm is set as the default algorithm in a project (when <span class="XML-Token">true</span>). If <em>default</em> is not set or false, the Flash programming algorithm can be configured on a lower level. However, the Flash programming algorithm of a project can be changed manually at any time during development. </p>
  179. </div></div><!-- contents -->
  180. </div><!-- doc-content -->
  181. <!-- start footer part -->
  182. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  183. <ul>
  184. <li class="footer">Generated on Wed Aug 1 2018 17:12:42 for CMSIS-Pack by Arm Ltd. All rights reserved.
  185. <!--
  186. <a href="http://www.doxygen.org/index.html">
  187. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
  188. -->
  189. </li>
  190. </ul>
  191. </div>
  192. </body>
  193. </html>