天天看點

NRF52832 OTA無線更新 1  Installing nrfutil

1  Installing nrfutil

You can install nrfutil from the Python Package Index (PyPI) or you can run or install it from the sources.

In both cases, the following prerequisites must be installed:

  • Python 2.7 (2.7.6 or later, but not Python 3)
  • pip (see Installing Python Modules)
  • Installing from sources
  • To be able to modify nrfutil, download the sources of the tool from GitHub and install it.

    In addition to Python and pip, installing nrfutil from the sources requires the Python setuptools. To upgrade to the latest version, run:

    pip install -U setuptools      
    If you want to create an executable for nrfutil, install pyinstaller:
    pip install pyinstaller      
    1. Clone the nrfutil GitHub repository.  URL: https://github.com/NordicSemiconductor/pc-nrfutil/
    2. Open a command prompt in the folder where you cloned the repository and run pip install -r requirements.txt to install all prerequisites.
    3. Set up nrfutil in one of the following ways:
      • To run nrfutil from the sources without installation, enter the following command:
        python nordicsemi/__main__.py      
        The following sections assume that you have installed the tool and can call it with nrfutil. If you choose to run it without installation, always replace the nrfutil command with python nordicsemi/__main__.py and add the required command-line options.
      • To install the library to the local Python site-packages and script folder, enter the following command:
        python setup.py install
              
      • To generate a self-contained executable version of the utility, enter the following command:
        pyinstaller nrfutil.spec      

2.hex打包為zip

        進入工程的編譯目錄下使用以下指令把hex檔案打包為zip, 其中app.hex為工程生成的檔案

nrfutil pkg generate --hw-version 52 --sd-req0x8C --application-version 0xFF --application app.hex --key-file private.pem app_dfu_package.zip

3 Generating and displaying keys

The keys command can be used to generate and display cryptographic keys.

Cryptographic keys are required to sign and validate a Device Firmware Update package. See the Cryptography library in the SDK for more information about signing and cryptographic keys.

  • Run nrfutil keys generate to generate a private (signing) key and store it in a file in PEM format.
  • Run nrfutil keys display to display a private (signing) or public (verification) key from a PEM file. There are several options available, which you can view by entering the following command:
    nrfutil keys display --help
          

For example, enter the following command to generate a private key and store it in a file named private.pem:

nrfutil keys generate private.pem
      

Enter the following command to display a public key in code format from this key file:

nrfutil keys display --key pk --format code private.pem      

通過pem生成public_key,替換原先的SDK\examples\dfu\bootloader_secure檔案

nrfutil keys display --key pk --format code c:\vault\private.pem --out_file dfu_public_key.c

4.install micro-ecc

      Install version 4.9-2015-q3-update of the GCC compiler toolchain for ARM. You can use ARM's Launchpad to find the toolchain for your operating system.

      Make sure that make is installed (see, for example, MinGW, GNU Make, or Xcode).Click below URL and download it.

  1. https://sourceforge.net/projects/mingw/files/latest/download?source=files      
    I recommend you to install msys as well after installed MinGW in order to use Unix bash shell.
    NRF52832 OTA無線更新 1  Installing nrfutil

    after installed msys, open the bash shell script which it located in “C:\MinGW\msys\1.0\msys.bat”

    for uECC download and installation, you should unzip the uECC source code under micro-ecc folder as below.

    1. Unzip micro-ecc code at “nRF5_SDK_12.1.0_0d23e2a\external\micro-ecc\”
    2. Change folder name to “micro-ecc” ex) \external\micro-ecc\micro-ecc
    3. use the msys to make \external\micro-ecc\nrf52_keil\armgcc, and then generate micro_ecc_lib_nrf52.lib
    4. use this micro_ecc_lib_nrf52.lib and dfu_public_key.c, you can compile the project and examples\dfu\bootloader_secure, and use nrfgo-studio download SoftDevice and this bootloader.
    5. use android or IOS APP nrf-toolbox to upgrade applicationapp_dfu_package.zip