Quick start with Linux microPlatform (LmP)
This guide shows you how to get started with Pelion Edge and Linux microPlatform (LmP). LmP is a Yocto-built distribution maintained by Foundries.io. At the end of this tutorial, you will have built an LmP image that contains the Pelion Edge software that is ready to be deployed on NXP i.MX 8M Mini EVK or Avnet UltraZed-EG.
Prerequisites
Building the Pelion Edge image has been verified to work on Ubuntu 18.04 operating system.
-
Verify you comply with the Yocto build machine requirements.
-
Install the build requirements:
sudo apt-get install coreutils curl gawk wget git diffstat unzip \ texinfo g++ gcc-multilib build-essential chrpath socat cpio \ openjdk-11-jre python3 python3-pip python3-venv python3-pexpect xz-utils \ debianutils iputils-ping libsdl1.2-dev xterm libssl-dev libelf-dev \ android-sdk-ext4-utils ca-certificates whiptail
-
Set up the required building tools:
-
Install repo. You can install
repo
on Linux with this command:mkdir ~/bin && PATH=~/bin:$PATH && curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo
-
-
Check your default Python version:
python --version
If your default Python version is earlier than 3.6, you need to install a newer Python version.
-
Create a Python virtual environment for pelion-build, activate it, check Python version again and install Manifest tool v2.1.1:
python3 -m venv ~/pelion-venv source ~/pelion-venv/bin/activate python --version pip install wheel pip install manifest-tool==2.1.1
After you have activated the Python 3 virtual enviroment, a
python
command that startspython3
. -
Configure
user.name
anduser.email
because therepo
tool is built on top of Git:git config --global user.name "Mona Lisa" git config --global user.email "[email protected]"
-
Decide to build a Production (factory) or a Developer mode image:
- Production mode results in a build that only contains bootstrap credentials against the Pelion Cloud. This enables you to use the FCU/FCC process to pair the gateway to any Pelion Cloud account. Look at the PEP tool to learn about automating your factory floor in a production environment.
- Developer mode results in a build that automatically pairs to a specific Pelion Cloud account.
You can read more about Production or Developer mode on the configuring mbed-edge github page.
Developer mode prerequisites
-
Create a folder to store Pelion-specific configuration files:
mkdir ~/Pelion_Edge_Credentials cd ~/Pelion_Edge_Credentials
Note: You can reuse this folder in further tutorials, such as when using the Pelion Edge Provisioner. Store it in a safe location.
-
Create and download a developer certificate to allow the edge gateway to connect to your Pelion account:
- In the Pelion Device Management Portal, go to Device Identity > Certificates.
- Create a developer certificate.
- Download the certificate
mbed_cloud_dev_credentials.c
- Place this file into
~/Pelion_Edge_Credentials
.
-
Create the corresponding
update_default_resources.c
file to enable firmware updates to be applied to the gateway device:- In the Pelion Device Management Portal, go to Access Management > API keys.
- Create an API key and save it.
- Run following command
manifest-dev-tool init -a <api key>
- Copy the generated
update_default_resources.c
to ~/Pelion_Edge_Credentials For more information, please refer to the manifest tool README.
Note: To unlock the rich node features, such as gateway logs and the gateway terminal in the Pelion web Portal, pass the command-line parameter
--vendor-id 42fa7b48-1a65-43aa-890f-8c704daade54
to the manifest tool. Contact the service continuity team to request they enable Edge gateway features in your Pelion web Portal account. By default, the features are not enabled.
Build
-
Initialize a repository client:
-
Create an empty directory to hold the build directory:
mkdir ~/build cd ~/build
-
Download the Yocto manifest file in this repository:
repo init -u https://github.com/PelionIoT/manifest-lmp-pelion-edge.git -m pelion.xml
Note: If you use two-factor authentication, you need to generate a personal access token and use it as password.
Your directory now contains a
.repo
directory. -
-
Fetch all the repositories:
repo sync -j"$(nproc)"
-
Determine whether you're running in Production mode or Developer mode:
-
If running in Developer mode:
-
Ensure you followed the Developer mode prerequsites above.
-
Copy the
mbed_cloud_dev_credentials.c
andupdate_default_resources.c
to the edge-core recipe folder.cp ~/Pelion_Edge_Credentials/mbed_cloud_dev_credentials.c layers/meta-mbed-edge/recipes-connectivity/mbed-edge-core/files/ cp ~/Pelion_Edge_Credentials/update_default_resources.c layers/meta-mbed-edge/recipes-connectivity/mbed-edge-core/files/
-
Inform the build system about developer mode and update:
echo -e "\n" >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_DEVELOPER_MODE = "ON"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_FIRMWARE_UPDATE = "ON"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_FOTA_ENABLE = "ON"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_CURL_DYNAMIC_LINK = "ON"' >> .repo/manifests/conf/local.conf
-
-
If running in Production mode, inform the build system that this is not a developer mode build (which is the default):
echo -e "\n" >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_FACTORY_MODE = "ON"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_DEVELOPER_MODE = "OFF"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_BYOC_MODE = "OFF"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_FIRMWARE_UPDATE = "ON"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_FOTA_ENABLE = "ON"' >> .repo/manifests/conf/local.conf echo 'MBED_EDGE_CORE_CONFIG_CURL_DYNAMIC_LINK = "ON"' >> .repo/manifests/conf/local.conf
-
-
Set up the build environment variables:
-
For i.MX 8M Mini, run:
MACHINE=imx8mmevk source setup-environment
-
For Avnet UltraZed, run:
MACHINE=uz3eg-iocc source setup-environment
-
-
Start the build with
bitbake
:bitbake console-image-lmp
The built image is in the build directory under
deploy/images/<MACHINE_NAME>/
with a file nameconsole-image-lmp-<MACHINE_NAME>-<timestamp>.rootfs.wic
. -
Prepare the device for booting from the SD card
-
For i.MX 8M Mini, check the positions of the boot switches. You can see the required positions of the switches printed on the silkscreen of the PCB.
-
For Avnet UltraZed, check the position of the boot switches. You can find the required positions of the switches from the user guide of your board.
-
-
Flash the image
console-image-lmp-<MACHINE_NAME>-<timestamp>.rootfs.wic.gz
to an SD card:-
macOS:
-
Be sure to verify your device's path. This example assumes the SD card is enumerated as
/dev/diskX
. -
Make sure the SD card drive and its partitions, if any, are unmounted. To unmount all partitions, run the following command:
ls /dev/diskX?* | xargs -n1 diskutil umount
-
Use
dd
:$ gunzip -c console-image-lmp-<MACHINE_NAME>-<timestamp>.rootfs.wic.gz | sudo dd bs=4m of=/dev/diskX conv=sync
Alternatively, you can use the Etcher app, which can result in significant time savings over using
dd
:- Choose the file to flash.
- Choose the destination SD card.
- Click Flash.
-
-
Linux:
-
Make sure the SD card drive and its partitions, if any, are unmounted. You can use
lsblk
to find the name of your SD card block device. To unmount all partitions, run:ls /dev/mmcblkX?* | xargs -n1 umount -l
-
Use
dd
:$ gunzip -c console-image-lmp-<MACHINE_NAME>-<timestamp>.rootfs.wic.gz | sudo dd bs=4M of=/dev/mmcblkX conv=fsync status=progress iflag=fullblock oflag=direct
-
-
Flash the i.MX 8M Mini eMMC
If you are using the i.MX 8M Mini, you must flash the device with the built image. This writes the internal boot tools to the device. You only need to do this once:
-
Navigate to the root of your work directory (one folder above the build-folder).
-
Build the mfgtool-files for flashing:
DISTRO=lmp-mfgtool MACHINE=imx8mmevk source setup-environment build-mfgtool bitbake mfgtool-files
-
Copy the earlier built image to the new build directory:
cp ../build-lmp/deploy/images/imx8mmevk/console-image-lmp-imx8mmevk.wic deploy/images/imx8mmevk/
-
Navigate to the mfgtools-directory, and change the flashed image name in the
full_image.uuu
file:cd deploy/images/imx8mmevk/mfgtool-files sed -i 's/lmp-base-console-image-imx8mmevk.wic/console-image-lmp-imx8mmevk.wic/' full_image.uuu # Ensure that the new image name was written grep "console-image-lmp-imx8mmevk.wic" full_image.uuu
-
Set your i.MX 8M Mini EVK board to a download mode, and turn it on. Please consult your user guide on how to do this.
-
Flash the eMMC of the board using
uuu
:sudo ./uuu full_image.uuu
-
Set your i.MX 8M Mini EVK back to the SD card boot mode.
Running Pelion Edge
After preparing the SD card (and flashing the device in the case of i.MX 8M Mini EVK), you are ready to run Pelion Edge:
-
Insert the prepared SD card.
-
Power on the device.
-
Use the serial connection of your board to communicate with the device. Please consult the user's guide of your board on how to do this.
-
Modify the login credentials:
The default login user for the system is
fio
. The default password is set tofio
. The user has sudo-permissions. To modify the default password, use thepasswd
command after login.
Troubleshooting
Please see the meta-pelion-edge GitHub issues for solutions to common build errors.