Code Monkey home page Code Monkey logo

mbed-os-example-pelion's Introduction

Pelion Device Management Client example for Mbed OS

This is a basic Device Management Client example for Mbed OS that supports:

  • The latest Mbed OS and Device Management Client releases.
  • Developer mode provisioning.
  • Firmware Update.

There is a more advanced example of the client with support for multiple operating systems in mbed-cloud-client-example repository. The underlying client library is the same for both. This Mbed OS only example is simpler as it only supports one OS with a limited set of demonstrated features. If you want to do development in Linux and Mbed OS at the same time - you should use the mbed-cloud-client-example.

Note: If you want to use production provisioning modes, or use more advanced client features, those are demonstrated via mbed-cloud-client-example.

Supported boards

This table shows a list of boards that are supported.

Board Connectivity Storage for credentials and FW candidate Notes
Cypress CYTFM_064B0S2_4343W Wi-Fi Internal flash for credentials + external flash for FW candidate To use mbed-os-example-pelion with the CYTFM_064B0S2_4343W board, check out the cytfm-064b0s2-4343w branch and see Running PDMC example on the CYTFM_064B0S2_4343W.
Cypress CY8CPROTO-062-4343W Wi-Fi QSPIF Build-only
Embedded Planet EP_AGORA Cellular SPIF Build-only
Nuvoton NUMAKER_IOT_M263A Wi-Fi ESP8266 SD card (NUSD) Build-only
Nuvoton NUMAKER_IOT_M487 Wi-Fi ESP8266 SD card (NUSD) Build-only
Nuvoton NUMAKER_PFM_M487 Ethernet SD card (NUSD) Build-only
Nuvoton NUMAKER_PFM_NUC472 Ethernet SD card (NUSD) Build-only
NXP K64F Ethernet Internal Flash
NXP K66F Ethernet Internal Flash
Renesas GR_LYCHEE Wi-Fi ESP32 External Flash (See security limitation of this board) Build-only
Renesas RZ_A1H Ethernet External Flash (See security limitation of this board) Build-only
Seeed ARCH_MAX Ethernet SD card Build-only
Seeed WIO_3G Cellular Internal Flash Build-only
Seeed WIO_BG96 Cellular Internal Flash Build-only
ST DISCO_L475VG_IOT01A Wi-Fi QSPIF Build-only
ST DISCO_L496AG Cellular QSPIF Build-only
ST NUCLEO_F411RE Wi-Fi ESP8266 SD card Build-only
ST NUCLEO_F429ZI Ethernet Internal Flash Build-only
ST NUCLEO_F767ZI Ethernet Internal Flash Build-only
ST NUCLEO_H743ZI2 Ethernet Internal Flash Build-only
ST NUCLEO_L4R5ZI Wi-Fi ESP8266 Internal Flash Build-only
ST DISCO_F746NG Ethernet QSPIF Build-only
Uhuru UHURU_RAVEN Wi-Fi ESP32 Internal Flash Build-only

Build-only = This target is currently verified only via compilation, and is not verified at runtime.

Developer guide

This section is intended for developers to get started, import the example application, compile and get it running on their device.

Requirements

  • Mbed CLI >= 1.10.0

    For instructions on installing and using Mbed CLI, please see our documentation.

  • Generate your own access key. Pelion Device Management is available for any Mbed developer. Create a free trial.

    For instructions on how to generate your access key, please see our documentation.

Deploying

This repository is in the process of being updated and depends on few enhancements being deployed in mbed-cloud-client. In the meantime, follow these steps to import and apply the patches before compiling.

```
mbed import mbed-os-example-pelion
cd mbed-os-example-pelion
```

Preparing for build

  1. Configure Mbed CLI defaults:

    mbed target K64F
    mbed toolchain GCC_ARM
    
  2. Download the developer certificates from the Device Management Portal:

    1. Log in to the portal with your credentials.
    2. Navigate to Device identity > Certificates.
    3. Click New certificate.
    4. Add a name and an optional description for the certificate, and click Create certificate.
    5. Go to Device identity > Certificates again.
    6. Click on your new certificate.
    7. Click Download developer C file to download the file mbed_cloud_dev_credentials.c.
  3. Copy the mbed_cloud_dev_credentials.c file to the root folder of the example.

  4. Use manifest-tool python package to create an update-related configuration for your device:

    1. Install the requirements.txt from the application to get the supported version of manifest-tool:
      pip install -r requirements.txt
      
    2. Initialize the developer environment:
      manifest-dev-tool init --access-key <Device Management access key>
      

Compiling

mbed compile

Program Flow

  1. Initialize, connect and register to Pelion DM
  2. Interact with the user through the serial port (115200 bauds)
    • Press enter through putty/minicom to simulate button
    • Press i to print endpoint name
    • Press Ctrl-C to to unregister
    • Press r to reset storage and reboot (warning: it generates a new device ID!)

Further information and requirements

Check the public tutorial for further information:

https://www.pelion.com/docs/device-management/current/connecting/mbed-os.html

Enabling logs

Logging (or tracing) can be enabled by modifying the mbed_app.json file.

```
        "mbed-trace.enable"                         : null,
```

