AIMLinux DeviceOn

From ESS-WIKI
Jump to: navigation, search

DeviceOn

This section describes the information about DeviceOn on RISC platform.

Requirements for Build Environment

To cross-compile DeviceOn agent, you have to install dependencies into SDK toolchain.

Please refer to packagegroup-wise-paas.bb and sdk.inc for details. These two files are used on Yocto to generate suitable image & toolchain for DeviceOn.

For Debian/Ubuntu, you can refer to mk-adv.sh which we use to build rootfs for RK platform.

Build Instruction

Make sure you have set up SDK toolchain environment, before start building RMM EI agent.

For RK platforms, you have to set up chroot environment instead of SDK toolchain.

# Get source
repo init -u https://gitlab.edgecenter.io/build-common_repo/ei-manifests.git -m wise-agent.xml  
repo sync -cdj 4

# Build
make clean
rm config.cache
cd build

# Choose one for your platform
./build-imx6.sh
./build-imx8.sh
./build-db410c.sh
./build-rk3399.sh
./build-rk3288.sh
./build-am335x.sh

After build process is complete, you can get the installer (.run) and tarball files in Wrapped/ folder.

$ ls Wrapped/
wise-agent-Poky_2.1.1 imx6-1.2.14.0-binary.tar.gz
wise-agent-Poky_2.1.1 imx6-1.2.14.0.run
wise-agent-Poky_2.1.1 imx6-1.2.14.0.run.tar.gz

In addition, you can check the output binaries in Release/AgentService/ folder as well.

Bundle Mechanism

To generate an eMMC hex binary which is a specific BSP official release with DeviceOn enabled, you can refer to the steps below.

DeviceOn Installation

1. Install RMM EI Agent

You can get the latest official release of RMM EI agent here.

\\eossfs\WISE-PaaS\WISE-PaaS2.0\Release

-OR-

\\essci\Product\WISE-Agent\RepoReleaseBuild

During the installation, do not configure at this moment.

* Setup Agent [y/n](default:n): y
* Do you want to configure RMM Agent now? [y/n](default: y) n
* Do you want to start RMM Agent now? [y/n](default: y) n

2. Install CreateAccount

Get CreateAccount program and install with npm.

export GIT_SSL_NO_VERIFY=1
git clone https://gitlab.edgecenter.io/ei-paas-rmm_repo/createaccount.git
cd createaccount/
npm install

After installation, copy all files into /usr/local/AgentService/ folder except agent_config.xml.

rm agent_config.xml
cp -a * /usr/local/AgentService/

3. Set up Zero-Config service

[System V]

vi  zero-config
cp ./zero-config /etc/init.d
chown root:root /etc/init.d/zero-config
chmod 0750 /etc/init.d/zero-config
update-rc.d -f zero-config remove
update-rc.d zero-config defaults 99 20

The content of zero-config:

#!/bin/sh

SERVICE_PATH="/usr/local/AgentService/"
SERVICE_PROGRAM="node index.js"

# Source function library.
. /etc/init.d/functions 

case "$1" in
    start)
        echo -n "Starting CreateAccount: "
        cd $SERVICE_PATH
        $SERVICE_PROGRAM > /dev/null 2>&1
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
            echo "OK"
        else
            echo "Failure"
        fi
        ;;
    *)
        echo "Usage: $0 {start}"
        exit 1
        ;;
esac

exit 0

[System D]

cp zero-config.service /etc/systemd/system
chown root:root /etc/systemd/system/zero-config.service
chmod 750 /etc/systemd/system/zero-config.service
systemctl enable zero-config.service

The content of zero-config.service:

[Unit]
Description=CreatAccount
After=saagent.service

[Service]
User=root
Group=root

Type=idle
WorkingDirectory=/usr/local/AgentService/
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/node /usr/local/AgentService/index.js

[Install]
WantedBy=multi-user.target

Configuration

  • Check if OTA & HDD handlers are enabled
$ cd /usr/local/AgentService
$ vi module/module_config.xml
<ModuleName1>HDDHandler</ModuleName1><ModulePath1>module/HDDHandler.so</ModulePath1><ModuleEnable1>TRUE</ModuleEnable1>
<ModuleName13>OTAHandler</ModuleName13><ModulePath13>module/OTAHandler.so</ModulePath13><ModuleEnable13>TRUE</ModuleEnable13>
  • Install Service-SDK
cp -a ${S}/Core/src/.libs/libEIServiceSDK.so* /usr/lib/
  • Install SUSI 4.0
