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

Generating just the application hex file

Hi,

I am currently working on generating a dfu over serial uart by testing with the ble_app_blinky example given in the SDK 15.2.0. Currently the ble_app_blinky hex file contains both application and the softdevice. I want to be able to generate the hex file without the softdevice portion in the hex file. Is there any way I can do this? Or is there a way I can unmerge the hex file into their respective application and softdevice hex files? 

  • Hi,

    If you build the project yourself, then the generated hex file is the application only. That is probably the easiest solution.

    Alternatively, it is possible to locate within the hex file where the data for the application is located, and remove everything else. The rest of this answer describes how to do that.

    The hex file is a text file in the Intel HEX format, and removing the SoftDevice can be done using any text editor if you know what you are doing.

    E.g. in nRF5_SDK_15.3.0_59ac345\examples\ble_peripheral\ble_app_blinky\hex\ble_app_blinky_pca10040_s132.hex, the first two lines are:

    :020000040000FA
    :1000000000040020810A000015070000610A0000BA

    Splitting it up to better show the individual parts of those lines, they become:

    :02 0000 04 0000 FA
    :10 0000 00 00040020810A000015070000610A0000 BA

    Everything is hexadecimal values.

    You can ignore most of the values. The important parts from those lines are:

    :## #### 04 0000 ##

    The record type 04 means this is "Extended Segment Address". The value (in this case 0000) should be added in front of any data addresses on the following lines.

    :## 0000 00 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ##

    This is address 0000, record type "Data" (00). The full address is 00000000, as we need to put the extended segment address in front. The hexadecimal sequence (written as xx..xx above) is placed at this address.

    So, as long as you know the start and end address of the SoftDevice, you can locate the "Data" lines for that data and remove it. The SoftDevice is always starting at address 0, and the size is described in the release notes (which you find under <sdk root folder>\components\softdevice\<softdevice variant>\doc\, where <softdevice variant> is e.g. s132 or s140.

    Following the example from above, using the s132 SoftDevice v6.1.1, we see from the SoftDevice release notes that it takes 0x26000 bytes. This means removing the "data" lines from line 1 through line 9416 of the hex file (last line to remove is :105140002A8608019F0916CB327F0B6CF410C00031). Note that we need to keep line 8115, which reads :020000040002F8, as it sets the extended segment address to 0002. That is needed because the application start on address 00026000. Also note that in this case the last SoftDevice data line has (full) address 00025140, and there is a gap in address space before the first application data line with (full) address 00026000.

    There may be some other bytes also described in the hex file, for instance in the UICR area of flash. Particularly for DFU related hex files. Then you may have to remove lines related to that as well.

    Regards,
    Terje

Related