This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Replace S132 with S112

My application is a BLE peripheral and will only allow a single connection to a BLE central. Hardware will be nRF52832. My test application was based on a Nordic example that uses S132. It looks like I could save some flash if I use S112 instead of S132. Would this work and is this a good choice.

Parents
  • I burned flash with S112 but now my application does not run.  There must be more steps required to change from one version of SoftDevice to another.  Is this documented anywhere?

    My environment:  nRF52 DK, SDK 15.2, SD 6.1.0, SES v3.52

    My bootloader was built from examples/dfu//secure_bootloader

    My application was built from examples/ble_peripheral/ble_app_buttonless_dfu

    When I use S132 the DFU application runs normally and I can load a ZIP package.  When I replace S132 with S112 the board does not run the application. Instead it just runs the bootloader and LED-1 and LED-2 are on solid. 

    I went into the SES project files and found a couple places where S132 was used. I replaced those with S112.  I did this in the bootloader project and the application project.  However there was no change in behavior.

  • Hi.

    Have you used the right settings when you created your .zip packet?

    If you look at the command nrfutil pgk generate --help, you see the following options:

    λ nrfutil pkg generate --help
    Usage: nrfutil pkg generate [OPTIONS] ZIPFILE
    
      Generate a zip package for distribution to apps that support Nordic DFU
      OTA. The application, bootloader, and SoftDevice files are converted to
      .bin if supplied as .hex files. For more information on the generated
      package, see: http://developer.nordicsemi.com/nRF5_SDK/doc/
    
      The following combinations are supported by this command:
    
      * BL only: Supported.
    
      * SD only: Supported (SD of same Major Version).
    
      * APP only: Supported.
    
      * BL + SD: Supported.
    
      * BL + APP: Not supported (use two packages instead).
    
      * BL + SD + APP: Supported.
    
      * SD + APP: Supported (SD of same Major Version).
    
    Options:
      --debug-mode                    Debug mode switch, enables version check
                                      skipping.
      --application TEXT              The application firmware file.
      --application-version INTEGER   The application version.
      --application-version-string TEXT
                                      The application version string, e.g
                                      "2.7.31".
      --bootloader TEXT               The bootloader firmware file.
      --bootloader-version INTEGER    The bootloader version.
      --hw-version INTEGER            The hardware version.  [required]
      --sd-req TEXT                   The SoftDevice requirements. A comma-
                                      separated list of SoftDevice firmware IDs (1
                                      or more) of which one must be present on the
                                      target device. Each item on the list must be
                                      a two- or four-digit hex number prefixed
                                      with "0x" (e.g. "0x12", "0x1234").
                                      A non-
                                      exhaustive list of well-known values to use
                                      with this option follows:
                                      |s112_nrf52_6.0.0|0xA7|
                                      |s112_nrf52_6.1.0|0xB0|
                                      |s130_nrf51_1.0.0|0x67|
                                      |s130_nrf51_2.0.0|0x80|
                                      |s132_nrf52_2.0.0|0x81|
                                      |s130_nrf51_2.0.1|0x87|
                                      |s132_nrf52_2.0.1|0x88|
                                      |s132_nrf52_3.0.0|0x8C|
                                      |s132_nrf52_3.1.0|0x91|
                                      |s132_nrf52_4.0.0|0x95|
                                      |s132_nrf52_4.0.2|0x98|
                                      |s132_nrf52_4.0.3|0x99|
                                      |s132_nrf52_4.0.4|0x9E|
                                      |s132_nrf52_4.0.5|0x9F|
                                      |s132_nrf52_5.0.0|0x9D|
                                      |s132_nrf52_5.1.0|0xA5|
                                      |s132_nrf52_6.0.0|0xA8|
                                      |s132_nrf52_6.1.0|0xAF|
                                      |s140_nrf52_6.0.0|0xA9|
                                      |s140_nrf52_6.1.0|0xAE|  [required]
      --sd-id TEXT                    The new SoftDevice ID to be used as --sd-req
                                      for the Application update in case the ZIP
                                      contains a SoftDevice and an Application.
      --softdevice TEXT               The SoftDevice firmware file.
      --key-file PATH                 The private (signing) key in PEM fomat.
      --zigbee BOOLEAN                Create an image and distribution package for
                                      Zigbee DFU server.
      --zigbee-manufacturer-id INTEGER
                                      Manufacturer ID to be used in Zigbee OTA
                                      header.
      --zigbee-image-type INTEGER     Image type to be used in Zigbee OTA header.
      --zigbee-comment TEXT           Firmware comment to be used in Zigbee OTA
                                      header.
      --help                          Show this message and exit.
    

    Note: Make sure you have the latest nrfutil version by running the command pip install nrfutil.

    If you want to have your new firmware using SoftDevice S112 V6.1.0, then you have to use --sd-req 0xB0, when you generate the packet. Did you do this?

    Some more information about generating a packet is found in the infocenter here.

    Try this and see if it works by using --sd-req 0xB0 to generate the packet.

    Best regards.

    Andreas

  • I did not get that far. I am back at step 1 where I am just burning hex images to flash. I use the DFU boot loader, S132, and DFU application. That combination will boot normally. But if I replace S132 with S112 the application does not run. It just boots into the boot loader. 

    Below is the console output when I use S132.  When I use S112 there is no output on the console at all.

    <info> app: Setting vector table to bootloader: 0x00072000
    <LF><info> app: Setting vector table to main app: 0x00026000
    <LF><info> app: Buttonless DFU Application started.
    

    Also, I understand your comments about the ZIP package and nrfutil. When I use S132 I have no problem creating ZIP package and executing the DFU. And I understand I need to change the SD version number to B0 when I use S112. However at this point I cannot event get the DFU application to boot when I use S112.

    Another data point:  I replaced S132 6.1.0 with S132 6.1.1 and everything worked including the DFU with ZIP package. I used --sd-req 0xB7 for this test.  

  • Hi.

    Sorry for the late reply, I tried to answer you yesterday, but the reply got very long, so here it is today.

    I can try to clarify more:

    If you have a bootloader and an application you wish to use for a DFU, the right settings for this DFU .zip file must be given when you create it.

    With that in background, there should not be any issues if your application runs standalone, and your bootloader also runs standalone, to use this application as the upgrade firmware. But, if the DFU Packet is generated with the wrong settings, the bootloader will have a bad time running the application. It might not know what the application start address is, or the end address. Since this is dependent on the SoftDevice. Therefore, it is essential that if you wish to do a DFU where you change SoftDevice version you include this when you generate the DFU packet.  Also, if the SoftDevice version is to be changed, a bootloader with the SoftDevice version of the new firmware is required.

    So, I will try to walk you through the process a bit more:

    To do a DFU where we change the applications SoftDevice we require 3 items in our DFU packet:

    • Bootloader with SoftDevice S112 v6.1.0
    • Application with SoftDevice S112 v6.1.0
    • SoftDevice S112 v6.1.0

     

    We also need a bootloader with SoftDevice S132 v6.1.0.

    So lets start.

    1. Bootloader with SoftDevice S132 v6.1.0

    I used the bootloader project found in nRF5_SDK_15.2.0_9412b96\examples\dfu\secure_bootloader\pca10040_ble

    You need to have a key which you use to verify the DFU packet.

    This can be created by doing the following, which is explained on the infocenter:

    1. Use the nrfutil command:

    nrfutil keys generate private.pem

    In a command window. This command will create a key file.

    Open the bootloader project. And create a new file called dfu_public_key.c in the Application folder, if its there already you dont have to create a new one.

    Use the nrfutil command:

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

    To display the content of the key file in your command window, like this:

    You should now copy the output from the keys display command and replace it with the existing code in dfu_public_key.c, In my case this was the code I pasted and replaced the code in dfu_public_key.c:

    /* This file was automatically generated by nrfutil on 2018-11-29 (YY-MM-DD) at 14:43:06 */
    
    #include "sdk_config.h"
    #include "stdint.h"
    #include "compiler_abstraction.h"
    
    #if NRF_CRYPTO_BACKEND_OBERON_ENABLED
    /* Oberon backend is changing endianness thus public key must be kept in RAM. */
    #define _PK_CONST
    #else
    #define _PK_CONST const
    #endif
    
    
    /** @brief Public key used to verify DFU images */
    __ALIGN(4) _PK_CONST uint8_t pk[64] =
    {
        0xb4, 0xbf, 0x71, 0x80, 0x25, 0x9f, 0x6c, 0xaf, 0x88, 0xd5, 0xfd, 0x03, 0xcf, 0x64, 0xa1, 0x87, 0xef, 0x79, 0xf0, 0x4f, 0xf1, 0x63, 0x36, 0x23, 0xea, 0xd9, 0xff, 0x9f, 0xc9, 0xd9, 0x92, 0x3d,
        0x88, 0xa6, 0xd1, 0xf2, 0x7f, 0xd6, 0xbc, 0x6d, 0x83, 0x78, 0xb7, 0xc7, 0xd3, 0xb1, 0xb3, 0xbe, 0x73, 0x5c, 0x3f, 0x89, 0xd5, 0xbe, 0x39, 0x07, 0xed, 0x2f, 0x25, 0xa4, 0xc2, 0xc7, 0x65, 0x68
    };
    
    
    

    NOTE: Do not use the code I have pasted here, you have to use the code generated from your own key.

    You can now compile the project, and the project should compile without errors. You have no made a bootloader which requires a private key, and the bootloader is using SoftDevice S132 v6.1.0.

                2. Create the Application which uses SoftDevice S112 v6.1.0

    I used the UART example project, but you can use whatever you like

    I just compiled the project found in the folder nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_uart\pca10040\s112

    The projects found in pca10040\s112 folders are setup for nRF52832 Boards and uses SoftDevice S112 v6.1.0.

    If you would like to use a project which does not have a pca10040\s112 folder, you have to set this up yourself by doing the following:

    Copy the pca10040\s132 folder, and open your preferred IDE and do the following modifications:

    1. Change two of the include paths from:

    ../../../../../../components/softdevice/s132/headers
    ../../../../../../components/softdevice/s132/headers/nrf52

    To:

    ../../../../../../components/softdevice/s112/headers

    ../../../../../../components/softdevice/s112/headers/nrf52

    2. Change the SoftDevice included to:

    nRF5_SDK_15.2.0_9412b96/components/softdevice/s112/hex/s112_nrf52_6.1.0_softdevice.hex

    3. Edit the preprocessor definition S132 to S112

    4. Edit the Section Placement Macros to:

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x80000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x10000

    FLASH_START=0x19000

    FLASH_SIZE=0x67000

    RAM_START=0x20002500

    RAM_SIZE=0xdb00

    It should now compile without any errors

                3. Create the Bootloader which uses SoftDevice S112 v6.1.0

    Here, I used the secure_bootloader project (nRF5_SDK_15.2.0_9412b96\examples\dfu\secure_bootloader\pca10040_ble) and did the same thing as I would have done above if I had used a project which did not have a pca10040\s112 folder, That is:

    Copy the pca10040\s132 folder, and open your preferred IDE and do the following modifications:

    1. Changed two of the include paths from:

    ../../../../../../components/softdevice/s132/headers
    ../../../../../../components/softdevice/s132/headers/nrf52

    To:

    ../../../../../../components/softdevice/s112/headers

    ../../../../../../components/softdevice/s112/headers/nrf52

    2. Changed the SoftDevice included to:

    nRF5_SDK_15.2.0_9412b96/components/softdevice/s112/hex/s112_nrf52_6.1.0_softdevice.hex

    3. Edit the preprocessor definition S132 to S112

    4. Edit the Section Placement Macros to:

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x80000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x10000

    FLASH_START=0x19000

    FLASH_SIZE=0x67000

    RAM_START=0x20002500

    RAM_SIZE=0xdb00

    It should now compile without any errors

    1. Create the DFU packet

    Make sure you have the latest nrfutil, by running the command pip install nrfutil in your preferred command window.

    I use the information about generating a DFU packet found on the infocenter to write the following command:

    nrfutil pkg generate --hw-version 52 --sd-req 0xAF,0xB0 --application-version 4 --application <application_hex_file_name>.hex --softdevice s112_nrf52_6.1.0_softdevice.hex --bootloader <bootloader_with_s112v6.1.0_hex_file_name>.hex  --bootloader-version 2 --sd-id 0xB0 --key-file private.pem <dfu_packet_name>.zip


    This command gave me this output:

    I opened the nRF Connect Bluetooth Low Energy Application and connected to the bootloader DfuTarg, and clicked on the DFU button, selected the file and started:

    Start of transfer:

    During transfer:

    Completed:

    And after I've completed the transfer, the name of the devices has changed to Nordic_Buttonless, as expected:

    I hope this will make things clearer, and sorry for the late reply.

    Best regards.

    Andreas

