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
  • Andreas, Thanks for your detailed response!

    From your response I can see the missing step for me was to change FLASH_START and FLASH_SIZE in my application build settings. Once I did that I was able to create a single HEX image containing the bootloader, S112, and application and then boot the system and get the application to run normally. After that it was easy to get DFU working again.

    I appologize if I did not communicate the problem clearly. There was never a problem with the DFU upgrade itself, the problem was just getting the DFU application to boot up.

    Based on your response I went back into the SoftDevice Specification and found the section about memory usage. Here it gives some clues about how you need to build your application to be compatible with the SoftDevice flash locations. This is the info I was missing.

    I did run into one problem with your instructions regarding the bootloader. In my case I had to skip the steps where you change the FLASH_XXX macros in the bootloader project. If I made this change I was not able to build the single HEX image containing all three images. When I ran hexmerge it reported an error about overlapping sections. So instead I just used the original values for the bootloader project.

    So to summarize for the benefit of anyone else trying this, here are the steps to replace S132 with S112 and get your application running again:

    1) Modify your application
    1.1) Go to your application folder and copy the entire folder pca10040\s132 to pca10040\s112
    1.2) Modify your project file to use S112 instead of S132
    1.2.1) In my case I use SES so I opened my project file (pca10040\s112\ses\application.emProject) in a text editor
    1.2.2) Do a global replace: 132 --> 112
    1.2.3) Change your flash section placement macros to align with the S112 requirements: FLASH_START=0x19000;FLASH_SIZE=0x67000
    1.2.4) Build

    2) Modify your bootloader. In my case I am using examples\dfu\secure_bootloader
    2.1) Create a new copy of your bootloader project file. In my case I use SES so I copied secure_bootloader_ble_s132_pca10040.emProject to secure_bootloader_ble_s112_pca10040.emProject
    1.2) Modify your bootloader project file to use S112 instead of S132
    1.2.1) In my case I use SES so I opened my project file in a text editor
    1.2.2) Do a global replace: 132 --> 112
    1.2.3) Delete your Output folder and do a full build

    3) Create a single hex image. This example works on Windows:

    set blHex=D:\Nordic\nRF5_SDK_15.2.0\examples\dfu\secure_bootloader\pca10040_ble\ses\Output\Release\Exe\secure_bootloader_ble_s112_pca10040.hex
    set sdHex=D:\Nordic\nRF5_SDK_15.2.0\components\softdevice\s112\hex\s112_nrf52_6.1.0_softdevice.hex
    set appHex=D:\Nordic\nRF5_SDK_15.2.0\examples\ble_peripheral\YourApplication\pca10040\s112\ses\Output\Debug\Exe\YourApplication.hex

    nrfutil settings generate --family NRF52 --application %appHex% --application-version 1 --bootloader-version 1 --bl-settings-version 1 bootloader_settings.hex

    mergehex -m %blHex% bootloader_settings.hex -o bootloaderAndSettings.hex
    mergehex -m bootloaderAndSettings.hex %sdHex% %appHex% -o packageFull.hex

    4) Burn to flash. I just copy the HEX file to the Segger J-Link drive like so:

    copy packageFull.hex f:

    5) Your application should be booting normally now.

Reply
  • Andreas, Thanks for your detailed response!

    From your response I can see the missing step for me was to change FLASH_START and FLASH_SIZE in my application build settings. Once I did that I was able to create a single HEX image containing the bootloader, S112, and application and then boot the system and get the application to run normally. After that it was easy to get DFU working again.

    I appologize if I did not communicate the problem clearly. There was never a problem with the DFU upgrade itself, the problem was just getting the DFU application to boot up.

    Based on your response I went back into the SoftDevice Specification and found the section about memory usage. Here it gives some clues about how you need to build your application to be compatible with the SoftDevice flash locations. This is the info I was missing.

    I did run into one problem with your instructions regarding the bootloader. In my case I had to skip the steps where you change the FLASH_XXX macros in the bootloader project. If I made this change I was not able to build the single HEX image containing all three images. When I ran hexmerge it reported an error about overlapping sections. So instead I just used the original values for the bootloader project.

    So to summarize for the benefit of anyone else trying this, here are the steps to replace S132 with S112 and get your application running again:

    1) Modify your application
    1.1) Go to your application folder and copy the entire folder pca10040\s132 to pca10040\s112
    1.2) Modify your project file to use S112 instead of S132
    1.2.1) In my case I use SES so I opened my project file (pca10040\s112\ses\application.emProject) in a text editor
    1.2.2) Do a global replace: 132 --> 112
    1.2.3) Change your flash section placement macros to align with the S112 requirements: FLASH_START=0x19000;FLASH_SIZE=0x67000
    1.2.4) Build

    2) Modify your bootloader. In my case I am using examples\dfu\secure_bootloader
    2.1) Create a new copy of your bootloader project file. In my case I use SES so I copied secure_bootloader_ble_s132_pca10040.emProject to secure_bootloader_ble_s112_pca10040.emProject
    1.2) Modify your bootloader project file to use S112 instead of S132
    1.2.1) In my case I use SES so I opened my project file in a text editor
    1.2.2) Do a global replace: 132 --> 112
    1.2.3) Delete your Output folder and do a full build

    3) Create a single hex image. This example works on Windows:

    set blHex=D:\Nordic\nRF5_SDK_15.2.0\examples\dfu\secure_bootloader\pca10040_ble\ses\Output\Release\Exe\secure_bootloader_ble_s112_pca10040.hex
    set sdHex=D:\Nordic\nRF5_SDK_15.2.0\components\softdevice\s112\hex\s112_nrf52_6.1.0_softdevice.hex
    set appHex=D:\Nordic\nRF5_SDK_15.2.0\examples\ble_peripheral\YourApplication\pca10040\s112\ses\Output\Debug\Exe\YourApplication.hex

    nrfutil settings generate --family NRF52 --application %appHex% --application-version 1 --bootloader-version 1 --bl-settings-version 1 bootloader_settings.hex

    mergehex -m %blHex% bootloader_settings.hex -o bootloaderAndSettings.hex
    mergehex -m bootloaderAndSettings.hex %sdHex% %appHex% -o packageFull.hex

    4) Burn to flash. I just copy the HEX file to the Segger J-Link drive like so:

    copy packageFull.hex f:

    5) Your application should be booting normally now.

Children
No Data
Related