Mistake on this page? Email us

Set up the factory environment

In this section you simulate the factory provisioning process using an example implementation of Factory Configurator Client (FCC) and Factory Configurator Utility (FCU).

What is factory provisioning?

Factory provisioning is the process of injecting IoT devices with certificates, keys, and device and cloud-related configuration to enable the devices to connect to your Device Management account securely.

What is FCC?

FCC is Device Management device side code that provides an API for provisioning devices at the factory line. Devices that were provisioned successfully through FCC have all the keys, certificates and parameters that are required for proper connection to Device Management.

In this tutorial, you use an example implementation of FCC that we provide.

What is FCU?

FCU is a utility that, together with FCC, allows you to provision devices with all the parameters, keys and certificates they need to connect to Device Management when they leave the factory. The utility can also act as a certificate authority.

In this section

  1. Build FCC example on your computer.
  2. Flash FCC binary from your computer to your device.
  3. Install FCU on your computer.
  4. Configure FCU as required for this tutorial.
  5. Set up the demo tool.
  6. Inject your credentials on your device using the demo tool.

1. Build FCC example

To deploy and build FCC example on your computer, run:

mbed import https://github.com/PelionIoT/factory-configurator-client-example
cd factory-configurator-client-example
mbed toolchain <toolchain>
mbed config <toolchain path> <path to the toolchain binaries>
mbed target <target>
mbed compile -D<INTERFACE>

Where:

  • <toolchain> may be GCC_ARMor ARM.
  • <toolchain path> may be GCC_ARM_PATH or ARM_PATH. This value is only required if the toolchain binaries are not in the path.
  • <target> is your device target name, for example, K64F.
  • <INTERFACE> is the interface to your device. May be FCE_ETHERNET_INTERFACE or FCE_SERIAL_INTERFACE.

2. Flash the binary to your device

Once you have built the FCC binary, you must flash it to your device.

  1. Connect your device to your computer using USB. Your computer lists your device as a mass storage device.
  2. To flash the binary to your device, copy BUILD/<target>/<toolchain>/factory-configurator-client-example.hex from your computer to your device.
  3. To indicate the flash is in progress, your device's LED will blink rapidly. Once the LED stops blinking, the flash is complete.

3. Install Factory Configurator Utility (FCU)

We recommend installing FCU on an isolated virtual environment to avoid conflicts with any other Python packages installed on your computer.

For more detailed information, see the Installing FCU section.

  1. Log in to Device Management Portal for your region:

  2. Select Device identity > Factory.

  3. Click Download factory_configurator_utility.zip

  4. Extract FCU archive into a directory of your choice.

  5. Install FCU demo tool's requirements in your Python virtual environment.

    • In Windows, run:

      @REM Creating and activating virtual environment
      py -3 -m virtualenv factory_configurator_utility\fcu-venv
      factory_configurator_utility\fcu-venv\Scripts\activate
      
      @REM Installing FCU and demo tool requirements
      pip install fcu -f factory_configurator_utility\fcu
      pip install -r factory_configurator_utility\ft_demo\sources\requirements.txt --upgrade
      
    • In Linux, run:

      # Creating and activating virtual environment
      python3 -m virtualenv factory_configurator_utility/fcu-venv
      source factory_configurator_utility/fcu-venv/bin/activate
      
      # Installing FCU and demo tool requirements
      pip install fcu -f factory_configurator_utility/fcu
      pip install -r factory_configurator_utility/ft_demo/sources/requirements.txt --upgrade
      

4. Configure FCU

When you download FCU from Device Management Portal, you get a ZIP archive that contains the configuration file factory_configurator_utility/config/fcu.yml.

The following table describes the fields that you must populate in the fcu.yml configuration file to complete this tutorial.

For more information, see the Configuring FCU section.

Parameter Description Data type
certificate-authority:common-name Common name of the device certificate. You can set this to any value. String
update-auth-certificate-file Relative path to the Update authentication certificate you generated during the Generate update credentials step.
For example, ../my-update-certificate.der.
Path
vendor-id The Vendor ID you generated during the Generate Vendor and Class IDs step. UUID
class-id The Class ID you generated during the Generate Vendor and Class IDs step. UUID
manufacturer-name Manufacturer name String
device-type Device type String
model-number Model number String
hardware-version Hardware version String
memory-total Total memory size in kilobytes Integer

5. Set up the demo tool

To set up the demo tool, run:

cd factory_configurator_utility
python ft_demo/sources/ft_demo.py setup

6. Inject your credentials using the demo tool

  • To inject your credentials using an Ethernet interface, run:

    cd factory_configurator_utility
    python ft_demo/sources/ft_demo.py inject --endpoint-name=<endpoint name> --serial-number=<serial number> tcp --ip=<device IP> --port=<device port>
    

    Where:

    • <endpoint name> is the name that you want assign to the device. This value must be unique within the domain and will be displayed as the device's name in the portal.
    • <serial number> is used to generate the LwM2M device object. This value must be an integer.
    • <device IP> and <device port> are the device IP and port as it shows on the device's serial terminal.
  • To inject your credentials using a serial interface, run:

    cd factory_configurator_utility
    python ft_demo/sources/ft_demo.py inject --endpoint-name=<endpoint name> --serial-number=<serial number> serial --port=<device serial port>
    

    Where:

    • <endpoint name> is the name that you want assign to the device. This value must be unique within the domain and will be displayed as the device's name in the portal.
    • <serial number> is used to generate the LwM2M device object. This value must be an integer.
    • <device serial port> is the serial port your device is connected to.

Your device is now provisioned and ready to be set up for connection to Device Management Portal.