Reply
  • Hi.

    Sorry for the late reply, I tried to answer you yesterday, but the reply got very long, so here it is today.

    I can try to clarify more:

    If you have a bootloader and an application you wish to use for a DFU, the right settings for this DFU .zip file must be given when you create it.

    With that in background, there should not be any issues if your application runs standalone, and your bootloader also runs standalone, to use this application as the upgrade firmware. But, if the DFU Packet is generated with the wrong settings, the bootloader will have a bad time running the application. It might not know what the application start address is, or the end address. Since this is dependent on the SoftDevice. Therefore, it is essential that if you wish to do a DFU where you change SoftDevice version you include this when you generate the DFU packet.  Also, if the SoftDevice version is to be changed, a bootloader with the SoftDevice version of the new firmware is required.

    So, I will try to walk you through the process a bit more:

    To do a DFU where we change the applications SoftDevice we require 3 items in our DFU packet:

    • Bootloader with SoftDevice S112 v6.1.0
    • Application with SoftDevice S112 v6.1.0
    • SoftDevice S112 v6.1.0

     

    We also need a bootloader with SoftDevice S132 v6.1.0.

    So lets start.

    1. Bootloader with SoftDevice S132 v6.1.0

    I used the bootloader project found in nRF5_SDK_15.2.0_9412b96\examples\dfu\secure_bootloader\pca10040_ble

    You need to have a key which you use to verify the DFU packet.

    This can be created by doing the following, which is explained on the infocenter:

    1. Use the nrfutil command:

    nrfutil keys generate private.pem

    In a command window. This command will create a key file.

    Open the bootloader project. And create a new file called dfu_public_key.c in the Application folder, if its there already you dont have to create a new one.

    Use the nrfutil command:

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

    To display the content of the key file in your command window, like this:

    You should now copy the output from the keys display command and replace it with the existing code in dfu_public_key.c, In my case this was the code I pasted and replaced the code in dfu_public_key.c:

    /* This file was automatically generated by nrfutil on 2018-11-29 (YY-MM-DD) at 14:43:06 */
    
    #include "sdk_config.h"
    #include "stdint.h"
    #include "compiler_abstraction.h"
    
    #if NRF_CRYPTO_BACKEND_OBERON_ENABLED
    /* Oberon backend is changing endianness thus public key must be kept in RAM. */
    #define _PK_CONST
    #else
    #define _PK_CONST const
    #endif
    
    
    /** @brief Public key used to verify DFU images */
    __ALIGN(4) _PK_CONST uint8_t pk[64] =
    {
        0xb4, 0xbf, 0x71, 0x80, 0x25, 0x9f, 0x6c, 0xaf, 0x88, 0xd5, 0xfd, 0x03, 0xcf, 0x64, 0xa1, 0x87, 0xef, 0x79, 0xf0, 0x4f, 0xf1, 0x63, 0x36, 0x23, 0xea, 0xd9, 0xff, 0x9f, 0xc9, 0xd9, 0x92, 0x3d,
        0x88, 0xa6, 0xd1, 0xf2, 0x7f, 0xd6, 0xbc, 0x6d, 0x83, 0x78, 0xb7, 0xc7, 0xd3, 0xb1, 0xb3, 0xbe, 0x73, 0x5c, 0x3f, 0x89, 0xd5, 0xbe, 0x39, 0x07, 0xed, 0x2f, 0x25, 0xa4, 0xc2, 0xc7, 0x65, 0x68
    };
    
    
    

    NOTE: Do not use the code I have pasted here, you have to use the code generated from your own key.

    You can now compile the project, and the project should compile without errors. You have no made a bootloader which requires a private key, and the bootloader is using SoftDevice S132 v6.1.0.

                2. Create the Application which uses SoftDevice S112 v6.1.0

    I used the UART example project, but you can use whatever you like

    I just compiled the project found in the folder nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral\ble_app_uart\pca10040\s112

    The projects found in pca10040\s112 folders are setup for nRF52832 Boards and uses SoftDevice S112 v6.1.0.

    If you would like to use a project which does not have a pca10040\s112 folder, you have to set this up yourself by doing the following:

    Copy the pca10040\s132 folder, and open your preferred IDE and do the following modifications:

    1. Change two of the include paths from:

    ../../../../../../components/softdevice/s132/headers
    ../../../../../../components/softdevice/s132/headers/nrf52

    To:

    ../../../../../../components/softdevice/s112/headers

    ../../../../../../components/softdevice/s112/headers/nrf52

    2. Change the SoftDevice included to:

    nRF5_SDK_15.2.0_9412b96/components/softdevice/s112/hex/s112_nrf52_6.1.0_softdevice.hex

    3. Edit the preprocessor definition S132 to S112

    4. Edit the Section Placement Macros to:

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x80000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x10000

    FLASH_START=0x19000

    FLASH_SIZE=0x67000

    RAM_START=0x20002500

    RAM_SIZE=0xdb00

    It should now compile without any errors

                3. Create the Bootloader which uses SoftDevice S112 v6.1.0

    Here, I used the secure_bootloader project (nRF5_SDK_15.2.0_9412b96\examples\dfu\secure_bootloader\pca10040_ble) and did the same thing as I would have done above if I had used a project which did not have a pca10040\s112 folder, That is:

    Copy the pca10040\s132 folder, and open your preferred IDE and do the following modifications:

    1. Changed two of the include paths from:

    ../../../../../../components/softdevice/s132/headers
    ../../../../../../components/softdevice/s132/headers/nrf52

    To:

    ../../../../../../components/softdevice/s112/headers

    ../../../../../../components/softdevice/s112/headers/nrf52

    2. Changed the SoftDevice included to:

    nRF5_SDK_15.2.0_9412b96/components/softdevice/s112/hex/s112_nrf52_6.1.0_softdevice.hex

    3. Edit the preprocessor definition S132 to S112

    4. Edit the Section Placement Macros to:

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x80000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x10000

    FLASH_START=0x19000

    FLASH_SIZE=0x67000

    RAM_START=0x20002500

    RAM_SIZE=0xdb00

    It should now compile without any errors

    1. Create the DFU packet

    Make sure you have the latest nrfutil, by running the command pip install nrfutil in your preferred command window.

    I use the information about generating a DFU packet found on the infocenter to write the following command:

    nrfutil pkg generate --hw-version 52 --sd-req 0xAF,0xB0 --application-version 4 --application <application_hex_file_name>.hex --softdevice s112_nrf52_6.1.0_softdevice.hex --bootloader <bootloader_with_s112v6.1.0_hex_file_name>.hex  --bootloader-version 2 --sd-id 0xB0 --key-file private.pem <dfu_packet_name>.zip


    This command gave me this output:

    I opened the nRF Connect Bluetooth Low Energy Application and connected to the bootloader DfuTarg, and clicked on the DFU button, selected the file and started:

    Start of transfer:

    During transfer:

    Completed:

    And after I've completed the transfer, the name of the devices has changed to Nordic_Buttonless, as expected:

    I hope this will make things clearer, and sorry for the late reply.

    Best regards.

    Andreas

Children
No Data
Related