Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Mihini/Run Mihini on an Open Hardware platform"

Line 5: Line 5:
 
== Step 1 - Build Mihini ==
 
== Step 1 - Build Mihini ==
  
* Download the sources
+
So far, all the work is being done directly on your remote system. For the following sample, <em>pi</em> user is being used on a <em>RaspberryPi</em>. Connect to you device using <code>ssh</code> and follow the steps.
* Cross-compile (or compile directly on the target) the Mihini runtime
+
* '''TODO''' at that stage, can we try to create a dpkg? That'd be very useful...
+
  
== Step 1 (alternative) - Get a ready-to-use "Mihini for XXX" SD card binary image ==
+
=== Compilation prerequisites ===
  
* Download a ready-to-use .img file and put it on the SD card used on the development board
+
First of all, you will need some compilation tools:<br/>
 +
<code><pre>$ sudo apt-get install git build-essential cmake</pre></code>
  
== Step 2 - Configure network connection ==
+
=== Sources to compile ===
 
+
=== 3G connection ===
+
 
+
* apt-get install ppp
+
* http://mycusthelp.net/SIERRAWIRELESS/_cs/AnswerDetail.aspx?sSessionID=&aid=5#Connecting_using_PPPD
+
 
+
=== Ethernet connection ===
+
 
+
* Configure/verifiy that there is Ethernet connection as a fall-back
+
 
+
== Step 3 - Configure Mihini ==
+
  
=== Compile Mihini ===
+
Get the sources
 +
<code><pre>$ cd /tmp/
 +
$ git clone ssh://host/mihini.git</pre></code>
  
First of all you will need prerequisites
+
=== Configure Mihini ===
<code>sudo apt-get install git build-essential cmake</code>
+
Now get the sources
+
<code><pre>cd /tmp/
+
git clone ssh://host/mihini.git</pre></code>
+
  
Then there will be some configuration on <em>agent/agent/defaultconfig.lua</em>.
+
Then there will be some configuration on <code>agent/agent/defaultconfig.lua</code>.
 
* Enable the application container
 
* Enable the application container
** <code>appcon.activate = true</code> in defaultconfig.lua
+
** <code>appcon.activate = true</code>
 
* Enable the update manager
 
* Enable the update manager
** <code>update.activate = true</code> in defaultconfig.lua
+
** <code>update.activate = true</code>
 
* OPTIONAL (but useful :)), enable Lua shell on all network interfaces by <em>adding</em>
 
* OPTIONAL (but useful :)), enable Lua shell on all network interfaces by <em>adding</em>
 
** <code>shell.address = '*'</code>
 
** <code>shell.address = '*'</code>
  
Now you can choose to compile directly on your device or cross compile it then send in to your device of choice. For the following sample a RaspberryPi has been used.
+
=== Run the compilation ===
  
==== Compiling on device ====
+
Lets move into the repository you just cloned. Make sure you have all prerequisites mentioned above installed. Now, simply run the following in the repository you just cloned, here called <code>mihini/</code>.
 
+
Move the repository you just cloned to your device ( in my case using ''scp'' ). Installed the prerequisites mentioned above on your device and simply run the following in the repository you just copied.
+
 
<code>
 
<code>
 
<pre>
 
<pre>
#
+
# Compile Mihini
# On raspberrypi itself
+
$ cd mihini/bin
#
+
$ ./build.sh
cd mihini/bin
+
 
./build.sh
+
# Compile Lua
#
+
$ cd build.default/
# Compiling Lua
+
$ make lua
#
+
cd build.default/
+
make lua
+
 
</pre>
 
</pre>
 
</code>
 
</code>
  
==== Cross compiling ====
+
=== It should be easier  ===
<code>
+
<pre>
+
#
+
# Cross compiling
+
#
+
  
# Get linaro toolchain
+
What is explained above is just a beginning. We are about to provide material which will speed up previous steps, such as:
cd /where/you/want/it
+
git clone https://github.com/raspberrypi/tools.git
+
  
