Difference between revisions of "WISE-3610 LoRa Gateway"

From ESS-WIKI
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 33: Line 33:
 
== Add static route and DNS server on LoRa Gateway ==
 
== Add static route and DNS server on LoRa Gateway ==
 
<pre>route del default
 
<pre>route del default
route add -net 0.0.0.0 gw 172.22.15.130 netmask 0.0.0.0 dev br-lan
+
route add -net 0.0.0.0 gw 172.22.15.130 netmask 0.0.0.0 dev eth0
 
route add -net 172.16.0.0 gw 172.22.15.254 netmask 255.240.0.0 dev br-lan
 
route add -net 172.16.0.0 gw 172.22.15.254 netmask 255.240.0.0 dev br-lan
 
echo "nameserver 8.8.8.8" >> /etc/resolv.conf</pre>
 
echo "nameserver 8.8.8.8" >> /etc/resolv.conf</pre>
 
 
  
 
== mbed-client sample with mosquitto library ==
 
== mbed-client sample with mosquitto library ==
Line 248: Line 246:
 
location
 
location
  
/node-4.7.3/out/Release/node   ~ 16 MB</pre>
+
~/Work/LoRa/Docker/build_env/nodejs/node-4.7.3/out/Release/node ~ 16 MB
 +
</pre>
 +
 
 +
= Build code =
 +
 
 +
Environment
 +
<pre>export STAGING_DIR=/home/adv/work/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi
 +
export CROSS_COMPILE=$STAGING_DIR/bin/arm-openwrt-linux-
 +
export CC=${CROSS_COMPILE}gcc
 +
export CXX=${CROSS_COMPILE}g++
 +
export AR=${CROSS_COMPILE}ar
 +
export LD=${CROSS_COMPILE}ld
 +
export GDB=${CROSS_COMPILE}gdb
 +
export STRIP=${CROSS_COMPILE}strip
 +
export RANLIB=${CROSS_COMPILE}ranlib
 +
export OBJCOPY=${CROSS_COMPILE}objcopy
 +
export OBJDUMP=${CROSS_COMPILE}objdump
 +
export NM=${CROSS_COMPILE}nm
 +
export CPPCFLAGS=-I$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/include
 +
export CFLAGS=-I$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/include
 +
export LDCFLAGS=-L$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/lib
 +
export LDFLAGS=-L$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/lib
 +
export PATH=$PATH:$STAGIN_DIR/bin</pre>
  
 +
== Build sample: WAPI&nbsp; ==
 +
<pre>svn co https://172.20.2.44/svn/essrisc/IoT/source/Projects/WISE_IOT_SW_Solution/WAPI
  
 +
update libwebsockets to 2.1.0 -> /qsdk/package/libs/libwebsockets/Makefile
 +
 +
PKG_VERSION:=2.1.0
 +
 +
make package/libwebsocket/clean package/libwebsocket/prepare package/libwebsocket/compile V=s -j 8
 +
 +
source wise-3610-toolchain-env
 +
 +
./configure --host=arm-openwrt-linux
 +
 +
sample -> cd sample -> modify Makefile to mark CC/CPP/AR
 +
 +
make</pre>
  
 
= Future Work =
 
= Future Work =
  
 
&nbsp; &nbsp;A sample code to get LoRa data from mqtt-bus.
 
&nbsp; &nbsp;A sample code to get LoRa data from mqtt-bus.

Latest revision as of 07:14, 27 October 2017

ADF Demo 

How to build mbed client sample and copy to target board

sudo docker exec -it lora bash

cd /home/adv/work/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137

export ARMGCC_DIR=`pwd`/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/

cd qsdk/

make package/mbed/clean package/mbed/prepare package/mbed/compile V=s -j 8

scp eric@172.22.12.213:/home/eric/Work/LoRa/Docker/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/build_dir/target-arm_cortex-a7_uClibc-0.9.33.2_eabi/mbed/mbed-cloud-client-1.1-Linux-example-master/mbed-cloud-client-example-ref/Debug/mbedCloudClientExample.elf .


Ubuntu 16.04 x64 Docker Image ( for building LoRa SDK )

Copy OpenWRT BSP SDK ( WISE-3610_SDK_20170405_0f7f137.tar.bz2 ) in your Linux host

tar jxvf WISE-3610_SDK_20170405_0f7f137.tar.bz2

cd ./WISE-3610_SDK_20170405_0f7f137/

sudo docker run -it --name lora_sdk -v $PWD:/home/adv/work/ advwiseec/lorasdk_openwrt

cd /home/adv/work

export ARMGCC_DIR=`pwd`/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/

make -j 8

Add static route and DNS server on LoRa Gateway

route del default
route add -net 0.0.0.0 gw 172.22.15.130 netmask 0.0.0.0 dev eth0
route add -net 172.16.0.0 gw 172.22.15.254 netmask 255.240.0.0 dev br-lan
echo "nameserver 8.8.8.8" >> /etc/resolv.conf

mbed-client sample with mosquitto library

