Skip to content

ROM Region Merging is not padding correctly #11140

@DrynnBavis

Description

@DrynnBavis

Description

I've got a managed bootloader application of which I've set the target.restrict_size to a value of 0x40000. When I use this binary as a bootloader for my main application, I get the following in my build logs:

Using ROM regions bootloader, application in this build.
  Region bootloader: size 0x10000, offset 0x8000000
  Region application: size 0x170000, offset 0x8010000
Compile [100.0%]: mbed_application.c

This is problematic because the bootloader calls mbed_app_start(POST_APPLICATION_ADDR) which has a value of 0x8040000. Essentially, the linker is placing my main program at 0x8010000 while the bootloader is actually booting into 0x8040000. The behaviour of this is my application just "hangs" after the bootloader completes.

Note that I've also printed the address, sp, and pc, before booting the assembly code within start_new_application() is called, and I got the following results:

calling start_new_application
address -> 0x08040000
sp ------> 0xFFFFFFFF
pc ------> 0xFFFFFFFF

and after I set target.restrict_size back down to something smaller like 0x1000, I see something of more expected behaviour (but still seems to hang):

calling start_new_application
address -> 0x08010000
sp ------> 0x20050000
pc ------> 0x080132DD

Is this a bug on mbed's side? Or do I need to do something in my main program's config to pad out until 0x8040000?

As requested these are contents of your requested files @AGlass0fMilk
bootloader's mbed_app.json:

{
    "config": {
        "default_target" : {
            "value": "TRACK_PILOT2"
        }
    },
    "target_overrides": {
        "*": {
            "mbed-trace.enable": 1,
            "platform.stdio-baud-rate": 115200,
            "platform.stdio-convert-newlines": true
        },
        "MY_CUSTOM_TARGET": {
            "target.restrict_size": "0x00020000"
        }
    }
}

main app's mbed_app.json:

"MY_CUSTOM_TARGET": {
    "enable-swo": "0",
    "spif-driver.SPI_MOSI": "FLASH_SPI_MOSI",
    "spif-driver.SPI_MISO": "FLASH_SPI_MISO",
    "spif-driver.SPI_CLK": "FLASH_SPI_SCK",
    "spif-driver.SPI_CS": "FLASH_SPI_CS",
    "spif-driver.SPI_FREQ": 40000000,
    "target.features_add": ["STORAGE"],
    "target.components_add": ["SPIF"],
    "target.bootloader_img": "../bootloader/build/develop/bootloader.bin"
}

target definition:

"MY_CUSTOM_TARGET": {
    "inherits": ["FAMILY_STM32"],
    "core": "Cortex-M4F",
    "extra_labels_add": [
        "STM32F4",
        "STM32F413xx",
        "STM32F413RH",
        "STM32F413xH",
        "STM32F413ZH"
    ],
    "config": {
        "clock_source": {
            "help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
            "value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
            "macro_name": "CLOCK_SOURCE"
        },
        "lpticker_lptim": {
            "help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
            "value": 1
        }
    },
    "overrides": {
        "lpticker_delay_ticks": 4
    },
    "macros_add": [
        "MBED_TICKLESS",
        "USB_STM_HAL"
    ],
    "device_has_add": [
        "ANALOGOUT",
        "CAN",
        "SERIAL_ASYNCH",
        "TRNG",
        "FLASH",
        "MPU"
    ],
    "bootloader_supported": true,
    "release_versions": [
        "5"
    ],
    "device_name": "STM32F413ZHTx"
}

Issue request type

Target: custom MCU with STM32F413RH processor
Toolchain: GCC_ARM 8.2.1
Tool: mbed-cli
Vers: cfa7938 (HEAD, tag: mbed-os-5.12.2)

[x] Question
[ ] Enhancement
[ ] Bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions