Mistake on this page? Email us

Connect a Linux device

Securely connect a Linux device to Device Management over an IP connection.

Note: These instructions explain how to connect a generic Linux device. If you want to connect a Raspberry Pi 3, use the Raspberry Pi 3 tutorial.

Requirements

This requires a Linux PC (64-bit Ubuntu/XUbuntu OS desktop environment).

For all other requirements, see the tools and account section. See also the Mbed CLI instructions.

Connecting the device

  1. Open a terminal, and clone the example repository to a convenient location on your development environment:

    git clone https://github.com/ARMmbed/mbed-cloud-client-example
    cd mbed-cloud-client-example
    

    Note: If you want to speed up mbed deploy, you can remove unnecessary Linux components, such as mbed-os.lib and the drivers/ folder.

  2. Deploy the example repository:

    mbed deploy
    
  3. 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.
  4. Copy the mbed_cloud_dev_credentials.c file to the root folder of the Device Management example.

  5. Navigate to the Device Management Client example folder, and run one of the following commands:

    • For a manually configured build for Release profile:

      python pal-platform/pal-platform.py deploy --target=x86_x64_NativeLinux_mbedtls generate
      cd __x86_x64_NativeLinux_mbedtls
      
      cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./../pal-platform/Toolchain/GCC/GCC.cmake -DEXTERNAL_DEFINE_FILE=./../<external-define-file.txt>
      

      <external-define-file.txt> may be either define.txt for non-PSA or define_linux_psa.txt for PSA variant.

      make mbedCloudClientExample.elf
      
    • For a manually configured build for Debug profile:

      python pal-platform/pal-platform.py deploy --target=x86_x64_NativeLinux_mbedtls generate
      cd __x86_x64_NativeLinux_mbedtls
      
      cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=./../pal-platform/Toolchain/GCC/GCC.cmake -DEXTERNAL_DEFINE_FILE=./../<external-define-file.txt>
      

      <external-define-file.txt> may be either define.txt for non-PSA or define_linux_psa.txt for PSA variant.

      make mbedCloudClientExample.elf
      
    • To compile Device Management Client with KCM over RAM, add the PAL_SIMULATOR_FILE_SYSTEM_OVER_RAM compilation flag.

      Read more about KCM over RAM mode.

    For more details on the manual build procedure, see the PAL platform utility documentation.

  6. The manual build creates binaries under mbed-cloud-client-example/__x86_x64_NativeLinux_mbedtls. In both cases, there are subdirectories ´Debug´ and ´Release´ respectively for the two profiles.

    Note: If you experience build problems, refer to the Troubleshooting section for potential issues and workarounds.

  7. Set the Entropy source:

    export ENTROPYSOURCE=<file-name>

    For example:

    export ENTROPYSOURCE=/dev/urandom

    Note: The ENTROPYSOURCE environment variable is optional. If you do not use it, Device Management uses a default entropy source, which is Linux-platform-dependent.

  8. Run the application (at the respective path, see above):

    ./mbedCloudClientExample.elf
    
  9. You see messages about connecting to Device Management Connect:

    Client registered
    Endpoint Name: 013584750b3400000000000100100051
    Device Id: 013584750b3400000000000100100051
    

Now that your device connects to Device Management, you can read information from it and control it.