cp -axr ${S}/Driver/ini/*.ini ${D}/usr/lib/Advantech/Susi/ini
cp -axr ${S}/Driver/lib*.* ${D}/usr/lib/
cp -axr ${S}/Susi4Demo/susidemo4 ${D}/usr/bin/

- OR -

cd SUSI4.x.x/Driver
sudo ./install.sh
  • Install SUSI-IoT
cp -ar ${S}/library/libSusiIoT.so* /usr/lib/
cp -ar ${S}/library/modules/libSUSIDrv.so /usr/lib/Advantech/iot/modules/
cp -ar ${S}/library/modules/libDiskInfo.so /usr/lib/Advantech/iot/modules/

- OR -

cd release/library
sudo ./install.sh

PS. Please make sure the owner of files above are 'root:root'.

  • After all, remove all installation files and clean history
rm /etc/boottimes 
rm /var/log/*
history -c
  • Finally, you can dump the eMMC hex binary.

PS. If the eMMC size is larger that 4GB, you may need to use exFat filesystem to store the dump binary.

First Boot

During the first boot procedure, the agent_config.xml will be updated by saagent service firstly. The MAC address is used as an unique device id for DeviceOn.

<DeviceName>imx6dlubc220a1</DeviceName>
<DevID>00000001-0000-0000-0000-00049F0130E0</DevID>
<SN>00049F0130E0</SN>
<UserName>00049F0130E0@advtrial.net</UserName>

Then, zero-config service will register this account to the server. Once successful, the agent_config.xml will be updated again with corresponding credentials.

<CredentialURL>https://deviceonapp.wise-paas.com/rmm/v1/iothub/credential</CredentialURL>
<IoTKey>10da34e72025c137618bb4d4aefff18d</IoTKey>

These procedures are automatically complete during first booting up. Users only need to power up device and connect with network.

Connect to Server

On PC or cellular phone, connect to DeviceQRCode website and input the MAC address of your target device.

If your target device has multiple Ethernet interfaces, use the following command to confirm the associated MAC.

$ cat /usr/local/AgentService/agent_config.xml | grep SN
   <SN>00049F0130E0</SN>

Follow the steps to connect to DeviceOn server

1. Click the button to generate QR code

2. Click the QR code or scan it with camera

deviceon_qrcode

The QR code will re-direct to DeviceOn home page. Enjoy it!

deviceon_home


If the DeviceQRCode website appear the mac address does not exist, the mac account may have expired (six month trial period) or you can check the <IoTKey> exist or not in the /usr/local/AgentService/agent_config.xml.

If the <IoTKey> is empty, please connect the internet and reboot the device again.

Deviceon_mac

Add New Project to DeviceOn

Wiseagent

1). Add build setting

Create build script

$ cd ${WISEAGENT}/build-env/
$ cp build-XXX.sh build-${PLATFORM}.sh

Edit build-${PLATFORM}.sh

Modify risc-env, the build-${PLATFORM}.sh will call it. Add new target for new solution in "if" clause, the TARGET=risc-"$ENV_VANDER"-"$ENV_PLAT"-"$ENV_OS"

If the project has no ENV_SCRIPT like i.MX does, please build it on rootfs via chroot.

2). Add build environment

Add a build script soft link

$ cd ${WISEAGENT}/build/
$ ln -s ../build-env/build-${PLATFORM}.sh build-${PLATFORM}.sh

Create a project folder on doc and script, folder name = "$RISC_TARGET"_"$OS_VERSION"

$ cd ${WISEAGENT}/build/doc/
$ cp risc_XXX $RISC_TARGET_$OS_VERSION -rf
$ cd ${WISEAGENT}/build/script/
$ cp risc_XXX $RISC_TARGET_$OS_VERSION -rf

Edit all files in that folder for new project.

SUSI

1). Add build setting

$ cd ${SourceCode}/

Modify risc-env and add new target for new solution in "if" clause, the TARGET=risc-"$ENV_VANDER"-"$ENV_PLAT"-"$ENV_OS"

2). Add board name - Add it on kernel (/proc/board) or file system (/etc/board)

BSP

https://github.com/ADVANTECH-Corp/linux-imx/commit/029e039fe76c4018f662dd3dad92d782d11ba436

Add device tree

    board {
        compatible = "proc-board";
        board-type = "EPC-R7200";
        board-cpu = "XAVIER-NX";
    };

File System

You can add /etc/board and fill board name directly

3). Add ${PROJECT}.ini file in ${SourceCode}/ini/

SUSIIoT

$ cd ${SUSIIoT}/

Modify risc-env and add new target for new solution in "if" clause, the TARGET=risc-"$ENV_VANDER"-"$ENV_PLAT"-"$ENV_OS"

Additional Modules

This section describes how to build & deploy additional plug-in for DeviceOn.

OTA Handler

SUSI 4.0 & SUSI-IoT

Service-SDK

OPC-UA

Modbus Handler

Supported Platforms

DeviceOn supports the following RISC platforms.

Platform OS Architecture SDK
NXP i.MX8 Yocto 2.5.2 aarch64 Link
NXP i.MX6 Yocto 2.1.1 armv7-a Link
Qualcomm APQ8016 Yocto 2.1.3 aarch64 Link
TI AM335x Yocto 2.4 armv7-a Link
RK3288 Debian 9.8 arm N/A
RK3399 Debian 9.9 aarch64 N/A