By modifying that null to 1 and recompiling the application.

Log level can be modified compile-time by defining MBED_TRACE_MAX_LEVEL -macro to mbed_app.json:

 "target.macros_add": [
      "MBED_TRACE_MAX_LEVEL=TRACE_LEVEL_INFO",

Default level is TRACE_LEVEL_DEBUG, possible values are:

  • TRACE_LEVEL_DEBUG (largest amounts of logs)
  • TRACE_LEVEL_INFO
  • TRACE_LEVEL_WARN and
  • TRACE_LEVEL_ERROR (smallest amount of logs).

Component level run-time control is also possible by setting log levels (by calling mbed_trace_config_set()) and inclusions/exclusions (by calling mbed_trace_include_filters_set() or mbed_trace_exclude_filters_set()`).

For more details, see the mbed-trace library.

Troubleshooting

  • Device initializes but can't register to Pelion

    Error: client_error(3) -> Bootstrap server URL is not correctly formed

    Solution: Format the the storage by pressing 'r' in the serial terminal.

Porting process to add support for an Mbed Enabled board

There are many steps involved in this process. We generally recomend the following steps:

  1. Configure the application using mbed_app.json
    • Configure the default connectivity
    • Configure the KVSTORE area to store credentials (internal or external memory)
    • Build the application, program the board and observe whether the application can connect to Pelion DM by using a serial terminal.
  2. Configure the bootloader using bootloader_app.json
    • Configure the KVSTORE area
    • Configure the FW Candidate Storage
    • Build bootloader application, program the board and observe whether this is able to boot.
  3. Enable application with bootloader using mbed_app.json
    • Enable the usage of the bootloader
    • Ensure the KVSTORE addresses and FW Candidate storage addresses match with the bootloader configuration
    • Build the application again (this time combined with bootloader) and check whether it can boot and connect to Pelion DM.
    • Perform a FW Update and check whether the process can be completed succesfully.

1. Application configuration

Note: consider allocating the credentials on internal flash to simplify the application setup process. In addition, consider the use of internal flash to store the firmware candidate image for the FW update process as this would remove the need to use external components. If there isn't enough space, you may need to enable external storage (SD Card, SPI, etc).

Mbed OS boards should have a default configuration for connectivity and storage in Mbed OS (targets.json). You can extend or override the default configuration using mbed_app.json in this application. Create a new entry under the target name for your device.

a. Connectivity

Specify the default IP connectivity type for your target. It's essential with targets that lack default connectivity set in targets.json or for targets that support multiple connectivity options. For example:

  "target.network-default-interface-type" : "ETHERNET",

The possible options are ETHERNET, WIFI and CELLULAR.

Depending on connectivity type, you might have to specify more configuration options. Review the documentation for further information.

b. Storage for credentials

Start by getting familiar with the multiple storage options and configurations supported in Mbed OS.

Then start designing the system memory map, the location of components (whether they are on internal or external memory), and the corresponding base addresses and sizes. You may want to create a diagram similar to the one below to help you to make design decisions:

+--------------------------+
|                          |
|                          |
|                          |
|Firmware Candidate Storage|
|                          |
|                          |
|                          |
+--------------------------+ <-+ update-client.storage-address
|                          |
|         KVSTORE          |
|                          |
+--------------------------+ <-+ storage_tdb_internal.internal_base_address
|                          |
|        Free space        |
|                          |
+--------------------------+
|                          |
|                          |
|        Active App        |
|                          |
|                          |
|                          |
+--------------------------+ <-+ mbed-bootloader.application-start-address
|Active App Metadata Header|
+--------------------------+ <-+ update-client.application-details
|                          |
|        Bootloader        |
|                          |
+--------------------------+ <-+ 0

In cases where the MCU has two separate memory banks, it's appropiate to allocate the bootloader and base application in one bank, and KVSTORE storage at the begining of the second bank followed by a firmware candidate storage.

  • Option 1: Allocating credentials in internal memory

    This is the preferred option whenever possible. Make sure TDB_INTERNAL is the type of storage selected in mbed_app.json. Specify the base address depending on the available memory in the system. The size of this section should be aligned with the flash erase sector. The value should be multiple of 4 with a minimum of 24KB and upwards depending on the use case (for example the usage of certificate chain will increase the need of storage to hold those certificates). An example of this configuration can be seen for the NUCLEO_F429ZI board in this application.

    "storage.storage_type"                      : "TDB_INTERNAL"
    "storage_tdb_internal.internal_base_address": "(MBED_ROM_START+1024*1024)",
    "storage_tdb_internal.internal_size"        : "(128*1024)",
    
  • Option 2: Allocating credentials in external memory:

    This is possible when the board has an storage device wired to the MCU (could be on-board or external component). Make sure FILESYSTEM is specified as type of storage. The blockdevice and filesystem should be one of the supported in Mbed OS (see docs).

    An example of this configuration can be seen for the K64F board in the mbed-cloud-client-example

    "storage.storage_type"                      : "FILESYSTEM",
    "storage_filesystem.blockdevice"            : "SD",
    "storage_filesystem.filesystem"             : "LITTLE",
    "storage_filesystem.internal_base_address"  : "(32*1024)",
    "storage_filesystem.rbp_internal_size"      : "(8*1024)",
    "storage_filesystem.external_base_address"  : "(0x0)",
    "storage_filesystem.external_size"          : "(1024*1024*64)",
    

c. Storage for firmware updates

Before enabling FW updates, it's recomended that the application is able to initialize the network and connect to Pelion DM.

Once the connection is successfull, you can follow the steps below to enable the board to receive FW updates. Note the configuration for the application in this section should match with the one on the bootloader - see section below.

  • Common configuration

    Regardless of where the firmware candidate is located (internal or external), there is a need to have a bootloader in place. The binary of the booloader can be specified with the bootloader_img option. The address and size of the bootloader determines the application-details and bootloader-details options. The value of bootloader-details can be obtained by checking for the symbol from the map file of the binary. Example python code for obtaining the location:

    with open("BUILD/UBLOX_EVK_ODIN_W2/GCC_ARM/mbed-bootloader.map", 'r') as fd:
        s = fd.read()
    
    regex = r"\.rodata\..*{}\s+(0x[0-9a-fA-F]+)".format("bootloader")
    match = re.search(regex, s, re.MULTILINE)
    offset = int(match.groups()[0], 16)
    print hex(offset)

    Review the mbed-bootloader guidelines on how these options should be selected. Review the bootloader configuration section below for more information.

    Copy the compiled bootloader from mbed-bootloader/BUILDS/<TARGET>/<TOOLCHAIN>-TINY/mbed-bootloader.bin to bootloader/mbed-bootloader-<TARGET>.bin.

    Edit mbed-os-pelion-example/mbed_app.json and modify the target configuration to match with the one in bootloader_app.json.

Note:

  • update-client.application-details should be identical in both bootloader_app.json and mbed_app.json.

  • target.app_offset is relative offset to flash-start-address you specified in mbed_app.json and bootloader_app.json, and is the hex value of the offset specified by application-start-address in bootloader_app.json. For example, (MBED_CONF_APP_FLASH_START_ADDRESS+65*1024) dec equals 0x10400 hex.

  • target.header_offset is also relative offset to the flash-start-address you specified in the bootloader_app.json, and is the hex value of the offset specified by update-client.application-details. For example, (MBED_CONF_APP_FLASH_START_ADDRESS+64*1024) dec equals 0x10000 hex.

An example of this configuration can be seen for the NUCLEO_F429ZI board.

    "update-client.application-details"         : "(MBED_ROM_START + MBED_BOOTLOADER_SIZE)",
    "update-client.bootloader-details"          : "0x08007300",
    "target.bootloader_img"                     : "bootloader/mbed-bootloader-<target>",
    "target.header_offset"                      : "0x8000",
    "target.app_offset"                         : "0x8400",
  • Option 1: Allocating the firmware update candidate in internal memory

    This is the preferred option whenever possible. Make sure ARM_UCP_FLASHIAP is selected in update-storage in mbed_app.json. This area should be located at the end of the flash after the KVSTORE area. Specify the storage-address, storage-size and storage-page as required. The application-details option should point at the end of the bootloader area. An example of this configuration can be seen for the NUCLEO_F429ZI board.

    "mbed-cloud-client.update-storage"          : "ARM_UCP_FLASHIAP",
    "update-client.storage-address"             : "(MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS+MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE)",
    "update-client.storage-size"                : "(1024*1024-MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE)",
    "update-client.storage-page"                : 1,
    
  • Option 2: Allocating the firmware update candidate in external memory

When using an external device to the MCU to store the firmware candidate, make sure ARM_UCP_FLASHIAP_BLOCKDEVICE is specified as type of update-storage. Specify the storage-address, storage-size and storage-page as required.

An example of this configuration can be seen for the K64F board in the mbed-cloud-client-example

    "mbed-cloud-client.update-storage"          : "ARM_UCP_FLASHIAP_BLOCKDEVICE",
    "update-client.storage-address"             : "(1024*1024*64)",
    "update-client.storage-size"                : "((MBED_ROM_START + MBED_ROM_SIZE - APPLICATION_ADDR) * MBED_CONF_UPDATE_CLIENT_STORAGE_LOCATIONS)",

2. Bootloader configuration

The bootloader is required to perform FW Updates. The steps below explain how to create a new configuration and binary for the bootloader.

  1. Import as a new application the mbed-bootloader repository.

  2. Edit the bootloader application configuration in this example (bootloader/bootloader_app.json) and add a new target entry. An example of this configuration can be seen for the NUCLEO_F429ZI board:

    "update-client.firmware-header-version"    : "2",
    "mbed-bootloader.use-kvstore-rot"          : 0,
    "mbed-bootloader.bootloader-size"          : "APPLICATION_SIZE",
    "update-client.application-details"        : "(MBED_ROM_START + MBED_BOOTLOADER_SIZE)",
    "mbed-bootloader.application-start-address": "(MBED_CONF_UPDATE_CLIENT_APPLICATION_DETAILS + MBED_BOOTLOADER_ACTIVE_HEADER_REGION_SIZE)",
    "mbed-bootloader.max-application-size"     : "(MBED_ROM_START + MBED_BOOTLOADER_FLASH_BANK_SIZE - MBED_CONF_MBED_BOOTLOADER_APPLICATION_START_ADDRESS)",
    "update-client.storage-address"            : "(MBED_ROM_START + MBED_BOOTLOADER_FLASH_BANK_SIZE + KVSTORE_SIZE)",
    "update-client.storage-size"               : "(MBED_BOOTLOADER_FLASH_BANK_SIZE - KVSTORE_SIZE)",
    "update-client.storage-locations"          : 1,
    "kvstore-size"                             : "2*64*1024",
    "update-client.storage-page"               : 1
    
  3. Compile the bootloader using the bootloader_app.json configuration you've just edited:

    mbed compile -t <TOOLCHAIN> -m <TARGET> --profile=tiny.json --app-config=.../mbed-os-pelion-example/bootloader/bootloader_app.json>

Note: mbed-bootloader is primarily optimized for GCC_ARM, so you may want to compile it with that toolchain. Before jumping to the next step, you should compile and flash the bootloader and then connect over the virtual serial port to ensure the bootloader is running correctly. You can ignore errors related to checksum verification or failure to jump to application - these are expected at this stage.

Validation and testing for the board configuration

The board needs to pass the underlying Mbed OS tests and be supported by official Mbed OS release.

  cd mbed-os
  mbed test -m <target> -t <toolchain>
  cd mbed-os
  mbed test -t <toolchain> -m <board> -n *integration-* -DINTEGRATION_TESTS -v

Validation and testing for the client configuration

Basic pelion features are required to work:

  • Connects to Pelion in developer mode.
  • Firmware can be updated.
  • Responsive to REST API commands.

This should be verified by executing the Pelion E2E python test library tests.

  • Install the prerequisites listed in the README of the pelion-e2e-python-test-library.

  • Configure your access key as instructed in the same README.

  • Basic tests can be then executed as:

    pytest TESTS/pelion-e2e-python-test-library/tests/dev-client-tests.py --update_bin=/home/user/mbed-os-example-pelion/mbed-os-example-pelion_update.bin

Contributing platform support

The contribution of platform support to this repository is restricted to Arm Mbed Partners and Arm Engineering teams. If you’d like to add a custom or community-based platform, please fork this repository and add it into your own account. Expectations on contributions:

  • No code changes in main.cpp. This is a minimal and generic application that’s expected to work on out of the box with all platforms listed in the documentation and Pelion Quick-start guide.

  • No changes to the hash of mbed-os.lib or mbed-cloud-client.lib files. The Mbed OS release used in this repository should be update-to-date but you can raise an issue to be updated by the maintainers.

  • No extra files or .mbedignore with removal of Mbed OS code. You may need to fix issues and send a PR to Mbed OS first.

  • Configuration (required)

    • mbed_app.json to add components or features. Please follow the guidelines in the porting section of the docs.
  • Drivers (optional)

    • If required, drivers for networking or storage (non-default) can be added in the drivers folder using an external library (.lib). For example COMPONENT_MYDRIVER.lib and enabling in mbed_app.json.
  • Bootloader (required)

    • The configuration should be provided in either mbed-bootloader repository (as default configuration) or bootloader folder in this repository (if non-default). Our recommendation is to contribute to the mbed-bootloader repository whenever possible. Please indicate where the bootloader configuration lives.
    • Binaries should be generated and contributed following the name conventions in the bootloader folder.
  • Indication of platform support

    • Please update README.md file and add an entry to the list of supported boards.
  • Test results and other information

    • Attach test logs for required toolchains as documented here
      • Greentea (Mbed OS tests, including integration tests).
      • Pelion E2E tests based on pytest.
    • Mbed OS and Mbed-cloud-client version used during the tests. Note contributions will be accepted only against versions available in the example at that time.
  • Pull-requests are raised against the master branch. The Arm team makes releases regularly.

  • Pelion-Ready. Indicate if a board is expected to be marked as Pelion-Ready and therefore be added to the Pelion Quick-start.

  • You agree that the configuration changes contributed are considered open source and Apache 2.0 licensed.

  • Support of the platform is provided by Silicon Partners or Platform vendors for Mbed Enabled platforms. If using a non-default configuration, then Arm is responsible for its support.

Note platforms will be tested regularly in the Arm CI system. Please discuss with your Arm contact and make hardware available as indicated in the Mbed Enabled requirements.

Known-issues

Please review existing issues on GitHub and report any problem you may see.

mbed-os-example-pelion's People

Contributors

ccli8 avatar esajaa avatar guywi avatar qasim-ublox avatar soleilplanet avatar teetak01 avatar toyowata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mbed-os-example-pelion's Issues

Use of Ctrl+C to copy text can cause accidental deregister of the client

Background:
For Windows users, it is common to use Ctrl+C to copy text. If someone uses this command to try to copy text from the serial terminal window (example: coping the device ID), then it causes the client to deregister. This can be confusing.

Suggestion:
Use a less command command, such as Ctrl+X to trigger the deregister.

I have tested this, and it works.

        } else if (in_char > 0 && in_char != 0x18) { // Ctrl+X is 0x18
            button_press(); // Simulate button press
            continue;
        }
        // if Ctrl+X, then reach this point and trigger deregister
        deregister_client();
        break;

slow network / fota never finishes on CY8CKIT_062S2_43012

Describe the bug
While testing CY8CKIT_062S2_43012 with this example, we encountered the following issues:

  • Initial network connection fails sometimes
  • The network connection is very slow, causing long delay in FOTA download
  • Initialization issue with the latest Mbed OS 6.x and Mbed Client

The issues in the last item are being investigated by the Pelion team in a separate ticket.

We believe that the network issues could be independent of the Mbed OS and Client versions.

We pushed changes to the following branch to allow the network to be tested.
https://github.com/ARMmbed/mbed-os-example-pelion/tree/CY8CKIT_062S2_43012

To Reproduce
Steps to reproduce the behavior:

  1. get clone https://github.com/ARMmbed/mbed-os-example-pelion/
  2. git checkout -B CY8CKIT_062S2_43012 origin/CY8CKIT_062S2_43012
  3. Follow the steps in https://developer.pelion.com/docs/device-management/current/connecting/mbed-os.html starting at step 2 under Configuring Device Management Client, including testing the firmware update.

Expected behavior
The firmware should be able to be downloaded in a few minutes. However, on this device it is very slow and it is difficult to tell if it will ever finish.

Logs
none available

Host system (please complete the following information):

  • OS: tested on MacOS, but shouldn't matter
  • Compiler: Arm Compiler 6
  • Compiler version: (latest version of Mbed Studio as of January 2021)
  • Mbed CLI version (if used):

Device information:

  • Device: CY8CKIT_062S2_43012
  • OS: Mbed OS 5.15.x
  • Client version: 4.3.0
  • Other SW: [attach printout of mbed ls]

Additional context
Add any other context about the problem here.

[REQ] Support MUS-CA with TF-M

For non TF-M platform, Pelion example could work with standard Mbed API of kv-store & block device.
In Mbed OS v6.x, MUS-CA with TF-M could support secure storage but (1) how to store key or provision ? (2) how to operate block device for storage ?

Traceback error when running tests

Running basis test (serial dependency) and getting this traceback consistently when testing on K64F.

2019-07-05T16:26:23.827Z | Iteration 1 of 1
2019-07-05T16:26:23.834Z | 
2019-07-05T16:26:23.834Z | START TEST CASE EXECUTION: 'put'
2019-07-05T16:26:23.835Z | 
2019-07-05T16:26:23.837Z | TC     MainThread: ------TEST BENCH SETUP STARTS---------
INFO:transitions.core:Exited state initial
INFO:transitions.core:Entered state setup
2019-07-05T16:26:23.838Z | TC     MainThread: ------TEST BENCH SETUP ENDS---------
2019-07-05T16:26:23.838Z | TC     MainThread: ------TC SETUP STARTS---------
INFO:transitions.core:Exited state setup
INFO:transitions.core:Entered state setup_test
2019-07-05T16:26:28.888Z | TC     MainThread: ------TC SETUP ENDS---------
2019-07-05T16:26:28.889Z | TC     MainThread: ------TEST CASE STARTS---------
INFO:transitions.core:Exited state setup_test
2019-07-05T16:26:28.889Z | TC     MainThread: Testing PUT 1000:1000:1000:1000 with value /3201/0/5853
2019-07-05T16:27:29.327Z | TC     MainThread: PUT request failed with 0 and msg Timeout getting async value. Timeout: 60 seconds
2019-07-05T16:27:29.328Z | TC     MainThread: -----------TEST CASE ENDS-----------
2019-07-05T16:27:29.328Z | TC     MainThread: Test case failed.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/icetea-2.0.0-py2.7.egg/icetea_lib/TestBench/RunnerSM.py", line 271, in run
    self.setup_test_to_executing()
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 383, in trigger
    return self.machine._process(func)
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 1047, in _process
    return trigger()
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 399, in _trigger
    return self._process(event_data)
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 409, in _process
    if trans.execute(event_data):
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 263, in execute
    self._change_state(event_data)
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 274, in _change_state
    event_data.machine.get_state(self.dest).enter(event_data)
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 120, in enter
    event_data.machine.callback(handle, event_data)
  File "/usr/local/lib/python2.7/site-packages/transitions/core.py", line 1005, in callback
    func(*event_data.args, **event_data.kwargs)
  File "/usr/local/lib/python2.7/site-packages/icetea-2.0.0-py2.7.egg/icetea_lib/TestBench/RunnerSM.py", line 123, in _run_cases
    getattr(self._benchapi, test)()
  File "/Users/marsal01/mbed/sip-workshop/pelion/mbed-os-pelion-example/TESTS/put.py", line 46, in case
    raise TestStepFail("PUT request failed with %d and msg %s" % (error.status, error.message))
TestStepFail: PUT request failed with 0 and msg Timeout getting async value. Timeout: 60 seconds

@teetak01

pytest stops parsing device log by invalid character code

I faced a strange problem by pytest for ST's Cortex-M7 target.
The pytest doesn't seem to run test cases because of timeout error.

For the NUCLEO_F767ZI or UHURU_RAVEN (same MCU as the NUCLEO_F767ZI) target, I saw invalid some characters in between jump from the bootloader to application (Mbed OS start-up code). It is no issue for PDMC example functionality, but pytest does not parse device log correctly and test become timeout error.

I checked this on both Windows and Mac environment and both ARM and GCC_ARM toolchains (they are all same result).

NUCLEO_F767ZI or UHURU_RAVEN

See #108

Serial terminal output - see next line of booting...

Mbed Bootloader
Update image is older
[DBG ] Active firmware up-to-date
booting...
˝.¿<Application ready
Connect to network
Network initialized, connected with IP 10.128.4.42

Start developer flow
Create resources
Register Pelion Device Management Client

Client registered.
Account ID: 0xxxxxxxxxxxxxxxxxxxxxxx00000000
Endpoint name: xxxxxxxxxxxx0000000000xxxxxxxxxx
Device ID: xxxxxxxxxxxx0000000000xxxxxxxxxx

pyest log - doesn't seem to parse after the booting... line and it will be timeout error.

16:12:33 mbed-os-example-pelion-1 $ pytest TESTS/pelion-e2e-python-test-library/tests/dev-client-tests.py
================================================================= test session starts =================================================================
platform darwin -- Python 3.6.1, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/toywat01/test/uhuru/mbed-os-example-pelion-1/TESTS/pelion-e2e-python-test-library/tests, inifile: pytest.ini
plugins: html-2.0.1, metadata-1.8.0
collected 6 items                                                                                                                                     

TESTS/pelion-e2e-python-test-library/tests/dev-client-tests.py::test_01_get_device_id 
------------------------------------------------------------------- live log setup --------------------------------------------------------------------
2020-02-05 16:12:40.542      INFO   Using "NUCLEO_F767ZI[0]: 08180221041F69063B5BF023" device at "/dev/tty.usbmodem14203" port for tests
2020-02-05 16:12:42.546      INFO   Starting runner threads for client "D0"
2020-02-05 16:12:42.954      INFO   <--|D0| Counter 24
2020-02-05 16:12:42.961      INFO   <--|D0| 
2020-02-05 16:12:42.963      INFO   <--|D0| Mbed Bootloader
2020-02-05 16:12:43.027      INFO   <--|D0| Update image is older
2020-02-05 16:12:43.030      INFO   <--|D0| [DBG ] Active firmware up-to-date
2020-02-05 16:12:43.031      INFO   <--|D0| booting...

Full test result: pytest_log_full.txt

DISCO_F746NG (https://os.mbed.com/teams/st/code/pelion-example-common/)

Serial terminal output - see next line of [BOOT] Forwarding to application...

[BOOT] Mbed Bootloader
[BOOT] ARM: 00000000000000000000
[BOOT] OEM: 00000000000000000000
[BOOT] Layout: 0 8009160
[BOOT] Active firmware integrity check:
[BOOT] SHA256: 421142F70604D55DB93A22AC98A5A35CB54D800198431EA83A457F238593B72C
[BOOT] Version: 1580885161
[BOOT] Slot 0 is empty
[BOOT] Active firmware up-to-date
[BOOT] Application's start address: 0x8010400
[BOOT] Application's jump address: 0x803977D
[BOOT] Application's stack address: 0x20050000
[BOOT] Forwarding to application...
˝..¿.
Starting Simple Pelion Device Management Client example
You can hold the user button during boot to format the storage and change the device identity.
Connecting to the network using the default network interface...

pyest log - doesn't seem to parse after the [BOOT] Forwarding to application... line and it will be timeout error.

15:55:05 mbed-os-example-pelion-1 $ pytest TESTS/pelion-e2e-python-test-library/tests/dev-client-tests.py
================================================================= test session starts =================================================================
platform darwin -- Python 3.6.1, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Users/toywat01/test/uhuru/mbed-os-example-pelion-1/TESTS/pelion-e2e-python-test-library/tests, inifile: pytest.ini
plugins: html-2.0.1, metadata-1.8.0
collected 6 items                                                                                                                                     

TESTS/pelion-e2e-python-test-library/tests/dev-client-tests.py::test_01_get_device_id 
------------------------------------------------------------------- live log setup --------------------------------------------------------------------
2020-02-05 15:55:24.042      INFO   Using "DISCO_F746NG[0]: 08150221093A680C367EF124" device at "/dev/tty.usbmodem14203" port for tests
2020-02-05 15:55:26.050      INFO   Starting runner threads for client "D0"
2020-02-05 15:55:26.458      INFO   <--|D0| ADC temp:  23.7118 C,  vref: 0.3656 %
2020-02-05 15:55:26.468      INFO   <--|D0| [BOOT] Mbed Bootloader
2020-02-05 15:55:26.471      INFO   <--|D0| [BOOT] ARM: 00000000000000000000
2020-02-05 15:55:26.474      INFO   <--|D0| [BOOT] OEM: 00000000000000000000
2020-02-05 15:55:26.476      INFO   <--|D0| [BOOT] Layout: 0 8009160
2020-02-05 15:55:26.480      INFO   <--|D0| [BOOT] Active firmware integrity check:
2020-02-05 15:55:26.561      INFO   <--|D0| [BOOT] SHA256: 421142F70604D55DB93A22AC98A5A35CB54D800198431EA83A457F238593B72C
2020-02-05 15:55:26.563      INFO   <--|D0| [BOOT] Version: 1580885161
2020-02-05 15:55:26.600      INFO   <--|D0| [BOOT] Slot 0 is empty
2020-02-05 15:55:26.603      INFO   <--|D0| [BOOT] Active firmware up-to-date
2020-02-05 15:55:26.607      INFO   <--|D0| [BOOT] Application's start address: 0x8010400
2020-02-05 15:55:26.611      INFO   <--|D0| [BOOT] Application's jump address: 0x803977D
2020-02-05 15:55:26.615      INFO   <--|D0| [BOOT] Application's stack address: 0x20050000
2020-02-05 15:55:26.618      INFO   <--|D0| [BOOT] Forwarding to application...

Issue in download certificate from pelion portal

I have download developer certificate throught last month.
But Today itself I found one strange behavior that
when I download developer certficate It is download mbed_cloud_dev_credentials.c
but in file only "undefine" string is there.
Even I create new developer certificate also Facing same Issue
Capture

[BUG]Device Fails to clear credentials and connect to Pelion

Describe the bug
While working with this example on an ST Discovery Kit I run into a problem where the device fails to retrieve the Account ID and Endpoint name. This persists through erasing the credentials and reflashing the board.

The output can be seen here:

Device Output

To Reproduce
Steps to reproduce the behavior:

  1. Program a previously used board that contains different credentials / applications
  2. See error
  3. Clear credentials and/or Re-flash
  4. See error

Logs
Disco Failure Log Pelion Example.txt

Additional context
I have seen this issue on multiple different Disco Boards. I have only had success clearing this example by programming deprecated examples and clearing the credentials using them.

@cvasilak

Fails to build when `mbed-trace.enable=1` and TRACE_LEVEL_DEBUG

Steps:

  • mbed target = K64F
  • mbed toolchain = GCC_ARM
  • Clone and setup dev certificate and update certificate
  • Change mbed-trace.enable from null to 1
  • Change macro to "MBED_TRACE_MAX_LEVEL=TRACE_LEVEL_DEBUG",
  • run mbed compile
    Expect: successful build

Actual result: Build fails at final step

Compile [100.0%]: USBPhy_Kinetis.cpp
Link: mbed-os-example-pelion
/arm_bin/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: ./BUILD/K64F/GCC_ARM/mbed-os-example-pelion_application.elf section `.text' will not fit in region `m_text'
/arm_bin/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: region m_text overflowed with text and data
/arm_bin/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: region `m_text' overflowed by 32452 bytes
collect2: error: ld returned 1 exit status
[ERROR] /arm_bin/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: ./BUILD/K64F/GCC_ARM/mbed-os-example-pelion_application.elf section `.text' will not fit in region `m_text'
/arm_bin/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: region m_text overflowed with text and data
/arm_bin/gcc-arm-none-eabi-8-2018-q4-major/bin/../lib/gcc/arm-none-eabi/8.2.1/../../../../arm-none-eabi/bin/ld: region `m_text' overflowed by 32452 bytes
collect2: error: ld returned 1 exit status

[mbed] ERROR: "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python" returned error.
       Code: 1
       Path: "/arm_bin/mbed-os-example-pelion"
       Command: "/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u /arm_bin/mbed-os-example-pelion/mbed-os/tools/make.py -t gcc_arm -m k64f --source . --build ./BUILD/K64F/GCC_ARM"
       Tip: You could retry the last command with "-v" flag for verbose output
---


Target Agora SIM identity

At some point we are going to be including bootstrapping creds on the SIMs we ship with Agora kits.

Any thoughts on how we might integrate support for that for this example?

Or should it just have it's own example?

[BUG] OOB for Mbed OS 6.0 - error with Online Compiler

Overview

As part of OOB and prep for Mbed 6 release, we're testing the Mbed Online Compiler (specific staging server for OOB).

Describe the bug

Getting a specific error at link time.

To Reproduce

Steps to reproduce the behavior:

  1. Import the https://github.com/ARMmbed/mbed-os-example-pelion into the Online compiler for OOB (ide-oob ...)
  2. Update Mbed OS to Mbed OS 6.0-RC2
  3. Configure Pelion DM credentials
  4. Select K64F
  5. Compile

Expected behavior

A binary should be generated by the Online Compiler and downloaded to let us program the board.

Logs

Error: L6218E: Undefined symbol MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE (referred from ../../build/mbed-cloud-client/factory-configurator-client/factory-configurator-client/source/fcc_dev_flow.K64F.o).
Info: Unable to download. Fix the reported errors...

Device information:

  • K64F
  • Mbed OS 6.0.0-RC2 tag (pre-release)
  • Client version: 4.4.0

Additional context

Note the application compiles/links ok when using Mbed CLI.

This is something for the Tools/Online compiler team to investigate

mbed_app.json configuration is too complex

There are many parameters and values to configure.
The porting process should be somehow simplified.

Also, the bootloader configuration should be simplified, as at the moment is too complex

C030-R412M timeouts when connecting to Pelion over cellular [BUG]

Describe the bug
The U-blox C030-R412M board doesn't connect to Pelion. I have a SIM card and a freshly formatted SD card. I'm using a Vodafone SIM card in the UK, APN is set to wap.vodafone.co.uk in mbed_app.json as indicated by Vodafone. I have attached an antenna.

Expected behavior
The board should connect to Pelion.

Logs
The serial output I'm getting is

Application ready
[INFO][FSST]: KV Dir: kvstore, exists(verified) - now closing it
Connect to network
[INFO][CELL]: New CellularContext  (0x2000e160)
[INFO][CELL]: CellularContext connect
[INFO][CELL]: Start connecting (timeout 1000 ms)
[INFO][CELL]: Modem ready
[INFO][CELL]: Setup SIM (timeout 1000 ms)
[INFO][CELL]: SIM is ready
[INFO][CELL]: RSSI unknown
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 1 seconds
[INFO][CELL]: RSSI unknown
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 2 seconds
[INFO][CELL]: RSSI unknown
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 4 seconds
[INFO][CELL]: RSSI unknown
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 8 seconds
[INFO][CELL]: RSSI unknown
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 16 seconds
[INFO][CELL]: RSSI unknown
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 32 seconds
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 64 seconds
[INFO][CELL]: RSSI -89 dBm
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 128 seconds
[INFO][CELL]: RSSI -51 dBm
[INFO][CELL]: Network registration (timeout 180000 ms)
[INFO][CELL]: Continue after 600 seconds

Host system (please complete the following information):

  • OS: Ubuntu
  • Compiler: GCC_ARM
  • Mbed CLI version (if used): 1.10.0

Device information:
Have the latest mbed-os-example-pelion code(latest commit on 22nd of April). Using mbed-OS and client pointed in there.

How can I get the board connected to Pelion?
Thank you.
George

use of macros in mbed_app.json is restrictive

I'm working with a partner on a platform to connect to Pelion device management. We would like to make a pull request to add this target as an officially "Pelion Ready" board.

However, this device requires some different settings because of the following:

  1. the bootloader is larger than 32K because of code required for a second core
  2. to keep it simple, it uses internal flash for the update storage

I need to change these settings in mbed_app.json, however this would change other unrelated devices.

"MBED_BOOTLOADER_SIZE=(32*1024)",
"ARM_UC_USE_PAL_BLOCKDEVICE=1",

I recommend pushing all configurations including macros down into the device specific area.

For example, instead of the above macros, use something like this for each device:

"target.macros_add"                         : ["MBEDTLS_USER_CONFIG_FILE=\"mbedTLSConfig_mbedOS.h\"", "MBED_BOOTLOADER_SIZE=(48*1024)", "ARM_UC_USE_PAL_BLOCKDEVICE=0"],

SSL Handshake Failed

I have configured my own leshan Server.
I am just replacing my credentials into mbed_cloud_dev_credentials.c
Compile & Run App then I receive

[ERR ][PAL]: SSL handshake return code -0x6b00.

  • OS: [Windows 10]
  • Compiler: Use Mbed Studio Mbed Studio: 1.4.3
  • Compiler version:
  • Mbed CLI version (if used):

Device information:

  • Device: NUCLEO-F429ZI

  • OS: Mbed OS
    Log.txt

  • Client version:

  • Other SW: NA

If I use same mbed_cloud_dev_credentials in pelion-client-lite repo, atleast TLS Connection is done successfully & bootstarp also done at one level..

What should I done wrong ??
Is there any better way ??

Capture

RZ_A1H does not support bootloader

Building project mbed-os-example-pelion-RZ_A1H-ARM-TCP (RZ_A1H, ARMC6)
Scan: mbed-os-example-pelion
Using ROM regions bootloader, header, application in this build.
  Region bootloader: size 0xc000, offset 0x18000000
  Region header: size 0x70, offset 0x18010000
  Region application: size 0x7efc00, offset 0x18010400
Configuration error: Bootloader not supported on this target. RAM start not found in targets.json.

Re-do all bootloader configurations

All the bootloaders will be changed to use internal-flash only + update storage in external storage.

This depends on new bootloader release.

Adding a "pelion-ready" target to this example

Hi,

I would like to know what is the porting process for a target that is already added to pelion-enablement repository? e.g. in case of C030-R412M, it passed all the tests and my PR was merged.

I compared the json file of this example and the one from "pelion-enablement" and there are changes e.g. device-management.xxxx is not present in json file of this example.

@MarceloSalazar

GR Lynchee does not support bootloader

Building project mbed-os-example-pelion-GR_LYCHEE-ARM-TCP (GR_LYCHEE, ARMC6)
Scan: mbed-os-example-pelion
Using ROM regions bootloader, header, application in this build.
  Region bootloader: size 0xc000, offset 0x18000000
  Region header: size 0x70, offset 0x18010000
  Region application: size 0x7efc00, offset 0x18010400
Configuration error: Bootloader not supported on this target. RAM start not found in targets.json.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.