Using mbed_app.json for target overrides makes the target impossible to compile

I am trying to use the mbed_app.json file to create a bootloader .bin file. Using the mbed_app.json file to restrict the app size with target.restrict_size makes the compilation crash at the very end every time.

When my mbed_app.json file looks like this:

{
    "target_overrides": {
        "MAX32630FTHR": {
            "target.restrict_size": "0x4000"
        }
    }
}

I get the following errors and warnings at the end of compilation:

Compile [100.0%]: USBPhy_Maxim.cpp
Link: bootloader
[Warning] @0,0: L3912W: Option 'legacyalign' is deprecated.
[Warning] @0,0: L6803W: Relocation #REL:1 in BUILD/MAX32630FTHR/ARMC6/mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/device/TOOLCHAIN_ARM_STD/startup_MAX3263x.o(.text) with respect to BUILD/MAX32630FTHR/ARMC6/mbed-os/platform/source/TARGET_CORTEX_M
/TOOLCHAIN_ARM/except.o. Thumb Branch is unlikely to reach target inHardFault_Handler(.text).
[Warning] @0,0: L6803W: Relocation #REL:2 in BUILD/MAX32630FTHR/ARMC6/mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/device/TOOLCHAIN_ARM_STD/startup_MAX3263x.o(.text) with respect to BUILD/MAX32630FTHR/ARMC6/mbed-os/platform/source/TARGET_CORTEX_M
/TOOLCHAIN_ARM/except.o. Thumb Branch is unlikely to reach target inMemManage_Handler(.text).
[Warning] @0,0: L6803W: Relocation #REL:3 in BUILD/MAX32630FTHR/ARMC6/mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/device/TOOLCHAIN_ARM_STD/startup_MAX3263x.o(.text) with respect to BUILD/MAX32630FTHR/ARMC6/mbed-os/platform/source/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.o. Thumb Branch is unlikely to reach target inBusFault_Handler(.text).
[Warning] @0,0: L6803W: Relocation #REL:4 in BUILD/MAX32630FTHR/ARMC6/mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/device/TOOLCHAIN_ARM_STD/startup_MAX3263x.o(.text) with respect to BUILD/MAX32630FTHR/ARMC6/mbed-os/platform/source/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.o. Thumb Branch is unlikely to reach target inUsageFault_Handler(.text).
[Warning] @0,0: L6803W: Relocation #REL:5 in BUILD/MAX32630FTHR/ARMC6/mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/device/TOOLCHAIN_ARM_STD/startup_MAX3263x.o(.text) with respect to BUILD/MAX32630FTHR/ARMC6/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/irq_cm4f.o. Thumb Branch is unlikely to reach target inSVC_Handler(.text).
[Warning] @0,0: L6803W: Relocation #REL:7 in BUILD/MAX32630FTHR/ARMC6/mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/device/TOOLCHAIN_ARM_STD/startup_MAX3263x.o(.text) with respect to BUILD/MAX32630FTHR/ARMC6/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/irq_cm4f.o. Thumb Branch is unlikely to reach target inPendSV_Handler(.text).
[Warning] @0,0: L6803W: Relocation #REL:8 in BUILD/MAX32630FTHR/ARMC6/mbed-os/targets/TARGET_Maxim/TARGET_MAX32630/device/TOOLCHAIN_ARM_STD/startup_MAX3263x.o(.text) with respect to BUILD/MAX32630FTHR/ARMC6/mbed-os/cmsis/CMSIS_5/CMSIS/RTOS2/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/irq_cm4f.o. Thumb Branch is unlikely to reach target inSysTick_Handler(.text).
Elf2Bin: bootloader
[ERROR] Bootloader not supported on this target.

So then the obvious solution would be to set bootloader_supported to true. My embed_app.json then looks like this:

{
    "target_overrides": {
        "MAX32630FTHR": {
            "target.restrict_size": "0x4000",
            "target.bootloader_supported": true
        }
    }
}

The error I get at the end is a little different but still about the same:

[ERROR] Bootloader not supported on this target. ROM start not found in targets.json.

Removing the mbed_app.json file fixes it, spelling the name of the device wrong also fixes it. But I need to restrict the size to build a proper bootloader.

I use MBED Studio 14.1 with MBED OS 6.14. The MCU is a MAX32630(FTHR).

What could I be doing wrong here?

[ERROR] Bootloader not supported on this target. ROM start not found in targets.json.

The error typically appears when the target does’t have proper device_name in targets.json which links to mbed-os/tools/arm_pack_manager/index.json file.
You can add proper device_name in your mbed_app.json. Also, I had to increase a value of target.restrict_size to fit my test app.

        "MAX32630FTHR": {
            "target.restrict_size"          : "0x8000",
            "target.bootloader_supported"   : true,
            "target.device_name"            : "MAX32630"
        }
2 Likes

Thank you very much, this seems to have fixed it. I had to increase the restrict_size even further due to me using the entire mbed library for the bootloader (I simply needed the print functions for testing!). But at least it works now.