ARMmbed / mbed-tools

⚠️ Beta Status: New command line tooling for Mbed OS
Apache License 2.0
45 stars 28 forks source link

Bootloader overrides from config are not processed #156

Open rwalton-arm opened 3 years ago

rwalton-arm commented 3 years ago

Description

mbed_app_start and friends are not processed by the config tool.

Issue request type

ghost commented 3 years ago

does mbed_app_start and friends work yet?

rwalton-arm commented 3 years ago

does mbed_app_start and friends work yet?

Sorry, the "bootloader overrides" don't work yet. We do have another backlog item to add those in. We will get to that over the next few weeks.

ladislas commented 3 years ago

@rwalton-arm looking forward to the bootloader settings. It is really needed for our product. We are a bit lost in translation as we are moving to the new CMake build system but need a way to manage the bootloader and application (we are using Pelion)

boraozgen commented 3 years ago

This is blocking adoption for us. How much effort would this require to be implemented?

0xc0170 commented 3 years ago

@boraozgen https://github.com/ARMmbed/mbed-tools/pull/270 - this does not fix the issue? If not, what we are missing? Can you describe what is blocking your project?

boraozgen commented 3 years ago

We are using a bootloader with an application. Therefore it is required to shift the application in ROM. Here it is explained that target.mbed_app_start and target.mbed_app_size can be used to do this, and indeed that is what I use with CLI 1. These options are not yet supported in CLI 2.

I see that #270 adds support for mbed_rom_start and mbed_rom_size, which seem to be doing the same thing, but I'm not sure. I'll try them out.

ghost commented 3 years ago

as far as i can tell it's not quite ready yet. I'm still looking for a way to work around it without editing the ld file itself.

This in particular doesn't work since it doesn't seem to parse from target_overrides:

{
  "target_overrides": {
    "*": {
      "mbed_app_start": "0xA",
      "mbed_app_size: "0xB"
    }
  }
}
boraozgen commented 3 years ago

I tried it today too, like @jrobeson said it does not parse the inputs from mbed_app.json.

{
    "target_overrides": {
        "*": {
            "target.mbed_rom_start": "0x8020200",
            "target.mbed_rom_size": "0xBE000"
        }
    }
}

This does not change anything in mbed_config.cmake. Furthermore I noticed that invalid configurations are not detected in mbed_app.json, but that's another issue.

ladislas commented 3 years ago

hitting the same issue working on mcuboot.

ghost commented 3 years ago

I thought i'd post the actual error from mbed-tools now that i found it again:

WARNING: You are attempting to override an undefined config parameter `target.mbed_app_start`.
It is an error to override an undefined configuration parameter. Please check your target_overrides are correct.
The parameter `target.mbed_app_start` will not be added to the configuration.
WARNING: You are attempting to override an undefined config parameter `target.mbed_app_size`.
It is an error to override an undefined configuration parameter. Please check your target_overrides are correct.
The parameter `target.mbed_app_size` will not be added to the configuration.
rwalton-arm commented 3 years ago

Could you let us know which targets you're working with? I'd guess the parameters aren't defined in targets.json for the target(s) so the tool doesn't want to apply an override. mbed-cli used to rely on another JSON file from CMSIS pack manager to get this information, but we decided the best approach was to move everything to targets.json as the CMSIS pack manager index file wasn't maintained and in some cases conflicted with the definitions in targets.json.

ghost commented 3 years ago

ah, i see the problem then. For me it's the nrf52832 and nrf52840 chips and various boards based on them with a custom bootloader.

boraozgen commented 3 years ago

STM32F4 based custom targets and dev boards (e.g. NUCLEO_F429ZI).

I just modified targets.json to define mbed_rom_start and mbed_rom_size for my target, and indeed the compiler flags appeared in mbed_config.cmake. However I cannot override them in mbed_app.json. What is the syntax for it?

ladislas commented 3 years ago

we decided the best approach was to move everything to targets.json

@rwalton-arm do you want to handle that PR by PR as they come or does it need to be 1 big PR to rule them all?

ladislas commented 3 years ago

Could you let us know which targets you're working with?

@rwalton-arm STM32F769 custom target based on DISCO_F769.

rwalton-arm commented 3 years ago

However I cannot override them in mbed_app.json. What is the syntax for it?

Your syntax above looked correct. I've just tried it myself and I can reproduce the issue. Looks like a bug in the memory region collection.

rwalton-arm commented 3 years ago

we decided the best approach was to move everything to targets.json

@rwalton-arm do you want to handle that PR by PR as they come or does it need to be 1 big PR to rule them all?

PR by PR would be easier to review, but I guess one PR to rule them all would also work.

ladislas commented 3 years ago

We've just tried this, and it seems to be working in our case:

{
    "config": {
        "mbed_app_start": {
            "help": "Use a custom application start address",
            "value": "0x08020000",
            "macro_name": "MBED_APP_START"
        }
    },
    "target_overrides": {
        "*": {
            "platform.stdio-baud-rate": 115200,
        }
    }
}
boraozgen commented 3 years ago

@ladislas this generates the flags in mbed_config.cmake but does not seem to shift the image. A quick search for MBED_CONFIG_DEFINITIONS shows that these flags are not given to the linker. I'm on 6.9.0, don't know if this changed in 6.10.

ladislas commented 3 years ago

we are on 6.9 as well. have you made a deep clean before building? are you using a custom target? (we are)

boraozgen commented 3 years ago

Deep clean did it, don't know why though. Not a good sign IMHO :/

Nice workaround, thanks!

ladislas commented 3 years ago

Great! My team mate @YannLocatelli is the real hero here 🙏

kalle16lab commented 3 years ago

Hi! The workaround mentioned by @ladislas woks but I am also currently interested in switching to CLI2 from Mbed Studio and this is also blocking progress on a commercial project.

Any ETA on a pull request to master to fix this?

ghost commented 3 years ago

@kalle16lab If it's a commercial project, then seems like you should be to able assist right?

ladislas commented 3 years ago

@kalle16lab we are not using mbed studio but mbed cli2

nat45928 commented 2 years ago

I hit this today as well and had to use @ladislas workaround.

Are there plans to get these features pulled into mbed-tools?

rjhind commented 1 year ago

Just looking to put a boot loader on my Nucleo F411 which is now running mbed and hitting this issue. The work-around for an unmanaged boot loader posted above works for offsetting the app address.

Is there a way to make use of the built-in header with this work-around or do we need to manually place the header also?