1 month, 2 weeks ago.

Generating just the Application HEX file during compilation.

When I compile via the online compiler or the offline compiler the resulting hex file contains both the soft device + Application. Is there a way to generate the resulting hex file to contain only the application in the offline compilation mode.

Thanks, Ajay

Question relating to:

The nRF52 Development Kit is a single-board development kit for Bluetooth Smart, ANT and 2.4GHz proprietary applications using the nRF52 Series SoC. This kit supports both development for nRF52832 SoCs.
Comment on this question

1 Answer

1 month, 1 week ago.

Hi Ajay,

The hex file for the application (minus the softdevice) needs to be built so the combined image can be constructed. If you examine the output of the CLI (here we are using the BLE LED example), you will see the the file you are looking for is "mbed-os-example-ble-LED_application.hex" (located under \BUILD\nrf52_dk\gcc_arm):

$  mbed compile -m nrf52_dk -t gcc_arm
Building project mbed-os-example-ble-LED (NRF52_DK, GCC_ARM)
Scan: .
Scan: env
Scan: mbed
Using regions bootloader, application in this build.
  Region bootloader: size 0x23000, offset 0x0
  Region application: size 0x5d000, offset 0x23000
Merging Regions
  Filling region bootloader with C:\Users\xyz\_work\mbed-os-example-ble-LED\mbed-os\targets\TARGET_NORDIC\TARGET_NRF5x\TARGET_SDK_14_2\TARGET_SOFTDEVICE_S132_FULL\hex/s132_nrf52_5.0.0_softdevice.hex
  Padding region bootloader with 0xb58 bytes
  Filling region application with .\BUILD\nrf52_dk\gcc_arm\mbed-os-example-ble-LED_application.hex

The combined image is called "mbed-os-example-ble-LED.hex".

Hi Ralph, Thanks for taking the time to respond. However I am not clear how based on the build o/p that I can separate the Application hex file or just generate a hex file that contains only the application from the resulting build. Are there any compile options or any build options so I can control the resulting build o/p?

Thanks, Yogesh

posted by Ajay Kashyap 09 Jun 2018

Hi Ralph,

I saw this piece of configuration that you can add to the target overrides, in mbed_app.json file. I am building my application and the version of the mbed os is 5.85. By adding this can I ensure the build doesn't contain the softdevice in the resulting build? However I get a compilation error cannot parse mbed_app.json file. Any thoughts?

{ "target_overrides": { "*": { "target.bootloader_img": null } } }

Thanks, Ajay

posted by Ajay Kashyap 26 Jun 2018

Hi Ajay,

Thanks for re-wording your question. We now understand that you are simply trying to remove the softdevice from the build - is that correct? To do this, you are on the right trail. In the mbed_app.json file you will want to remove the softdevice COMMON and FULL references and add one defined NONE. Please try this in your file:

    "target_overrides": {
        "NRF52_DK": {
            "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_S132_FULL"],
            "target.extra_labels_add": ["SOFTDEVICE_NONE"]
        "NRF52840_DK": {
            "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_S140_FULL"],
            "target.extra_labels_add": ["SOFTDEVICE_NONE"]

We've included both Nordic DK targets as the softdevices are different. You should now see a single hex file generated in the BUILD folder.

This is documened in the readme here:

posted by Ralph Fulchiero 27 Jun 2018

Hi Ralph, Does this target_overrides work with mbed os 5.8.5. Even though I have the mbed_app.json included in the root folder, yet the softdevice is included in the build.

Elf2Bin: mOrsatFuelTankSensor-5.8.5 [DEBUG] FromELF: arm-none-eabi-objcopy -O ihex .\BUILD\NRF52_DK\GCC_ARM\mOrsatFuelTankSensor-5.8.5.elf .\BUILD\NRF52_DK\GCC_ARM\mOrsatFuelTankSensor-5.8.5.hex [DEBUG] Return: 0 [DEBUG] SoftDevice file found s132_nrf52_2.0.0_softdevice.hex. [DEBUG] Merge SoftDevice file s132_nrf52_2.0.0_softdevice.hex +-------+--+-+-+



+-------+--+-+-+ Total Static RAM memory (data + bss): 13152 bytes Total Flash memory (text + data): 140150 bytes

Thanks, Ajay

posted by Ajay Kashyap 28 Jun 2018

Hi Ralph, Thanks for your inputs. I figured it out. The changes you mentioned is relevant from 5.9.x and so for versions prior to that i had to update the targets.json to prevent the softdevice from being merged into the resulting build.

Thanks, Ajay

posted by Ajay Kashyap 30 Jun 2018

To post an answer, please log in.