Add link library of LoRaSDK\WISE-3610_SDK_20170405_0f7f137\qsdk\package\network\utils\mbed\mbed-cloud-client-1.1-Linux-example-master\mbed-cloud-client-example-ref\CMakeLists.txt

target_link_libraries (${TEST_LIB}.elf  ${SRC_LIBS})

target_link_libraries (${TEST_LIB}.elf  mosquitto)

Add depends of V:\Work\LoRa\Docker\build_env\LoRaSDK\WISE-3610_SDK_20170405_0f7f137\qsdk\package\network\utils\mbed\Makefile

DEPENDS += +libpthread +libstdcpp +librt +libmosquitto


How to modify mbed-client source code and build

unzip mbed-cloud-client-1.1-Linux-example-master.zip

modify

\LoRaSDK\WISE-3610_SDK_20170405_0f7f137\qsdk\package\network\utils\mbed\mbed-cloud-client-1.1-Linux-example-master\mbed-cloud-client-example-ref\mbed-cloud-client-example\main.cpp

zip mbed-cloud-client-1.1-Linux-example-master.zip ./mbed-cloud-client-1.1-Linux-example-master

cd qsdk/

make package/mbed/clean package/mbed/prepare package/mbed/compile V=s -j 8


Enable all log with mbed-client example

 add_definitions(-DMBED_CONF_MBED_TRACE_ENABLE=1)  in define.txt


Change TCP / UDP Transport Protocol

mbed_cloud_client_user_config.h

MBED_CLOUD_CLIENT_TRANSPORT_MODE_TCP

MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP

Setup the build environment  mbed-client with Ubuntu 16.04 Dokcer container

docker run -it --name x86_mbed-client -v $PWD:/home/adv/work:rw advwiseec/lorasdk_openwrt bash

sudo apt-get install cmake

sudo apt-get install libmosquitto-dev

tar xvf mbed-cloud-client-1.1-with-lora-ga-mqtt.tar .

cd mbed-cloud-client-1.1-Linux-example-master/mbed-cloud-client-example-ref/mbed-cloud-client-example/

sudo cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DEXTARNAL_DEFINE_FILE=define.txt

make -j 8

How to build mbed-client on x86 Ubuntu 16.04

depend on: cmake 3.5.1   python 2.7.12

unzip mbed-cloud-client-1.1-Linux-example-master.zip

Modify define.txt & autogen.cmake to meet your environment

Replace files which are in Patch folder
    define.txt                    to mbed-cloud-client-1.1-Linux-example/mbed-cloud-client-example-ref/
    autogen.cmake                to mbed-cloud-client-1.1-Linux-example/mbed-cloud-client-example-ref/pal-platform          => x86 do not replace
    identity_dev_security.c        to mbed-cloud-client-1.1-Linux-example/mbed-cloud-client-example-ref/mbed-cloud-client-example

Generate makefiles

   cd  mbed-cloud-client-1.1-Linux-example/mbed-cloud-client-example-ref/)
    cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug -DEXTARNAL_DEFINE_FILE=define.txt

Build

   make

Execute 'mbedCloudClientExample.elf' application in ./Debug or ./Release  


For ARM Debug mbed-client Note

Set up the Build mbed-client environment for WISE-3610 LoRa GW

Copy OpenWRT BSP SDK ( WISE-3610_SDK_20170405_0f7f137.tar.bz2 ) in your Linux host

tar jxvf WISE-3610_SDK_20170405_0f7f137.tar.bz2

cd ./WISE-3610_SDK_20170405_0f7f137/

docker run -it --name WISE-3610-SDK -v $PWD:/home/adv/work/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137 advwiseec/lorasdk_openwrt bash

cd /home/adv/work/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/

export ARMGCC_DIR=`pwd`/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/

cd /home/adv/work/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/

make package/mbed/clean package/mbed/prepare package/mbed/compile V=s -j 8

How to copy mbed-client program and run on WISE-3610

# Login by SSH: 
Account: root
Password: advantech

# Copy 
scp eric@xxx.xxx.xxx:/Your Project Folder/WISE-3610_SDK_20170405_0f7f137/qsdk/build_dir/target-arm_cortex-a7_uClibc-0.9.33.2_eabi/mbed/mbed-cloud-client-1.1-Linux-example-master/mbed-cloud-client-example-ref/Debug/mbedCloudClientExample.elf .

# launch
./mbedCloudClientExample.elf 

How to modify mbed-client source code

# Source code at 

/home/adv/work/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/package/network/utils/mbed/mbed-cloud-client-1.1-Linux-example-master

# To modify your code and build

cd /home/adv/work/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/package/network/utils/mbed

