Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 7 months 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:
1 Answer
6 years, 6 months 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 Scan: FEATURE_BLE 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 09 Jun 2018Hi 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 26 Jun 2018Hi 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 27 Jun 2018Hi 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
+-------+--+-+-+
Module | .text | .data | .bss |
+-------+--+-+-+
Ble\FuelTankService.o | 3889 | 4 | 18 |
Ble\OrsatBle.o | 4774 | 0 | 5 |
Common\ConfigurationManager.o | 1819 | 0 | 4 |
Common\OrsatLog.o | 134 | 24 | 0 |
[fill] | 307 | 7 | 59 |
[lib]\c.a | 39219 | 2472 | 56 |
[lib]\gcc.a | 7180 | 0 | 0 |
[lib]\m.a | 272 | 0 | 0 |
[lib]\misc | 236 | 12 | 28 |
[lib]\nosys.a | 32 | 0 | 0 |
[lib]\stdc++.a | 7644 | 40 | 204 |
main.o | 835 | 4 | 104 |
mbed-os\drivers | 2014 | 0 | 40 |
mbed-os\events | 1472 | 0 | 101 |
mbed-os\features | 23678 | 9 | 784 |
mbed-os\hal | 1421 | 8 | 130 |
mbed-os\platform | 3243 | 260 | 105 |
mbed-os\rtos | 14121 | 168 | 6125 |
mbed-os\targets | 24712 | 140 | 2241 |
Subtotals | 137002 | 3148 | 10004 |
+-------+--+-+-+
Total Static RAM memory (data + bss): 13152 bytes
Total Flash memory (text + data): 140150 bytes
Thanks, Ajay
posted by 28 Jun 2018