Mistake on this page? Email us

Connect a Raspberry Pi 3 B

Securely connect a Raspberry Pi 3 to Device Management over an Ethernet connection. The Raspberry Pi 3 board runs a custom Linux image, built using Yocto branch Sumo (Yocto version 2.5). This is a small Linux image that contains the tools and libraries needed to run Device Management Client. You can update it using the Update client. The image boots directly into the Device Management Client executable.


For all other requirements, see the tools and account section.

Note: Always use the SSH keys without a passphrase. Using the passphrase makes the mbed deploy command fail.


With Ubuntu, you can install the requirements as:

$ apt-get install -y \
gawk wget git-core diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat libsdl1.2-dev xterm cpio \
cmake git python-pip whois ninja-build
$ pip install click requests

Downloading the developer certificates

Before building, download a developer certificate from Device Management Portal.

Building the Yocto image

  1. Open the terminal.

  2. Create cache directories for quicker builds (Optional):

    sudo mkdir /var/cache/bitbake
    sudo chown <build-username>:<build-username> /var/cache/bitbake
    Then compile the SW with additional flag 'EXTRA_CONF_FILE=1' to enable consecutive builds to be quicker.
  3. Import the top level Yocto repository and install its dependencies:

    git clone https://github.com/PelionIoT/mbed-cloud-client-yocto-setup
    cd mbed-cloud-client-yocto-setup
    mbed deploy
  4. Export the absolute path to your mbed_cloud_dev_credentials.c file in the environment:

    export MBED_CLOUD_IDENTITY_CERT_FILE_IMPORT=/absolute/path/to/credentials/file
  5. Create update-related configuration and credentials using the manifest-tool python package:

    1. Upgrade to manifest-tool version 2.2.0 or higher:
      pip install --upgrade manifest-tool
    2. Initialize the developer environment:
      manifest-dev-tool init --access-key <Device Management access key>
  6. Export the absolute path to your update_default_resources.c file in the environment:

    export MBED_UPDATE_RESOURCE_FILE_IMPORT=/absolute/path/to/credentials/file
  7. Build the Yocto image:

    make -f Makefile.example FOTA_ENABLE=1 build-raspberry-example

    or with cache enabled:

    make -f Makefile.example EXTRA_CONF_FILE=1 FOTA_ENABLE=1 build-raspberry-example

Note: The Yocto build process normally takes a lot of time and resources (disk space and RAM). Depending on the configuration of your PC, the first build might take a few hours to complete. Subsequent builds will be much faster. Using the bitbake caches as described above significantly speeds up the build process.

Copying the Yocto image to the micro SD card

The main output of the Yocto build process above is an SD card image, located in rpi-build/tmp/deploy/images/raspberrypi3/mbed-cloud-client-example-image-raspberrypi3.rpi-sdimg. Copy this image directly to the SD card, using dd or a similar program. See, for example, this document for more information.

Example of how to build and copy an SD image to an SD card:

  1. Check where the SD card is mounted to your PC. Connect an SD card to your PC, then use the lsblk command to locate the SD card. In this example, the SD card is mounted as /dev/sdc and has a size of 7.5GB:

    ~$ lsblk
    sda                    8:0    0 238.5G  0 disk
    ├─sda1                 8:1    0   476M  0 part
    └─sda2                 8:2    0   238G  0 part
      ├─vg00-swap (dm-0) 252:0    0   7.5G  0 lvm  [SWAP]
      └─vg00-root (dm-1) 252:1    0 230.6G  0 lvm  /
    sdb                    8:16   0   1.8T  0 disk
    ├─sdb1                 8:17   0   128M  0 part
    └─sdb2                 8:18   0   1.8T  0 part
    sdc                    8:32   1   7.5G  0 disk
    ├─sdc1                 8:33   1    16M  0 part
    └─sdc2                 8:34   1 492.3M  0 part
  2. Use the dd utility to write the image to the SD card:

    dd if=rpi-basic-image-raspberrypi3.rpi-sdimg of=/dev/sdc

Running the application

To run the Device Management Client example application, insert the micro SD card into the Raspberry Pi 3, and connect it to power. The Yocto image boots into the Device Management Client example executable, which displays its messages on the system console. If you want to view these messages, connect the Raspberry Pi console UART to the PC using a serial to USB converter. This site has more information on how to make the Raspberry Pi console accessible from a PC.

When you have connected the serial to USB converter to the PC, open a terminal emulator (for example screen):

screen /dev/ttyUSB0 115200

You can see the messages from the Linux kernel first, followed by the output of the example application:

Updating the firmware

To update the firmware on your device:

  1. Copy the updated firmware image to you current folder:

    cp $(ls ${rpi-build}/tmp/deploy/images/raspberrypi3/*rootfs.tar.bz2) ${UPDATE_FW_NAME}
  2. Perform the update using manifest-dev-tool:

    manifest-dev-tool update \
        --payload-path ${UPDATE_FW_NAME} \
        --start-campaign \

    During the update flow, the client tracing log shows:

    Download Authorization requested
    Download authorization granted.
    Downloading firmware. %0
    Downloading firmware. %5
    Downloading firmware. %95
    Downloading firmware. %100
    Firmware download finished
    Install Authorization requested

    After this, the device reboots automatically and registers to Device Management.

    Raspberry Pi 3 registered

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