📄 tutorial.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Copyright 2001, 2002 Cambridge Silicon Radio Limited -->
<html>
<head>
<title>CSR DFU Tools - Tutorial</title>
</head>
<body bgcolor="white">
<h1 align=center>CSR DFU Tools - Tutorial</h1>
This page describes the sequence of command invocations required to prepare a release of software for upgrade via DFU. In addition to the <i>DFU Tools</i> themselves, it is assumed that the following files have been obtained from CSR:
<table border=1 align=center>
<tr>
<th>File</th>
<th>Description</th>
</tr>
<tr>
<td><code>loader_unsigned.xpv</code> & <code>loader_unsigned.xdv</code></td>
<td>Loader software</td>
</tr>
<tr>
<td><code>stack_unsigned.xpv</code> & <code>stack_unsigned.xdv</code></td>
<td>Unsigned stack software</td>
</tr>
</table>
<p>
The examples assume that the <code><i>idVendor</i></code> field is set to <code>0x0a12</code> and the <code><i>idProduct</i></code> is set to <code>0x0001</code> in the device's USB device descriptor. If other values are used then the command lines will need to be modified appropriately.
<h2>Key Generation</h2>
Up to two pairs of keys can be used for DFU signature checking and verification. However, both pairs of keys are optional; if they are omitted then the corresponding signatures are never checked.
<dl>
<dt>Generate a pair of keys for the stack:</dt>
<dd><code><a href="dfukeygenerate.html#ka" title="Generating A Pair of Keys">dfukeygenerate</a> -v -o my_stack_key -i "My stack key"</code></dd>
<dt>Generate a pair of keys for the application:</dt>
<dd><code><a href="dfukeygenerate.html#ka" title="Generating A Pair of Keys">dfukeygenerate</a> -v -o my_app_key -i "My application key"</code></dd>
</dl>
Keep these keys secure.
<h2>Preparing the Loader</h2>
The loader needs to be prepared by inserting a copy of the public stack key. It is not necessary for the version of the loader to match that of the stack, so this process does not need to be repeated for every firmware release.
<dl>
<dt>Add the public stack key to the loader:</dt>
<dd><code><a href="dfukeyinsert.html#sk" title="Adding Stack Key to Loader">dfukeyinsert</a> -v -o loader_with_key -l loader_unsigned.xdv -ks my_stack_key.public.key</code></dd>
</dl>
The resulting <code>loader_with_key.xpv</code> and <code>loader_with_key.xdv</code> files can then be used for programming the flash memory during production. Note that the loader cannot be replaced via DFU.
<h2>Building Stack Only DFU File</h2>
The most common type of DFU file that needs to be produced is one containing just the stack software for a single BlueCore variant. This requires two steps.
<dl>
<dt>Sign the stack software using the private stack key:</dt>
<dd><code><a href="dfusign.html#ss" title="Signing Stack Software">dfusign</a> -v -o stack_signed -s stack_unsigned.xpv -ks my_stack_key.private.key</code></dd>
<dt>Generate a DFU file containing the signed stack software (assuming stack software <code>release-1</code>):</dt>
<dd><code><a href="dfubuild.html#ca" title="Constructing a DFU File">dfubuild</a> -v -pedantic -f stack.dfu -uv 0x0a12 -up 0x0001 -ui "BlueCore firmware version release-1" -s stack_signed.xpv</code></dd>
</dl>
The resulting <code>stack.dfu</code> file can be downloaded via DFU to devices whose loader contains the matching public key.
<h2>Building DFU File with All Components</h2>
DFU files can contain any combination of firmware and persistent store. The following example illustrates the construction of a file containing a single version of all the components. It is assumed that the following additional files have already been generated:
<table border=1 align=center>
<tr>
<th>File</th>
<th>Description</th>
</tr>
<tr>
<td><code>app_unsigned.app</code></td>
<td>Application software</td>
</tr>
<tr>
<td><code>stack_ps_unsigned.psr</code></td>
<td>Protected stack persistent store</td>
</tr>
<tr>
<td><code>app_ps_unsigned.psr</code></td>
<td>Protected application persistent store</td>
</tr>
</table>
<dl>
<dt>Add the public application key to the protected stack persistent store:</dt>
<dd><code><a href="dfukeyinsert.html#ak" title="Adding Application Key to Protected Stack Persistent Store">dfukeyinsert</a> -v -o stack_ps_with_key_unsigned -ps stack_ps_unsigned.psr -ka my_app_key.public.key</code></dd>
<dt>Sign the stack software using the private stack key:</dt>
<dd><code><a href="dfusign.html#ss" title="Signing Stack Software">dfusign</a> -v -o stack_signed -s stack_unsigned.xpv -ks my_stack_key.private.key</code></dd>
<dt>Sign the application software using the private application key:</dt>
<dd><code><a href="dfusign.html#as" title="Signing Application Software">dfusign</a> -v -o app_signed -a app_unsigned.app -ka my_app_key.private.key</code></dd>
<dt>Sign the protected stack persistent store using the private stack key:</dt>
<dd><code><a href="dfusign.html#sps" title="Signing Protected Stack Persistent Store">dfusign</a> -v -o stack_ps_signed -ps stack_ps_with_key_unsigned.psr -ks my_stack_key.private.key</code></dd>
<dt>Sign the protected application persistent store using the private application key:</dt>
<dd><code><a href="dfusign.html#aps" title="Signing Protected Application Persistent Store">dfusign</a> -v -o app_ps_signed -pa app_ps_unsigned.psr -ka my_app_key.private.key</code></dd>
<dt>Generate a DFU file containing the four signed components (assuming stack software <code>release-1</code>):</dt>
<dd><code><a href="dfubuild.html#ca" title="Constructing a DFU File">dfubuild</a> -v -pedantic -f combined.dfu -uv 0x0a12 -up 0x0001 -ui "BlueCore firmware version release-1 with application and persistent store" -s stack_signed.xpv -a app_signed.app -p3 . stack_ps_signed.stack.psr app_ps_signed.app.psr</code></dd>
</dl>
The resulting <code>combined.dfu</code> file can be downloaded via DFU to a device whose loader contains the matching public stack key.
<p>
Note:
<ul>
<li>No unprotected persistent store has been included. All persistent store keys can be written as either protected stack persistent store or protected application persistent store.</li>
<li>The application public key is changed in persistent store after the application software's signature has been checked. Hence, the download will fail if a different application public key is already present in persistent store.</li>
</ul>
<h2>Building DFU File for Multiple BlueCore Variants</h2>
DFU files can also contain multiple versions of each component to allow the same file to be used with different module designs. The following example illustrates the construction of a file containing different stack software for BlueCore01 and BlueCore2-External. It is assumed that the following files have already been obtained and prepared:
<table border=1 align=center>
<tr>
<th>File</th>
<th>Description</th>
</tr>
<tr>
<td><code>stack_bc01.xpv</code> & <code>stack_bc01.xdv</code></td>
<td>Signed stack software for BlueCore01</td>
</tr>
<tr>
<td><code>stack_bc02.xpv</code> & <code>stack_bc02.xdv</code></td>
<td>Signed stack software for BlueCore2-External</td>
</tr>
</table>
<dl>
<dt>Combine the two versions of stack software into a single DFU file:</dt>
<dd><code><a href="dfubuild.html#ca" title="Constructing a DFU File">dfubuild</a> -v -pedantic -f multiple.dfu -uv 0x0a12 -up 0x0001 -ui "BlueCore01 and BlueCore2-External firmware version release-1" -s stack_bc01.xpv stack_bc02.xpv</code></dd>
</dl>
The resulting <code>multiple.dfu</code> file can be downloaded via DFU to both BlueCore01 and BlueCore2-External devices. The complete file, containing both versions of stack software, is always downloaded; the on-chip loader software automatically selects the appropriate firmware to program into the flash memory.
<p>
Multiple versions of application software and persistent store can be combined similarly.
<p align=right><font size="-1">© 2001, 2002, 2003 <a href="http://www.csr.com" title="CSR" target="_blank">CSR</a></font></p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -