WebServer on linkin smart 7688

Linkit Smart7688的使用方式可先參照這篇

要能夠將C/C++的code放在linkitsmart上有兩種方法:

法一   cross compiling

https://labs.mediatek.com/site/global/developer_tools/mediatek_linkit_smart_7688/training_docs/c_programming/cross_compiling/index.gsp

法二    eclipse

https://labs.mediatek.com/site/global/developer_tools/mediatek_linkit_smart_7688/training_docs/c_programming/cross_compilation_eclipse/index.gsp

Using OpenWrt SDK to Build C/C++ Programs

要能夠讓Linkit Smart 7688執行C/C++的程式需要透過cross compiling , 不過有提供了相對應的SDK 讓整個過程變得很簡單

Using OpenWrt SDK to Build C/C++ Programs

HelloWorld.c

Steps

First, download the SDK zip file fromhttp://labs.mediatek.com/site/global/developer_tools/mediatek_linkit_smart_7688/sdt_intro/index.gsp.

Unzip the package The name is quite long and we’ll use SDK to denote its name.

`$sudo tar -xvjf SDK.tar.bz2`

*

Note that sudo is mandatory – without it the file won’t properly unpacked.

*

Download and unzip the example package file.

Copy the example helloworld directory to SDK/package folder. The folder structure should look like this:

In the SDK directory, type make package/helloworld/compile to build the package. Once it is built:

Simple Server

先寫一隻簡單的server測試一下(port 9999)

再來是模仿helloworld建立目錄結構

其中server/Makefile與server/src/Makefile需要修改

想看改了什麼可以參考:https://github.com/SwimGlass/OpenwrtSDK

最後都編譯完成之後我拿到了兩個檔案helloworld_1.0.0-1_ramips_24kec.ipk , server_1.0.0-1_ramips_24kec.ipk

再來將檔案放到linkit smart裡面

執行opkg install helloworld_1.0.0-1_ramips_24kec.ipk與opkg install server_1.0.0-1_ramips_24kec.ipk

安裝畫面

執行

網頁收到的資料

確認Linkit Smart上可執行簡單的web server後,下面就正式測試 Server framework

Server framework on LinkitSmart7688

TODO

Tools

利用MTK提供的OpenWrt-Toolchain

在bin目錄下有mipsel-openwrt-linux的gcc

修改server framework Makefile

將CC改為mipsel-openwrt-linux-gcc

編譯後會出現error且有一些warning,查詢後在Cflags補上-ldl參數(#libdl is the dynamic linking library)

且修改Cross Compile環境,就可排除warning(OpenWrt Cross Compile)

`$export STAGING_DIR=~/OpenWrt-Toolchain-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2`

`$make`後,利用`$file`看binary file的type

將server-framework用scp複製進linkitsmart的家目錄

`$sudo scp -r server-framework/ root@mylinkit.local:~`

Linkit Smart7688上測試原有的Server framework功能

測試`./test-async`

下`$ifconig`查Linkitsmart 得ip:http://192.168.1.42/

測試test-reator

測試網頁伺服器的效能in LinkitSmart7688

`$ab -c 32 -n 100 http://192.168.1.42:8080/`

對照彙整Server-framework行為與改進方式,改善效能前的測試linkit Smart上Requests per second已經慢了約10秒

Apache Benchmark

Debug with GDB

在LinkitSmart7688上使用gdb server

即可使用gdb