Mistake on this page? Email us

Setting up the client binaries

Tip: If you cannot access some of the repositories referenced in this section, contact us to request access.

Prepare the client files

  1. Clone the embedded application's GitHub repository:

    mbed import https://github.com/PelionIoT/secure-device-access-client-example
    
  2. Navigate to the application folder:

    cd secure-device-access-client-example
    

Build the client for Mbed OS

If you are using developer credentials, build the target as described below. In production mode, skip steps 1 and 2, and provision and store your credentials on your target, as described in the provisioning documentation.

  1. Overwrite the mbed_cloud_dev_credentials.c template file in the secure-device-access-client-example folder with the mbed_cloud_dev_credentials.c file that you downloaded from the Portal.

  2. From the secure-device-access-client-example folder, run the following command to overwrite the mbed_cloud_trust_anchor_credentials.c template file with your trust anchor:

    python create_trust_anchor_dev_cred.py -t "<trust anchor>"
    

    For example:

    python create_trust_anchor_dev_cred.py -t "-----BEGIN PUBLIC KEY-----MFkaEqYHKoZIzj0CAQYIKoZIzj0GAQcDHgAEbiRnZgdzoBpySFDPVPFp3J7yOmrOXJ09O5qVUMOD5knUjX7YbQBF0ueJWPz6tkTGbzORAwDzvRXYUA7vZpB+og==-----END PUBLIC KEY-----"
    

    Note: Be sure to remove any line breaks (\n or \r) in the trust anchor before running create_trust_anchor_dev_cred.py.

  3. Detect and configure the target device:

    • If your device is connected to your computer:

      mbed detect
      mbed target auto
      
    • If your device is not connected to your computer:

      mbed target <target>
      

    Where <target> is K64F.

  4. Set the toolchain:

    mbed config <path to the toolchain binaries>
    mbed toolchain <toolchain>
    
    • <path to the toolchain binaries> may be GCC_ARM_PATH, ARM_PATH or IAR_PATH. You only need this if toolchain binaries are not in the path.
    • <toolchain> may be GCC_ARM, ARM or IAR.
  5. Compile the application:

    mbed compile -DSDA_SERIAL_INTERFACE
    

    Note: You must set developer-mode to 1 in the mbed_app.json file to use developer mode.

  6. Flash the binary to the target:

    1. Connect the target to your computer using USB. The target is listed as a mass storage device.
    2. Drag and drop secure-device-access-client-example/BUILD/K64F/GCC_ARM/secure-device-access-client-example.hex to the target. The LED blinks rapidly; wait for it to finish.
    3. Press the Reset button to restart the device.

Example for K64F and GCC_ARM

mbed import https://github.com/PelionIoT/secure-device-access-client-example
cd secure-device-access-client-example
mbed target K64F
mbed toolchain GCC_ARM
mbed compile -DSDA_SERIAL_INTERFACE