# Define path to the arm toolchain you just downloaded
+
* How to cross compile Mihini from your Desktop machine
cd /tmp/mihini
+
* A <code>defaultconfig.lua</code> with the right default settings
vim cmake/toolchain.raspberrypi-linaro.cmake
+
* A Linux package, to avoid any kind of compilation or configuration ( It is hypothetical )
cd bin/
+
./build.sh -t raspberrypi-linaro
+
  
#
+
== Step 2 - Configure network connection ==
# Compiling Lua
+
#
+
cd build.raspberrypi-linaro/
+
make lua
+
  
# Send all this on raspberrypi
+
=== 3G connection ===
scp -r runtime pi@yourPiIp:mihini
+
</pre>
+
</code>
+
  
 +
* <code><pre>$ apt-get install ppp</pre></code>
 +
* [http://mycusthelp.net/SIERRAWIRELESS/_cs/AnswerDetail.aspx?sSessionID=&aid=5#Connecting_using_PPPD Connecting using PPPD]
  
=== Start Mihini daemon on your device ===
+
=== Ethernet connection ===
  
One of the features of Mihini is to manage the life cycle of your application. In order to do so, applications are run from another program. We need to start it.
+
* Configure/verifiy that there is Ethernet connection as a fall-back
  
====Manually====
+
== Step 3 - Start Mihini on your device ==
 +
 
 +
One of the features of Mihini is to manage the life cycle of your application. In order to do so, applications are run from another program: the <code>Appmon</code>. We need to start it.
 +
 
 +
=== Manually ===
  
 
On your device ( here a Raspberry Pi)
 
On your device ( here a Raspberry Pi)
Line 103: Line 74:
 
'''Notice''':  we launched <code>appmon_daemon</code> with user <code>pi</code> in order to benefit from valid user rights.
 
'''Notice''':  we launched <code>appmon_daemon</code> with user <code>pi</code> in order to benefit from valid user rights.
  
====As a service====
+
=== As a service ===
 +
 
 +
Soon :)
  
 
== Step 4 - Setup Koneki environment ==
 
== Step 4 - Setup Koneki environment ==

Revision as of 12:55, 16 January 2013

This page describes a scenario for illustrating the use of Mihini on an Open Hardware Linux-based platform such as BeagleBoard or RaspberryPi.

The goal would be for someone to be able to be only one hour away from taking a bare development board and have it configured to collect data out of the GPIO sensors and send this data on a remote server. The application aims to be updatable over-the-air.

Step 1 - Build Mihini

So far, all the work is being done directly on your remote system. For the following sample, pi user is being used on a RaspberryPi. Connect to you device using ssh and follow the steps.

Compilation prerequisites

First of all, you will need some compilation tools:

$ sudo apt-get install git build-essential cmake

Sources to compile

Get the sources

$ cd /tmp/
$ git clone ssh://host/mihini.git

Configure Mihini

Then there will be some configuration on agent/agent/defaultconfig.lua.

  • Enable the application container
    • appcon.activate = true
  • Enable the update manager
    • update.activate = true
  • OPTIONAL (but useful :)), enable Lua shell on all network interfaces by adding
    • shell.address = '*'

Run the compilation

Lets move into the repository you just cloned. Make sure you have all prerequisites mentioned above installed. Now, simply run the following in the repository you just cloned, here called mihini/.

# Compile Mihini
$ cd mihini/bin
$ ./build.sh

# Compile Lua
$ cd build.default/
$ make lua

It should be easier

What is explained above is just a beginning. We are about to provide material which will speed up previous steps, such as:

  • How to cross compile Mihini from your Desktop machine
  • A defaultconfig.lua with the right default settings
  • A Linux package, to avoid any kind of compilation or configuration ( It is hypothetical )

Step 2 - Configure network connection

3G connection

Ethernet connection

  • Configure/verifiy that there is Ethernet connection as a fall-back

Step 3 - Start Mihini on your device

One of the features of Mihini is to manage the life cycle of your application. In order to do so, applications are run from another program: the Appmon. We need to start it.

