Difference between revisions of "AIMLinux/AddOn/DeviceOn"

From ESS-WIKI
Jump to: navigation, search
 
(14 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
*'''SUSI-IoT'''
 
*'''SUSI-IoT'''
 
**EX: SusiIoT_Release_2021_08_31_Poky_3.0.4-imx8_x64_16490.tar.gz
 
**EX: SusiIoT_Release_2021_08_31_Poky_3.0.4-imx8_x64_16490.tar.gz
*'''SUSI'''
+
*'''SUSI 4.0'''
 
**EX: SUSI4.0_Release_2021_10_29_Poky_3.0.4-imx8_x64_16557.tar.gz
 
**EX: SUSI4.0_Release_2021_10_29_Poky_3.0.4-imx8_x64_16557.tar.gz
  
 
== <span style="color:#0070c0">Bundle Mechanism</span> ==
 
== <span style="color:#0070c0">Bundle Mechanism</span> ==
  
To generate an eMMC hex binary which is a specific BSP official release with DeviceOn enabled, you can refer to the steps below.
+
Install the DeviceOn function on a specific BSP official release with related DeviceOn packages enabled.
  
=== <span style="color:#0070c0">DeviceOn Installation</span> ===
+
== <span style="color:#0070c0">DeviceOn Installation</span> ==
  
'''1. Install&nbsp;WISE-Agent'''
+
=== '''1. Install&nbsp;WISE-Agent''' ===
  
 
  ./wise-agent-Poky_xxx.run
 
  ./wise-agent-Poky_xxx.run
Line 32: Line 32:
 
  * Do you want to start RMM Agent now? [y/n](default: y) '''<span style="color:#DD0000">n</span>'''
 
  * Do you want to start RMM Agent now? [y/n](default: y) '''<span style="color:#DD0000">n</span>'''
  
'''2. Install CreateAccount'''
+
=== '''2. Install CreateAccount''' ===
  
 
Get CreateAccount program and install with npm.
 
Get CreateAccount program and install with npm.
Line 40: Line 40:
 
  cp -a * /usr/local/AgentService/
 
  cp -a * /usr/local/AgentService/
  
'''3. Set up Zero-Config service'''
+
=== '''3. Set up Zero-Config service''' ===
  
'''[System V]'''
+
==== '''[System V]''' ====
  
vi  zero-config
+
Create the "zero-config" file, and the&nbsp;content of 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
 
  #!/bin/sh
Line 81: Line 74:
 
  exit 0
 
  exit 0
  
'''[System D]'''
+
Set up the zero-config file:
 +
 
 +
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
  
cp zero-config.service /etc/systemd/system
+
==== '''[System D]''' ====
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:
+
Create the "zero-config.service" file, and the&nbsp;content of zero-config.service:
  
 
  [Unit]
 
  [Unit]
Line 106: Line 102:
 
  WantedBy=multi-user.target
 
  WantedBy=multi-user.target
  
=== <span style="color:#0070c0">Configuration</span> ===
+
Set up the zero-config.service file:
  
*Check if OTA & HDD handlers are enabled
+
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
  
$ cd /usr/local/AgentService
+
=== '''4.&nbsp;Install Service-SDK''' ===
$ vi module/module_config.xml
 
<ModuleName1>HDDHandler</ModuleName1><ModulePath1>module/HDDHandler.so</ModulePath1><ModuleEnable1>'''<span style="color:#DD0000">TRUE</span>'''</ModuleEnable1>
 
<ModuleName13>OTAHandler</ModuleName13><ModulePath13>module/OTAHandler.so</ModulePath13><ModuleEnable13>'''<span style="color:#DD0000">TRUE</span>'''</ModuleEnable13>
 
  
*Install Service-SDK
+
tar -zxvf Service-SDK_Release_xxx.tar.gz
 +
cp -a Service-SDK/.libs/libEIServiceSDK.so* /usr/lib/
  
cp -a ${S}/Core/src/.libs/libEIServiceSDK.so* /usr/lib/
+
=== '''5.&nbsp;Install&nbsp;SUSI-IoT''' ===
  
*Install SUSI 4.0
+
  tar -zxvf SusiIoT_Release_xxx.tar.gz
 
+
  cd release/library
  cp -axr ${S}/Driver/ini/*.ini ${D}/usr/lib/Advantech/Susi/ini
+
  sudo ./install.sh
  cp -axr ${S}/Driver/lib*.* ${D}/usr/lib/
 
  cp -axr ${S}/Susi4Demo/susidemo4 ${D}/usr/bin/
 
  
- OR -
+
=== '''6. Install&nbsp;SUSI 4.0''' ===
  
 +
tar -zxvf SUSI4.0_Release_xxx.tar.gz
 
  cd SUSI4.x.x/Driver
 
  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
 
  sudo ./install.sh
  
 
''PS. Please make sure the owner of files above are ''''root:root''''.''
 
''PS. Please make sure the owner of files above are ''''root:root''''.''
  
*After all, <span style="color:#FF0000;">remove all installation files</span> and clean history
+
== <span style="color:#0070c0">First Boot</span> ==
  
rm /etc/boottimes
+
Connect the internet and during the first boot procedure, the /usr/local/AgentService/agent_config.xml will be updated by saagent service firstly. The MAC address is used as an unique device id for DeviceOn.
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.''
 
 
 
=== <span style="color:#0070c0">First Boot</span> ===
 
 
 
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>
 
  <DeviceName>imx6dlubc220a1</DeviceName>
Line 194: Line 169:
 
If the '''[https://deviceonapp.wise-paas.com/#/DeviceQRCode DeviceQRCode]''' website appear the mac address does not exist, the&nbsp;mac account may have expired (six month trial period) or&nbsp;'''you&nbsp;can check the &lt;IoTKey&gt; exist or not in the /usr/local/AgentService/agent_config.xml'''.
 
If the '''[https://deviceonapp.wise-paas.com/#/DeviceQRCode DeviceQRCode]''' website appear the mac address does not exist, the&nbsp;mac account may have expired (six month trial period) or&nbsp;'''you&nbsp;can check the &lt;IoTKey&gt; exist or not in the /usr/local/AgentService/agent_config.xml'''.
  
'''If the&nbsp;&lt;IoTKey&gt; is empty, please connect the internet and reboot the device agai'''n.
+
'''''If the&nbsp;&lt;IoTKey&gt; is empty, please connect the internet and reboot the device agai''n'''.
  
 
[[File:Deviceon mac.png|800px|Deviceon_mac]]
 
[[File:Deviceon mac.png|800px|Deviceon_mac]]
  
== <span style="color:#0070c0">Add New Project to DeviceOn</span> ==
+
== <span style="color:#0070c0">DeviceOn logs and check the connection</span> ==
 
+
You can go to the /usr/local/AgentService/logs and check the log file:
=== <span style="color:#0070c0">Wiseagent</span> ===
 
 
 
1). Add build setting
 
 
 
Create build script
 
<pre>$ cd ${WISEAGENT}/build-env/</pre>
 
<pre>$ cp build-XXX.sh build-${PLATFORM}.sh</pre>
 
 
 
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"'''
 
 
 
<span style="color:#ee0000">If the project has no ENV_SCRIPT like i.MX does, please build it on rootfs via chroot.</span>
 
 
 
2). Add build environment
 
 
 
Add a build script soft link
 
<pre>$ cd ${WISEAGENT}/build/
 
$ ln -s ../build-env/build-${PLATFORM}.sh build-${PLATFORM}.sh</pre>
 
 
 
Create a project folder on doc and script, folder name = '''"$RISC_TARGET"_"$OS_VERSION"'''
 
<pre>$ cd ${WISEAGENT}/build/doc/
 
$ cp risc_XXX $RISC_TARGET_$OS_VERSION -rf
 
$ cd ${WISEAGENT}/build/script/
 
$ cp risc_XXX $RISC_TARGET_$OS_VERSION -rf
 
</pre>
 
 
 
Edit all files in that folder for new project.
 
 
 
=== <span style="color:#0070c0">SUSI</span> ===
 
 
 
1). Add build setting
 
<pre>$ cd ${SourceCode}/</pre>
 
 
 
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 https://github.com/ADVANTECH-Corp/linux-imx/commit/029e039fe76c4018f662dd3dad92d782d11ba436]
 
 
 
Add device tree
 
<pre>    board {
 
        compatible = "proc-board";
 
        board-type = "EPC-R7200";
 
        board-cpu = "XAVIER-NX";
 
    };</pre>
 
 
 
File System
 
 
 
You can add /etc/board and fill board name directly
 
 
 
3). Add ${PROJECT}.ini file in&nbsp;${SourceCode}/ini/
 
 
 
=== <span style="color:#0070c0">SUSIIoT</span> ===
 
<pre>$ cd ${SUSIIoT}/</pre>
 
 
 
Modify '''risc-env''' and add new target for new solution in "if" clause, the '''TARGET=risc-"$ENV_VANDER"-"$ENV_PLAT"-"$ENV_OS"'''
 
<div id="gtx-trans" style="position: absolute; left: 405px; top: 397.385px;"><div class="gtx-trans-icon"></div></div>
 
= <span style="color:#0070c0">Additional Modules</span> =
 
 
 
This section describes how to build & deploy additional plug-in for DeviceOn.
 
 
 
== <span style="color:#0070c0">OTA Handler</span> ==
 
 
 
== <span style="color:#0070c0">SUSI 4.0 & SUSI-IoT</span> ==
 
 
 
== <span style="color:#0070c0">Service-SDK</span> ==
 
 
 
== <span style="color:#0070c0">OPC-UA</span> ==
 
 
 
== <span style="color:#0070c0">Modbus Handler</span> ==
 
 
 
= <span style="color:#0070c0">Supported Platforms</span> =
 
 
 
DeviceOn supports the following RISC platforms.
 
  
{| class="wikitable" style="text-align: center; width: 800px;"
+
04-01 07:35:11.306 1687 [WiseAgent] Agent Credential: mqtt,efcc749121b5ecd182f58aa1649457eb_created,2265409aaecb11bf79a7c16473af5c47,deviceonapp.wise-paas.com,1883,false
|-
+
04-01 07:35:11.306 1687 [WiseAgent] Connecting to broker: deviceonapp.wise-paas.com
! Platform
+
04-01 07:35:11.389 1740 [WiseAgent] Broker connected!
! OS
 
! Architecture
 
! SDK
 
|-
 
| NXP i.MX8
 
| Yocto 2.5.2
 
| aarch64
 
| [http://ess-wiki.advantech.com.tw/view/IoTGateway/BSP/Linux/iMX8/Yocto_LBV9_User_Guide#Setting_up_SDK Link]
 
|-
 
| NXP i.MX6
 
| Yocto 2.1.1
 
| armv7-a
 
| [http://ess-wiki.advantech.com.tw/view/IoTGateway/BSP/Linux/iMX6/Yocto_LBV8_User_Guide#Setting_up_SDK Link]
 
|-
 
| Qualcomm APQ8016
 
| Yocto 2.1.3
 
| aarch64
 
| [http://ess-wiki.advantech.com.tw/view/IoTGateway/BSP/Linux/APQ8016/BSP_User_Guide_V1#Set_Up_SDK Link]
 
|-
 
| TI AM335x
 
| Yocto 2.4
 
| armv7-a
 
| [http://ess-wiki.advantech.com.tw/view/Yocto_Linux_BSP_Ver.4_User_Guide_for_AM57xx/AM335x_series#Set_up_Build_Environment Link]
 
|-
 
| RK3288
 
| Debian 9.8
 
| arm
 
| N/A
 
|-
 
| RK3399
 
| Debian 9.9
 
| aarch64
 
| N/A
 
|}
 

Latest revision as of 10:21, 1 April 2022

DeviceOn

This section describes the information about How to install the DeviceOn on RISC platform.

Get the following required files from PM or AE members 

  • WISE-Agent
    • EX: wise-agent-Poky_3.0.4-imx8-1.4.31.0.run
  • CreateAccount
    • EX: createaccount_2020_04_10_a59cbe72.tar.gz
  • Service-SDK
    • EX: Service-SDK_Release_20200421_fsl_imx8_yocto_3f5ea785.tar.gz
  • SUSI-IoT
    • EX: SusiIoT_Release_2021_08_31_Poky_3.0.4-imx8_x64_16490.tar.gz
  • SUSI 4.0
    • EX: SUSI4.0_Release_2021_10_29_Poky_3.0.4-imx8_x64_16557.tar.gz

Bundle Mechanism

Install the DeviceOn function on a specific BSP official release with related DeviceOn packages enabled.

DeviceOn Installation

1. Install WISE-Agent

./wise-agent-Poky_xxx.run

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.

​tar -zxvf createaccount_xxx.tar.gz
cd createaccount
cp -a * /usr/local/AgentService/

3. Set up Zero-Config service

[System V]

Create the "zero-config" file, and 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

Set up the zero-config file:

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

[System D]

Create the "zero-config.service" file, and 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

Set up the zero-config.service file:

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

4. Install Service-SDK

tar -zxvf Service-SDK_Release_xxx.tar.gz
cp -a Service-SDK/.libs/libEIServiceSDK.so* /usr/lib/

5. Install SUSI-IoT

tar -zxvf SusiIoT_Release_xxx.tar.gz
cd release/library
sudo ./install.sh

6. Install SUSI 4.0

tar -zxvf SUSI4.0_Release_xxx.tar.gz
cd SUSI4.x.x/Driver
sudo ./install.sh

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

First Boot

Connect the internet and during the first boot procedure, the /usr/local/AgentService/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

DeviceOn logs and check the connection

You can go to the /usr/local/AgentService/logs and check the log file:

04-01 07:35:11.306 1687 [WiseAgent] Agent Credential: mqtt,efcc749121b5ecd182f58aa1649457eb_created,2265409aaecb11bf79a7c16473af5c47,deviceonapp.wise-paas.com,1883,false
04-01 07:35:11.306 1687 [WiseAgent] Connecting to broker: deviceonapp.wise-paas.com
04-01 07:35:11.389 1740 [WiseAgent] Broker connected!