ARMmbed / mbed-os

Arm Mbed OS is a platform operating system designed for the internet of things
https://mbed.com
Other
4.67k stars 2.98k forks source link

"target.header_offset" and "target.app_offset" ignored when defined in mbed_lib.json #14174

Open TaniaMirzin opened 3 years ago

TaniaMirzin commented 3 years ago

Hi, am working with mbed-os https://github.com/ARMmbed/mbed-os/#f2278567d09b9ae9f4843e1d9d393526b9462783 and I am using a prebuild bootloader. As I am using bootloader not from mbed-os\features\FEATURE_BOOTLOADER\, the "BOOTLOADER" feature is turned off in my mbed_app.json file. My prebuild bootloader directory has its own mbed_lib.json file with path to the specific bootloader bin file, header format , "target.app_offset" and "target.header_offset" configurations. It seems that all values are taken from this mbed_lib.json files except "target.app_offset" and "target.header_offset" values. It is seems that when a build occurs, the application placed immediately after the bootloader and ignoring these values of header and application offset. Is this behavior ok? What should I make to take these configs from my mbed_lib.json?

output :

Building project mbed-cloud-client-example-internal (DISCO_L475VG_IOT01A, GCC_ARM)
Scan: mbed-cloud-client-example-internal
Using ROM regions bootloader, header, application, post_application in this build.
  Region bootloader: size 0x6800, offset 0x8000000
  Region header: size 0x50, offset 0x8008000
  Region application: size 0x77600, offset 0x8008200
  Region post_application: size 0x80800, offset 0x807f800

When header and application should be taken from prebuilt-bl\TARGET_DISCO_L475VG_IOT01A\TARGET_BL_INTERNAL_FLASH\mbed_lib.json with these configurations:

{
    "name": "mbed-bootloader-DISCO_L475VG_IOT01A-TARGET_BL_INTERNAL_FLASH",
    "target_overrides": {
        "*": {
            "target.macros_add": [
                "MBED_BOOTLOADER_FLASH_BANK_SIZE=MBED_ROM_SIZE/2",
                "MBED_CONF_STORAGE_STORAGE_TYPE=TDB_INTERNAL",
                "MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS=(MBED_ROM_START + MBED_BOOTLOADER_FLASH_BANK_SIZE)",
                "MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE=(2*16*1024)",
                "MBED_CLOUD_CLIENT_FOTA_BLOCK_DEVICE_TYPE=FOTA_INTERNAL_FLASH_BD",
                "MBED_CLOUD_CLIENT_FOTA_STORAGE_START_ADDR=(MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS + MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE)",
                "MBED_CLOUD_CLIENT_FOTA_STORAGE_SIZE=(MBED_BOOTLOADER_FLASH_BANK_SIZE - MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE)"

            ],
            "target.bootloader_img": "mbed-bootloader-e7ebbc1.bin",
            "target.header_offset" : "0x8000",
            "target.app_offset"    : "0x8200",
            "target.restrict_size" : "0x77E00",
            "target.header_format": [
                ["magic", "const", "32le", "0x5c0253a3"],
                ["firmwareSize", "size", "32le", ["application"]],
                ["firmwareVersion", "const", "64le", "0x0"],
                ["firmwareDigest", "digest", "SHA256", "application"],
                ["reserved", "digest", "SHA256", "application"]
            ]
        }
    }
}
ciarmcom commented 3 years ago

@TaniaMirzin This issue has an incomplete or old issue template.For future reference please use an up to date clone of the repository before raising issues. Many thanks.

ciarmcom commented 3 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-3277

0xc0170 commented 3 years ago

According to the docs, https://os.mbed.com/docs/mbed-os/v6.6/program-setup/bootloader-configuration.html , it should work.

@ARMmbed/mbed-os-tools please review

ghost commented 3 years ago

you are using the mbed cli and not the beta https://github.com/ARMmbed/mbed-tools for this right? It works for me with the mbed cli, but does not yet work with mbed-tools

TaniaMirzin commented 3 years ago

@jrobeson I am using mbed-cli --version 1.10.2

ThomasGonet commented 3 years ago

Hello, same problem here with mbed-cli version 1.10.5.

Only workaround is to put this params into mbed-app.json for the moment.