Manually

On your device ( here a Raspberry Pi)

$ cd mihini/bin/
$ sudo ./appmon_daemon -u pi -g pi && cd .. && ./start.sh

Notice: we launched appmon_daemon with user pi in order to benefit from valid user rights.

As a service

Soon :)

Step 4 - Setup Koneki environment

  • Download Lua Development Tools
  • Install "Mihini target management"
  • Define your device and configure its "SSH Lua" paths like this
    SshLuaConfiguration.png
    • If you want the text version
LUA_PATH: /home/pi/mihini/lib/?.lua;/home/pi/mihini/lib/?/init.lua;/home/pi/mihini/lua/?.lua;/home/pi/mihini/lua/?/init.lua;./?.lua
LUA_CPATH: /home/pi/mihini/lib/?.so;/home/pi/mihini/lua/?.so
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:/home/pi/mihini/lib
  • Configure the "Mihini execution environment" (provides nice autocompletion...)

Step 5 - Create your first application

  • TODO (blink a LED, use a touch sensor, measure the temperature and available RAM of the board...)

Step 6 - Test the application

  • Configure the remote target in the Koneki environment
    • You will need to know the IP address of the target, but you likely know it already :-)
  • Create a launch/debug configuration and test your script

Step 7 - Install your application

Over the air

  • Use the Koneki tools to create an application package
  • Deploy the package on a publically available web server
  • Connect to the Mihini console and for a connection to the testing server

Manually

All you a have to do in order to enable Mihini to handle you application is:

  1. Create a launcher
  2. Provide sources

Create a launcher

Mihini Application container runs executables. To run a Lua application, we need to set some variables beforehand and then lauch ou application. In order to do so lets create the proper launcher.In the Mihini world, it is an executable file called run. Here is its content:

#!/bin/sh

# Setting up paths
export LUA_PATH="/home/pi/mihini/lib/?.lua;/home/pi/mihini/lib/?/init.lua;/home/pi/mihini/lua/?.lua;/home/pi/mihini/lua/?/init.lua;./?.lua"
export LUA_CPATH="/home/pi/mihini/lib/?.so;/home/pi/mihini/lua/?.so"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/pi/mihini/lib"

# Running app
/home/pi/mihini/bin/lua main.lua

Now the my application folder looks like

$ find raspapp/
raspapp/
raspapp/run
raspapp/main.lua

Install application

It is now time to install our application. Copy you app folder on your device.

scp -r raspapp/ pi@raspberry.local:/tmp

Now that your application is available on your device, lets install it. I suppose you already an Appmon Daemon running. We are about to install an app which will be named 'sample', available at '/tmp/raspapp', this application will benefit from autostart ( the last true parameter ).

$ telnet localhost 2000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Lua interactive shell
> appcon = require 'agent.appcon'
> = appcon.install('sample', '/tmp/raspapp', true )
= ok

We can check that the application is properly installed

> for app, t in pairs(appcon.list()) do
+     print( app )
+     for field, data in pairs(t) do
+         print('\t', field, data)
+     end
+ end
sample
                autostart       true
                runnable        true

MISC. TIP & TRICKS

  • You may want to have udev rules so as your USB devices (typically the 3G stick) does not end up having an always changing /dev/ttyUSB<something> file descriptor...
    • For a Sierra 3G stick, create a 99-aircard.rules in /etc/udev/rules.d, with the following rules (your ID_VENDOR_ID and ID_MODEL_ID may be different):

SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ENV{ID_VENDOR_ID}=="1199", ENV{ID_MODEL_ID}=="68a3", ENV{ID_USB_INTERFACE_NUM}=="03", SYMLINK+="ttyATConsole0" SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ENV{ID_VENDOR_ID}=="1199", ENV{ID_MODEL_ID}=="68a3", ENV{ID_USB_INTERFACE_NUM}=="04", SYMLINK+="ttyATConsole1"

TODO

Copyright © Eclipse Foundation, Inc. All Rights Reserved.