zip -r mbed-cloud-client-1.1-Linux-example-master.zip ./mbed-cloud-client-1.1-Linux-example-master/*

cd /home/adv/work/build_env/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/

make package/mbed/clean package/mbed/prepare package/mbed/compile V=s -j 8


mbed-cloud workshop

* Step 1: Login to build Server
ssh server: 172.22.12.213
id: adv
password: adv

* Step 2: Entry to docker container
#sudo docker exec -it mbed_workshop bash
#cd work

* Step 3: export environment variable
#export TOOLCHAIN_DIR=`pwd`/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/
#cd qsdk
#make menuconfig
Network -> <*>mbed

* Step 4: To build mbed-cloud-client-example
#make package/mbed/clean package/mbed/prepare package/mbed/compile V=s -j 8

#Step 5. Login to WISE-3610 target
ssh login to your WISE-3610 GW 192.168.0.1  ID/Password: root/advantech

* Step 6. Copy mbedCloudClient prgram to WISE-3610​
#scp adv@172.22.12.213:/home/eric/Work/LoRa/Docker/build_env/LoRaSDK/mbed/WISE-3610_SDK_20170405_0f7f137/qsdk/build_dir/target-arm_cortex-a7_uClibc-0.9.33.2_eabi/mbed/mbed-cloud-client-example-restricted/__ARM_OpenWRT_mbedtls/Debug/mbedCloudClientExample.elf .

WISE-3610 Tool-Chain

sudo docker exec -it lora_toolchain_for_will bash cd /home/adv/work/wise_snail_agent_0314ToECG/ make copy wise_snail_agent to WISE-3610 Target and exec it



How to setup a LoRa toolchain environment

docker run -it --name lora_sdk -v $PWD:/home/adv/work/ advwiseec/lorasdk_openwrt bash

copy the toolchain to /opt/
\\eossfs\share\@Eric\LoRa\toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi_with_wisesnail.tar.gz
tar zxvf toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi_with_wisesnail.tar.gz

copy wisesnail sample code to your working folder ( example: /home/adv/working/snail/ )

\\eossfs\share\@Eric\LoRa\wise_snail_agent_0314ToECG.ok.tar.bz2 

bzip2 -d wise_snail_agent_0314ToECG.ok.tar.bz2 

cd to project folder

make

WISE-3610 For GSMART ESL Project

AdvanWISE

  1. Build SOP:  Origin OpenWRT BSP ( version ? ) + AdvanWise's patches  =>  AdvanWISE releases BSP for WISE-3610

Build NodeJS for WISE-3610

node-4.7.3

export AR=/opt/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-ar
export CC=/opt/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-gcc
export CXX=/opt/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-g++
export LINK=/opt/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-g++
export RANLIB=/opt/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-ranlib
export STAGING_DIR=/route/to/openwrt/folder/staging_dir
export LIBPATH=/opt/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/lib
export LDFLAGS='-Wl,-rpath-link '${LIBPATH}
OR 
export AR=/home/adv/work/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-ar
export CC=/home/adv/work/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-gcc
export CXX=/home/adv/work/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-g++
export LINK=/home/adv/work/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-g++
export RANLIB=/home/adv/work/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/bin/arm-openwrt-linux-ranlib
export STAGING_DIR=/home/adv/work/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/staging_dir
export LIBPATH=/home/adv/work/LoRaSDK/WISE-3610_SDK_20170405_0f7f137/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi/lib
export LDFLAGS='-Wl,-rpath-link '${LIBPATH}

./configure --without-snapshot --without-npm --without-intl --without-inspector --without-ssl --dest-cpu=arm

make

location

~/Work/LoRa/Docker/build_env/nodejs/node-4.7.3/out/Release/node  ~ 16 MB

Build code

Environment

export STAGING_DIR=/home/adv/work/qsdk/staging_dir/toolchain-arm_cortex-a7_gcc-4.8-linaro_uClibc-0.9.33.2_eabi
export CROSS_COMPILE=$STAGING_DIR/bin/arm-openwrt-linux-
export CC=${CROSS_COMPILE}gcc
export CXX=${CROSS_COMPILE}g++
export AR=${CROSS_COMPILE}ar
export LD=${CROSS_COMPILE}ld
export GDB=${CROSS_COMPILE}gdb
export STRIP=${CROSS_COMPILE}strip
export RANLIB=${CROSS_COMPILE}ranlib
export OBJCOPY=${CROSS_COMPILE}objcopy
export OBJDUMP=${CROSS_COMPILE}objdump
export NM=${CROSS_COMPILE}nm
export CPPCFLAGS=-I$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/include
export CFLAGS=-I$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/include
export LDCFLAGS=-L$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/lib
export LDFLAGS=-L$STAGING_DIR/../target-arm_cortex-a7_uClibc-0.9.33.2_eabi/usr/lib
export PATH=$PATH:$STAGIN_DIR/bin

Build sample: WAPI 

svn co https://172.20.2.44/svn/essrisc/IoT/source/Projects/WISE_IOT_SW_Solution/WAPI

update libwebsockets to 2.1.0 -> /qsdk/package/libs/libwebsockets/Makefile

PKG_VERSION:=2.1.0

make package/libwebsocket/clean package/libwebsocket/prepare package/libwebsocket/compile V=s -j 8

source wise-3610-toolchain-env

./configure --host=arm-openwrt-linux

sample -> cd sample -> modify Makefile to mark CC/CPP/AR

make

Future Work

   A sample code to get LoRa data from mqtt-bus.