6 years, 2 months ago.

Is it possible to modify configuration parameters on Online Compiler?

The documentation on configuration parameters is unclear. I want to list some of my doubts in the following.

"When present, mbed_app.json may override configuration parameters defined in libraries" : does it mean that its not mandatory to have mbed_app.json file after compilation?

Is there a single file where all configuration parameters can be modified? (as they are spread across different mbed_lib.json files)

Is it possible to modify configuration parameters on online compiler? If yes please explain how this can be done.

I have complied and exported the "kionix-kx 123-hello" example and I could not find the mbed_app.json file. Please explain on how to change the parameters for this example.

1 Answer

6 years, 2 months ago.

Hello Venkatesh,

  • Yes, it's true that it isn't mandatory to have an mbed_app.json file in your project. You nedd to create one only when you would like to override some existing or add some new features or components to your project.
  • Yes, there is such file. If you would like to keep your target than it's the mbe_app.jsonfile. In case you would like to have a new target derived from an existing one it's the custom_targets.json file.
  • Yes. You can add an mbed_app.json or custom_targets.json file to your project also when using the online compiler as follows:
    • Open your project
    • On the toolbar, click on the small arrow located on the New button.
    • Select New File ... from the drop list menu.
    • Give it a name as appropiate (mbed_app.json or custom_targets.json)
    • Edit the file as needed, then click on the Save button (or press Ctrl+s).
  • If there is no configuration file in your project, for example in the "kionix-kx 123-hello" and you would like to configure it, then add one as appropriate (see above how).

Accepted Answer

If I look at examples for mbed_app.json file it contains little information. How can all the configuration parameters for all the nrf drivers be written in one mbed_app.json file. If you can explain how to write mbed_app.json file for one of the drivers (for example - SPI) it would be helpful.

posted by Venkatesh Pujari 12 Oct 2018

Mbed's configuration system is described at https://os.mbed.com/docs/v5.10/reference/configuration.html. The default configuration for a particular target is defined by mbed in the targets.json file (see the link above).
For example, for the Nordic nRF52-DK we find there:

    "NRF52_DK": {
        "supported_form_factors": ["ARDUINO"],
        "inherits": ["MCU_NRF52832"],
        "release_versions": ["5"],
        "device_name": "nRF52832_xxAA"
    },

Because it inherits the configuration of the MCU_NRF52832 we have to look at that one as well:

    "MCU_NRF52832": {
        "inherits": ["Target"],
        "core": "Cortex-M4F",
        "macros": [
            "BOARD_PCA10040",
            "NRF52",
            "TARGET_NRF52832",
            "CMSIS_VECTAB_VIRTUAL",
            "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\"",
            "MBED_TICKLESS"
        ],
        "device_has": [
            "ANALOGIN",
            "FLASH",
            "I2C",
            "I2C_ASYNCH",
            "INTERRUPTIN",
            "ITM",
            "LPTICKER",
            "PORTIN",
            "PORTINOUT",
            "PORTOUT",
            "PWMOUT",
            "SERIAL",
            "SERIAL_ASYNCH",
            "SERIAL_FC",
            "SLEEP",
            "SPI",
            "SPI_ASYNCH",
            "STCLK_OFF_DURING_SLEEP",
            "TRNG",
            "USTICKER"
        ],
        "extra_labels": [
            "NORDIC",
            "NRF5x",
            "NRF52",
            "SDK_14_2",
            "SOFTDEVICE_COMMON",
            "SOFTDEVICE_S132_FULL"
        ],
        "config": {
            "lf_clock_src": {
                "macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC",
                "help": "Select Low Frequency clock source. Options: NRF_LF_SRC_XTAL, NRF_LF_SRC_SYNTH, and NRF_LF_SRC_RC",
                "value": "NRF_LF_SRC_XTAL"
            },
            "lf_clock_rc_calib_timer_interval": {
                "macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_TIMER_INTERVAL",
                "value": 16
            },
            "lf_clock_rc_calib_mode_config": {
                "macro_name": "MBED_CONF_NORDIC_NRF_LF_CLOCK_CALIB_MODE_CONFIG",
                "value": 0
            }
        },
        "OUTPUT_EXT": "hex",
        "is_disk_virtual": true,
        "supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
        "public": false,
        "detect_code": ["1101"],
        "program_cycle_s": 6,
        "bootloader_supported": true
    },

Here we learn that the SPI (driver) is supported by mbed for this board so we can use it in our application program. There is nothign to configure for the SPI driver.

If it wasn't supported then we would have to write the code (in C, C++ language) for such SPI driver by ourself and then tell mbed about it (configure it) by adding an mbed_app.json file to our project with the following content:

mbed_app.json

{
    "target_overrides": {
        "NRF52_DK": {
            "target.device_has": ["SPI"]
        }
    }
}

For example, the CAN driver is not supported by mbed for the Seeed Arch Max board. In order to use it I have added the missing portion of code and after adding a proper mbed_app.json one can use it in his/her program (see https://os.mbed.com/users/hudakz/code/STM32F407VET6_Hello/ for more details).

If you are looking for the configuration of the SPI peripheral driver (like pins, format, frequency) used in your program then you can find it at https://os.mbed.com/docs/v5.10/apis/spi.html.

posted by Zoltan Hudak 12 Oct 2018