root@ubuntu:/home/ubuntu$ sudo -s
root@ubuntu:/home/ubuntu#
root@ubuntu:/home/ubuntu# wget https://github.com/contiki-os/contiki/archive/3.0.zip
root@ubuntu:/home/ubuntu# unzip 3.0.zip
root@ubuntu:/home/ubuntu$ sudo -s
root@ubuntu:/home/ubuntu#
root@ubuntu:/home/ubuntu# wget https://github.com/contiki-os/contiki/archive/3.0.zip
root@ubuntu:/home/ubuntu# unzip 3.0.zip
Go to google search and type instant contiki 2.7 download
Step1: Installing Java on Ubuntu
You can install one or several Java packages. You can also decide which version you want on your system by installing a specific version number. The current default and LTS version is Java 11.
Install OpenJDK
1. Open the terminal (Ctrl+Alt+T) and update the package repository to ensure you download the latest software version:
sudo apt update
2. Then, you can confidently install the latest Java Development Kit with the following command:
sudo apt install default-jdk
Install Specific Version of OpenJDK
You may decide to use Open JDK 8, instead of the default OpenJDK 11.
To do so, open the terminal and type in the following command:
sudo apt install openjdk-8-jdk
Once the installation process is complete, verify the current Java version:
java -version; javac -version
How to find the OpenJDK directory with the following command:
readlink -f /usr/bin/javac
How to Set Default Java Version
As you can have multiple versions of Java installed on your system, you can decide which one is the default one.First, run a command that shows all the installed versions on your computer:
sudo update-alternatives --config java
step 2: Uninstall Java on Ubuntu
In case you need to remove any of the Java packages installed, use the apt remove or purge command. To remove Open JDK 11, run the command:
sudo apt remove default-jdk
To uninstall OpenJDK 8:
sudo apt remove openjdk-8-jdk
2nd Method:
1. sudo dpkg --list | grep -i jdk
2. sudo apt-get purge Oracle-java8-installer
Open the terminal
ctrl +alt + t
vl@ubuntu:~/contiki-ng$ cd tools
vl@ubuntu:~/contiki-ng/tools$ ls
vl@ubuntu:~/contiki-ng/tools$ cd cooja
vl@ubuntu:~/contiki-ng/tools/cooja$ update-alternatives --config java
// it may not change unless we do in root
vl@ubuntu:~/contiki-ng/tools/cooja$ sudo -s
[sudo] password for vl:
root@ubuntu:/home/vl/contiki-ng/tools/cooja# update-alternatives --config.java
root@ubuntu:/home/vl/contiki-ng/tools/cooja# ant run
open the terminal
ctrl + alt + t
create a folder rk and copy helloworld.c and makefile from examples folder
vl@ubuntu:~/contiki-ng/examples$ mkdir rk
vl@ubuntu:~/contiki-ng/examples$ ls
6tisch ip64-router nullnet slip-radio
benchmarks ledprg platform-specific snmp-server
coap libs rk storage
cplusplus lwm2m-ipso-objects rpl-border-router websocket
dev mqtt-client rpl-udp
hello-world multicast sensniff
vl@ubuntu:~/contiki-ng/examples$ cd rk
vl@ubuntu:~/contiki-ng/examples/rk$ ls
vl@ubuntu:~/contiki-ng/examples/rk$ cp ../hello-world/hello-world.c .
vl@ubuntu:~/contiki-ng/examples/rk$ cp ../hello-world/Makefile .
vl@ubuntu:~/contiki-ng/examples/rk$ ls
hello-world.c Makefile
vl@ubuntu:~/contiki-ng/examples/rk$ mv hello-world.c myown.c
set the Makefile to myown as shown
Now create myown.c file
#include "contiki.h"
#include <stdio.h> /* For printf() */
/*---------------------------------------------------------------------------*/
PROCESS(myown_process, "I am on My Own");
AUTOSTART_PROCESSES(&myown_process);
/*---------------------------------------------------------------------------*/
//Protothread
PROCESS_THREAD(myown_process, ev, data)
{
static struct etimer timer;//static is used here to store the timer in RAM
PROCESS_BEGIN();
/* Setup a periodic timer that expires after 10 seconds. */
etimer_set(&timer, CLOCK_SECOND * 5);
while(1) { //super loop architecture
printf("Hello Friends Welcome to IoT\n");
/* Wait for the periodic timer to expire and then restart the timer. */
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
etimer_reset(&timer);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
Run:
vl@ubuntu:~/contiki-ng/examples/rk$ make
vl@ubuntu:~/contiki-ng/examples/rk$ ls
build Makefile myown.c myown.native
vl@ubuntu:~/contiki-ng/examples/rk$ make TARGET=native
make: Nothing to be done for 'all'.
vl@ubuntu:~/contiki-ng/examples/rk$ make clean
TARGET not defined, using target 'native'
vl@ubuntu:~/contiki-ng/examples/rk$ make TARGET=native
vl@ubuntu:~/contiki-ng/examples/rk$ ./myown.native
create a folder ledprg in contiki/examples
copy the makefile from helloworld into the above created folder
create a file led.c in ledprg folder
//led.c
#include "contiki.h"
#include <stdio.h>
#include "dev/leds.h"
#include "dev/button-sensor.h"
PROCESS(led_process, "LED Process");
AUTOSTART_PROCESSES(&led_process);
PROCESS_THREAD(led_process,ev,data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(button_sensor);
while(1)
{
printf("Press the Button of the sensor\n");
PROCESS_WAIT_EVENT_UNTIL(ev==sensors_event && data==&button_sensor);
leds_toggle(LEDS_GREEN);
}
printf("The sensor value is %u \n",leds_get());
PROCESS_END();
}
//Makefile
see that both the files are in the same folder ledprg
RUN THE PROGRAM:
vl@ubuntu:~/contiki-ng/examples/ledprg$ make TARGET=native
Note :
if there is an error regarding gcc version
wget http://www.netgull.com/gcc/releases/gcc-4.8.0/gcc-4.8.0.tar.bz2
To extract the file:
tar -xvjf gcc-4.8.0.tar.bz2
Install some additional libraries (sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libc6-dev
)
Compile the source: ./gcc-4.8.0/configure --prefix=/app/gcc/4.8.0
Run make
(This will take some time to complete. Go make some coffee, or bake some cookies. ;-))
Install the code: sudo make install
sudo dpkg --add-architecture i386
sudo apt update
sudo apt upgrade
sudo apt-get install gcc-multilib libstdc++6:i386
wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.bz2 --no-check-certificate
tar xf gcc-4.8.5.tar.bz2
# cd gcc-4.8.5
# ./contrib/download_prerequisites
# cd ..
sed -i -e 's/__attribute__/\/\/__attribute__/g' gcc-4.8.5/gcc/cp/cfns.h
sed -i 's/struct ucontext/ucontext_t/g' gcc-4.8.5/libgcc/config/i386/linux-unwind.h
mkdir xgcc-4.8.5
pushd xgcc-4.8.5
$PWD/../gcc-4.8.5/configure --enable-languages=c,c++ --prefix=/usr --enable-shared --enable-plugin --program-suffix=-4.8.5
make MAKEINFO="makeinfo --force" -j
sudo make install -j
Start by installing some necessary packages:
$ sudo apt update
$ sudo apt install build-essential doxygen git curl wireshark python3-serial srecord rlwrap
While installing Wireshark, select enable the feature that lets non-superuser capture packets (select "yes").
$ sudo apt install autoconf automake libxmu-dev
To install GCC for ARM controller
$ wget https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2
Extract this file in the home folder itself.
To open the above file using a terminal
vl@ubuntu:~/gcc-arm-none-eabi-5_2-2015q4-20151219-linux$ pwd
/home/vl/gcc-arm-none-eabi-5_2-2015q4-20151219-linux
vl@ubuntu:~/gcc-arm-none-eabi-5_2-2015q4-20151219-linux$ cd
vl@ubuntu:~$ pwd
/home/vl
vl@ubuntu:~$ gedit .bashrc
set the above in the PATH Environment.
/home/vl/.bashrc as:
export PATH=$PATH:/home/vl/gcc-arm-none-eabi-5_2-2015q4-20151219-linux/bin
To check the added path use the commnad
$ echo $PATH
Add this path in .bashrc file
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin/java
$ sudo apt-get install -y npm && sudo apt-get clean && sudo npm install coap-cli -g && sudo ln -s /usr/bin/nodejs /usr/bin/node
MQTT Clients
$ sudo apt-get install -y mosquitto mosquitto-clients
Configuration Completed.
Download Contiki NG
Peer-to-Peer (P2P) networks are a decentralized type of network architecture where each device (or node) on the network can act as both a...