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

CYESKIT_064B0S2_4343W wrong app offset with Mbed 6, Arm compiler #13057

Closed maclobdell closed 4 years ago

maclobdell commented 4 years ago

Description of defect

Background I'm testing mbed-os-example-pelion with CYESKIT_064B0S2_4343W and Mbed OS 6.

This target has a built-in bootloader. The application header is at the base of flash 0x10000000 and the application should start at 0x10000400. When compiling the client, I have to provide information about the target rom and bootloader support. Otherwise it fails to compile the client code because "APPLICATION_ADDR" won't be defined otherwise.

            "target.bootloader_supported"               : true,
            "target.mbed_rom_start"                     : "0x10000000",
            "target.mbed_rom_size"                      : "0x00200000",
            "target.sectors"                            : [[268435456, 512]]

Failure with ARM Compiler - bad offset If I compile with ARM compiler using the above configuration, the output file starts at wrong address 0x0FFFFC00, which is rom start - 0x400. This appears to be introduced by the post-build signing of the application. Result - DAPLINK will fail to program it.

Failure with ARM Compiler - hard fault If I set rom start to "0x10000400", then it compiles, produces a output that has the correct starting address. But it results in a hard fault in the application. Result - Hard fault when the network tries to connect.

Works with GCC If I compile with GCC using 0x10000000 as the rom start, it works fine. The application boots up and connects successfully.

Possible cause of issue When comparing the target code with it's predecessor, CY8CKIT_064S2_4343W, that was previously working, I noticed that there was a change in the linker/scatter files. The new linker files introduce a new macro. #define BOOT_HEADER_SIZE 0x00000400

This macro is used to set the start of the application. Arm Linker: ER_FLASH_VECTORS +BOOT_HEADER_SIZE GCC Linker: .text ORIGIN(flash) + BOOT_HEADER_SIZE :

For some reason this is not working with Arm compiler, but works with GCC.

Target(s) affected by this defect ?

CYESKIT_064B0S2_4343W

Toolchain(s) (name and version) displaying this defect ?

ARM compiler 6

What version of Mbed-os are you using (tag or sha) ?

Tested both mbed-os-6.0.0-beta-1 and mbed-os-6.0.0-beta-1

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-cli 1.10.1

How is this defect reproduced ?

mbed import https://github.com/ARMmbed/mbed-os-example-pelion cd mbed-os-example-pelion git fetch origin pull/133/head:pr133 mbed deploy

Add the following target configuration to mbed_app.json:

        "CYESKIT_064B0S2_4343W": {
            "target.macros_add"                         : ["MBEDTLS_USER_CONFIG_FILE=\"mbedTLSConfig_mbedOS.h\"","ARM_UC_FEATURE_DELTA_PAAL=0"],
            "target.network-default-interface-type"     : "WIFI",
            "storage_tdb_internal.internal_base_address": "0x101B8000",
            "storage_tdb_internal.internal_size"        : "0x00018000",
            "storage.storage_type"                      : "TDB_INTERNAL",
            "update-client.storage-address"             : "0x100DC000",
            "update-client.storage-size"                : "0x000DC000",
            "update-client.storage-locations"           : 1,
            "mbed-cloud-client.update-storage"          : "ARM_UCP_FLASHIAP",
            "update-client.application-details"         : "0x10000000",
            "target.bootloader_supported"               : true,
            "target.mbed_rom_start"                     : "0x10000000",
            "target.mbed_rom_size"                      : "0x00200000",
            "target.sectors"                            : [[268435456, 512]]
        }

mbed compile -m CYESKIT_064B0S2_4343W -t ARM --profile release

mbed compile -m CYESKIT_064B0S2_4343W -t GCC_ARM --profile release

Compare the output files BUILD\CYESKIT_064B0S2_4343W\GCC_ARM-RELEASE\mbed-os-example-pelion.hex and BUILD\CYESKIT_064B0S2_4343W\GCC_ARM-RELEASE\mbed-os-example-pelion.hex

maclobdell commented 4 years ago

I realized that the same issue seems to affect all applications with this target and the arm compiler. I created a new issue for that https://github.com/ARMmbed/mbed-os/issues/13058. closing this as it is duplicate.