Showing posts with label 6LowPAN. Show all posts
Showing posts with label 6LowPAN. Show all posts

Tuesday, August 25, 2020

Build OpenThread Sleepy End Device doorlock prototype to test with Rasperry Pi OpenThread Border Router

The following steps show how to build OpenThread Sleepy End Device doorlock prototype to test with Rasperry Pi OpenThread Border Router

1. Build OpenThread Sleepy End Device doorlock prototype for TI LAUNCHXL-CC26X2R1

1.1 Download/Install TI CCS 10.1 and SIMPLELINK-CC13X2-26X2-SDK v4.20.00.35.

1.2 Import thread door_lock example from C:\ti\simplelink_cc13x2_26x2_sdk_4_20_00_35\examples\rtos\CC26X2R1_LAUNCHXL\thread\door_lock

1.3 Set door_lock as Sleepy End Device from sysconfig.

 

1.4 Add the following codes in tiop_ui.c for providing API to output IPv6 address to UART console.

inline uint16_t Swap16(uint16_t v)
{
    return (((v & 0x00ffU) << 8) & 0xff00) | (((v & 0xff00U) >> 8) & 0x00ff);
}
 

inline uint16_t HostSwap16(uint16_t v)
{
    return Swap16(v);
}

void tiopCUIOutputIp6Address(otIp6Address aAddress)
{
    CUI_statusLinePrintf(
        clientHandle, nwkInfoLine1,
        "[" CUI_COLOR_GREEN "IPv6" CUI_COLOR_RESET "] %s - %x:%x:%x:%x:%x:%x:%x:%x",
        "Addr",
        HostSwap16(aAddress.mFields.m16[0]), HostSwap16(aAddress.mFields.m16[1]),
                HostSwap16(aAddress.mFields.m16[2]), HostSwap16(aAddress.mFields.m16[3]), HostSwap16(aAddress.mFields.m16[4]),
                HostSwap16(aAddress.mFields.m16[5]), HostSwap16(aAddress.mFields.m16[6]), HostSwap16(aAddress.mFields.m16[7]));
}

1.5 Add the following line to expose API tiopCUIOutputIp6Address in tiop_ui.h.

extern void tiopCUIOutputIp6Address(otIp6Address aAddress);

1.6 Add the following line in "case DoorLock_evtKeyRight:..." of processEvent (doorlock.c) to output IPv6 address when right button is pressed.

tiopCUIOutputIp6Address(*(otThreadGetRloc(OtInstance_get())));

1.7 Build and download sleepy door_lock firmware into LAUNCHXL-CC26X2R1.

 

2. Setup OpenThread Border Router and libcoap on Raspberry Pi.

2.1 Refer to this link to setup OpenThread Border Router on Raspberry Pi.

2.2 Run the following command in Raspberry Pi console to setup libcoap.

      sudo apt install autoconf automake libtool
      git clone --depth 1 --recursive -b dtls https://github.com/home-assistant/libcoap.git
      cd libcoap
      ./autogen.sh
      ./configure --disable-documentation --disable-shared --without-debug CFLAGS="-D COAP_DEBUG_FD=stderr"
      make
      sudo make install

3. Use the following commands on Raspberry Pi console and start sleepy door_lock to join thread network. Then, press right button on LAUNCHXL-CC26X2R1 to print IPv6 address of sleepy door_lock.

sudo ot-ctl commissioner start
sudo ot-ctl commissioner joiner add 00124b001ca16238 DRRLCK1

4. Use the following command to request lock state of sleepy door_lock from border router.

coap-client -m get coap://[fd11:1111:1122:0:0:ff:fe00:ec08]/doorlock/lockstate

5. Use the following command to change lock state of sleepy door_lock from border router.

coap-client -m post coap://[fd11:1111:1122:0:0:ff:fe00:ec08]/doorlock/lockstate -e unlock

 


Friday, August 21, 2020

Running OpenThread Border Router and device with Raspberry Pi and Silicon Labs EFR32 Kits

Silicon Labs releases Simplicity Studio v5 which supports OpenThread in the end of July 2020. To run the whole thing, you will need one Raspberry Pi, one SLWSTK6000B (BRD4001A+BRD4161A to act as OpenThread RCP connecting to OpenThread Border Router running on Raspberry Pi), and one SLWSTK6006A (BRD4001A+BRD4180A to act as OpenThread device to join Thread network). 


 

In the following steps, I will show you how to run OpenThread Border Router and device with Raspberry Pi and Silicon Labs EFR32 Kits.

 

1. Create and build OpenThread RCP to run on SLWSTK6000B .

1.1 Start  Simplicity Studio v5 and select ot-rcp project from EXAMPLE PROJECTS on Laucher

1.2 Switch to Simplicity IDE tab and open ot-rcp.slcp. Click "Force Generation" to generate codes and click "Build" button to build the project.

1.3 Download ot-rcp.s37 to SLWSTK6000B .


2. Setup OpenThread Border Router on Raspberry Pi.

2.1 Download Raspbian Stretch Lite OS image and put it on SD card. Insert the SD card into Raspberry Pi and power on it. Enable ssh access on Raspberry Pi and remote login with TeraTerm.

2.2 Run the following command to get OpenThread Border Router project (I use commit a69a9d5c82d25b6d3c6ddd5ac29d80676b34465f in my test).

      sudo apt-get update

      sudo apt-get install -y git

      git clone https://github.com/openthread/ot-br-posix

      cd ot-br-posix

      git checkout 28991cdf9f3c8794ccfa5843685228e8d93470a7

      git submodule update --init --recursive

2.3 Build and install OpenThread Border Router

      ./script/bootstrap

      ./script/setup

2.4 Connect SLWSTK6000B running OpenThread RCP to Raspberry PI by USB cable and make sure SLWSTK6000B simulates ttyACM0 under /dev.

2.5 Reboot OpenThread Border Router

      sudo reboot

2.6 After reboot, you can start a browser and use http://ip-of-raspberry-pi-border-router to access to web page of OpenThread Border Router.

 

2.7 Switch to Form tab and click "FORM" button to form a Thread Network.


3. Create and build OpenThread Cli-FTD to run on SLWSTK6006A .

3.1 Start  Simplicity Studio v5 and select ot-cli-ftd project from EXAMPLE PROJECTS on Laucher

 

3.2 Switch to Simplicity IDE tab and open ot-cli-ftd.slcp. Click "Force Generation" to generate codes and click "Build" button to build the project.

3.3 Download ot-cli-ftd.s37 to SLWSTK6006A .


4. Commission ot-cli-ftd running on SLWSTK6006A to Openthread Border Router.

4.1 Run commissioner and add device eui64/PSK to commissioner on Raspberry Pi console.

      sudo ot-ctl commissioner start

      sudo ot-ctl commissioner joiner add 000d6ffffe0a457b J01NME

4.2 Start ot-cli-ftd and run joiner with PSK to join OpenThread network.

      ifconfig up
      joiner start J01NME

      thread start


4.3 Try to ping ot-cli-ftd from OpenThread Border Router to make sure device joins.

 

4.4 Test the connectivity between the Joiner device in the Thread network and the external internet by pinging a public IPv4 address, such as 64:ff9b::808:808 (the Well-Known Prefix of 64:ff9b::/96 and an IPv4 address of 8.8.8.8 (Google Public DNS) combine to form an IPv6 address of 64:ff9b::808:808). Remember to do "thread start" before you do "ping 64:ff9b::808:808"


Monday, October 23, 2017

How to configure 6lbr to make it can do ping6 to a CC26xx/CC13xx node from Raspberry Pi running 6lbr.

The following steps shows you how to configure 6lbr to make it can do ping6 to a CC26xx/CC13xx node from Raspberry Pi running 6lbr.

1. Run "sudo vi /etc/6lbr/6lbr.conf" on Raspberry Pi terminal and use the following bridge mode settings.

RAW_ETH=0
BRIDGE=1
CREATE_BRIDGE=0
DEV_BRIDGE=br0
DEV_TAP=tap0
DEV_ETH=eth0
DEV_ETH_FCS=0

DEV_RADIO=/dev/ttyACM0
BAUDRATE=115200

LOG_LEVEL=3

2. Run "sudo vi /etc/network/interfaces" on Raspberry Pi terminal and Make sure you have the following br0 settings (red lines) added.

auto lo
iface lo inet loopback

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#auto wlan1
#allow-hotplug wlan1
#iface wlan1 inet manual
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface eth0 inet static
address 0.0.0.0

auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
up echo 0 > /sys/devices/virtual/net/br0/bridge/multicast_snooping
post-up ip link set br0 address 'ip link show eth0 | grep ether | awk '{print $2}''


3. Restart your Raspberry Pi (sudo reboot) and 6lbr (sudo service 6lbr start) to apply those changes.

4. Make sure you enable IP64 on your 6lbr configuration page.


5. Run "sudo route -A inet6 add fd00::/64 gw bbbb::100" to add routing of fd00::/64 to bbbb::100


6. Check IPv6 address of your CC26xx/CC13xx node



7. Run "ping6 fd00::212:4b00:e00:cc0" to ping your CC26xx/CC13xx node and get responses.


Wednesday, July 20, 2016

How to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.

The following steps show you how to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.

1. git clone --recursive https://github.com/contiki-os/contiki

2. Change directory to /contiki/examples/sensniff

3. Use the following three make command to build sensniff.bin for CC2650DK, CC2650 LaunchPad, or CC2650ST.

    a. make TARGET=srf06-cc26xx BOARD=srf06/cc26xx sensniff.bin   -->CC2650DK
    b. make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 sensniff.bin --> CC2650LP
    c. make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 sensniff.bin --> CC2650STK



4. Use Flash Programmer 2 to download sensniff.bin to CC2650DK, CC2650 LaunchPad, or CC2650ST.



5. Download latest sensniff.py from https://github.com/g-oikonomou/sensniff  and refer to here for running Wireshark to sniff packets.

How to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.

The following steps show you how to use CC2650DK, CC2650 LaunchPad, or CC2650STK as Contiki 6LowPAN Sniffer.

1. git clone --recursive https://github.com/contiki-os/contiki

2. Change directory to /contiki/examples/sensniff

3. Use the following three make command to build sensniff.bin for CC2650DK, CC2650 LaunchPad, or CC2650ST.

    a. make TARGET=srf06-cc26xx BOARD=srf06/cc26xx sniffer.bin   -->CC2650DK
    b. make TARGET=srf06-cc26xx BOARD=launchpad/cc2650 sniffer.bin --> CC2650LP
    c. make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 sensniff.bin --> CC2650STK



4. Use Flash Programmer 2 to download sensniff.bin to CC2650DK, CC2650 LaunchPad, or CC2650ST.



5. Download latest sensniff.py from https://github.com/g-oikonomou/sensniff  and refer to here for running Wireshark to sniff packets.

Tuesday, March 22, 2016

Running 6lbr on CC2538DK with ENC28J60 and make CC2650STK send sensor data to IBM MQTT quickstart service.

The following steps show how to run 6lbr on CC2538DK with ENC28J60 and make CC2650STK send sensor data to IBM MQTT quickstart service.

For CC2538DK and ENC28J60,

1. Connect CC2538DK with ENC28J60.

  • SCLK : CC2538 Port A2 (mapped to RF1.16 on P407 of SmartRF06EB)
  • MOSI : CC2538 Port A4 (mapped to RF1.18 on P407 of SmartRF06EB)
  • MISO : CC2538 Port A5 (mapped to RF1.20 on P407 of SmartRF06EB)
  • CS : CC2538 Port B5 (mapped to RF1.17 on P407 of SmartRF06EB)


2. Git 6lbr develop version from Github
 
 git clone https://github.com/cetic/6lbr
 git checkout develop

3. Build 6lbr for CC2538DK with ENC28J60

make TARGET=cc2538dk all

4. Use Flash Programmer 2 to download cetic_6lbr_router.bin (under \6lbr\examples\6lbr\bin_cc2538dk) to CC2538DK.


For CC2650STK,

1. Git Contiki from Github (refer to http://sunmaysky.blogspot.tw/search/label/Cygwin)

2. Add the following lines in project-conf.h of cc26xx-web-demo example to use nullRDC

#undef NETSTACK_CONF_RDC
#define NETSTACK_CONF_RDC     nullrdc_driver

3. Build cc26xx-web-demo.bin for CC2650STK

make BOARD=sensortag/cc2650 cc26xx-web-demo.bin

4. Use Flash Programmer 2 to download cc26xx-web-demo.bin to CC2650STK


Enable NAT64 to make CC2650STK can report sensor data to IBM MQTT quickstart service.

1. Connect Ethernet cable to CC2538DK-ENC28J60 and power on to run 6lbr.

2. Use Firefox to open web page at [bbbb::100] and switch to Configuration page. Change channel to 25 and select all options under IP64: to on. Press Submit button to write configurations and restart 6lbr.



3. Turn on CC2650STK to make it join 6lbr. Click on the web link in sensor page.



4.In sensor web page, click "IBM Quickstart"


5. Sensor data from CC2650STK would show on IBM MQTT quickstart service.




Thursday, November 12, 2015

How to build DTLS example for SmartRF06EB+CC2650EM in Contiki 6LowPAN

The following steps show you how to build DTLS example for SmartRF06EB+CC2650EM in Contiki 6LowPAN.

On SmartRF06EB+CC2650EM side:

1. Do "git clone --recursive https://github.com/cetic/6lbr" to get source code of 6lbr which contains DTLS examples.

2. Do "git clone --recursive https://github.com/contiki-os/contiki" to get Contiki source code

3. Copy folder "6lbr-demo" under "\6lbr\examples\" to "\contiki\examples"

4. Copy folder "tinydtls" under "\6lbr\apps\" to "\contiki\apps\"

5. Revise "#include "debug.h"" to "#include "../../../../apps/tinydtls/debug.h"" in \contiki\examples\6lbr-demo\apps\dtls-echo\dtls-echo.c.

6. Go to directory "\contiki\examples\6lbr-demo" and do "make TARGET=srf06-cc26xx clean" to clean up things.

7. Do "make TARGET=srf06-cc26xx WITH_TINYDTLS=1 WITH_DTLSECHO=1 6lbr-demo.bin" to get 6lbr-demo.bin which contains DTLS echo application for SmartRF06EB+CC2650EM.

8.  Download 6lbr-demo.bin to SmartRF06EB+CC2650EM using Flash Programmer 2.

9. Turn on SmartRF06EB+CC2650EM to join 6lbr Edge Router. If you connect UART to SmartRF06EB, you would see output like the followings:


On VMPlayer side:

1. Download tinyDTLS from http://sourceforge.net/projects/tinydtls/ and untar it to your home folder in Contiki VMPlayer. When I test this, it is tinydtls-0.8.2.

2. Open a terminal and go to "/tinydtls-0.8.2/" folder.

3. Do "./configure" and "make".

4. You will get dtls-client in "/tinydtls-0.8.2/test" folder.



5. If your network interface is eth0, run the following commands in terminal.

    sysctl -w net.ipv6.conf.eth0.accept_ra=1
    sysctl -w net.ipv6.conf.eth0.accept_ra_rt_info_max_plen=64
    route -A inet6 add aaaa::/64 gw bbbb::100

6. Run "./dtls-client aaaa::212:4b00:695:8605" in "/tinydtls-0.8.2/test" folder and you can send something to dtls-server on aaaa::212:4b00:695:8605. You will see echo from dtls-server running on SmartRF06EB+CC2650EM with aaaa::212:4b00:695:8605 as IPv6 address.


Wednesday, November 11, 2015

How to build/set Contiki rpl-border-router on SmratRF06EB+CC1350EM and run tunslip6

The following steps show how to build/set Contiki rpl-border-router on SmratRF06EB+CC1350EM and run tunslip6 in Contiki VMPlayer.
1. Go to "/contiki/examples/ipv6/rpl-border-router" directory and change "#define DEBUG DEBUG_NONE" to "#define DEBUG DEBUG_PRINT" in border-router.c. Also remember to add "#define RF_CORE_CONF_CHANNEL 25" in project-conf.h to set default channel to 25 (If you don't add this, it will use channel 0 which is defined in contiki-conf.h under /contiki/platform/srf06-cc26xx. It might have problem that a SensorTag use channel 25 to join later.)

2. Do "make TARGET=srf06-cc26xx BOARD=srf06/cc13xx" in terminal and you will get border-router.bin. Download border-router.bin to your SmratRF06EB+CC1350EM with Flash Programmer 2.

3. Connect USB cable and turn on SmratRF06EB+CC1350EM.

4. Run the following commands in Linux terminal of Contiki VMPlayer to enum ttyUSB0 and ttyUSB1 under /dev
    sudo modprobe ftdi_sio vendor=0x403 product=0xa6d1
    sudo chmod 777 /sys/bus/usb-serial/drivers/ftdi_sio/new_id
    sudo echo 0403 a6d1 > /sys/bus/usb-serial/drivers/ftdi_sio/new_id

5. Go to "/contiki/tools" directory and do " make tunslip6"

6. Run "sudo ./tunslip6 aaaa::1/64 -s /dev/ttyUSB1" and you will see tunslip6 running.





7. Press "EM RESET" button on SmratRF06EB to make rpl-border-router reset to dump
 Server IPv6 addresses which is aaaa:212:4b00:7c6:2b02 in my test.




8. Open FireFox in VMPlayer and go [aaaa:212:4b00:7c6:2b02]. You will see the web page of rpl-border-router.



9. Start a CC1350 SensorTag and you will see it joins rpl-border-router. The IPv6 address of my CC1350 SensorTag is aaaa::212:4b00:7c7:bf02 in my test.



10. Use coap://[aaaa::212:4b00:7c7:bf02] to access coap server on CC1350 SensorTag.


Wednesday, September 9, 2015

How to build Contiki 6lbr Slip Radio on CC2650 SensorTag or SmartRF06EB+CC2650EM

Do the following steps to build Contiki 6lbr Slip Radio for CC2650 SensorTag+CC-DEVPACK-DEBUGGER.

1. Change "#if BOARD_CONF_DEBUGGER_DEVPACK" to "#if 1" in \contiki\platform\srf06-cc26xx\sensortag\cc2650\board.h.

2. do "make clean".

3. do "make TARGET=srf06-cc26xx BOARD=sensortag/cc2650 slip-radio.bin".

4. Download slip-radio.bin to CC2650 SensorTag and connect CC2650 SensorTag+CC-DEVPACK-DEBUGGER to 6lbr router (could be Raspberry Pi or BeagleBone Black).

5. On 6lbr router, do "sudo vi /etc/6lbr/6lbr.conf" and make sure "DEV_RADIO=/dev/ttyACM0".

6. On 6lbr router, start 6lbr with "sudo service 6lbr start"


Do the following steps to build Contiki 6lbr Slip Radio for SmartRF06EB+CC2650EM.

1. do "make clean".

2. do "make TARGET=srf06-cc26xx BOARD=srf06/cc26xx slip-radio.bin".

3. Download slip-radio.bin to SmartRF06EB+CC2650EM and connect FT232 Serial-to-USB dongle to P412 on SmartRF06EB. Connect FT232 to 6lbr router (could be Raspberry Pi or BeagleBone Black).

4. On 6lbr router, do "sudo vi /etc/6lbr/6lbr.conf" and make sure "DEV_RADIO=/dev/ttyUSB0".

5. On 6lbr router, start 6lbr with "sudo service 6lbr start"


Monday, September 7, 2015

Build 6LowPAN Contiki SubG Hz Sniffer for CC1350

Use the following steps to build 6LowPAN Contiki SubG Hz Sniffer for CC1350.
1. Go to  contiki/examples/cc2538dk/sniffer.
2. Add the followinges into project-conf.h.
    #define BOARD_CONF_DEBUGGER_DEVPACK        0
    #define PROP_MODE_CONF_SNIFFER                    1
    #define CC26XX_UART_CONF_BAUD_RATE    460800
    #define RF_CORE_CONF_CHANNEL                 25
3. make TARGET=srf06-cc26xx BOARD=srf06/cc13xx sniffer.bin.
4. Download sniffer.bin to CC1350EM and connect FT232 Serial-to-USB cable to P412 on SmartRF06EB.
5. Refer to steps here about Wireshark part.





Thursday, September 3, 2015

Contiki SubG Hz 6LowPAN on CC1350

To test on Contiki SubG Hz 6LowPAN on CC1350, I use SmartRF06EB+CC1350EM with FT232 USB-to-Serial dongle to act as Slip Radio which is connected to Raspberry Pi (It also works on BeagleBone Black too).

1. Git the latest Contiki source code by using "git clone --recursive https://github.com/contiki-os/contiki".

2. Open /examples/ipv6/slip-radio/project-conf.h. Comment out the QUEUEBUF_CONF_NUM and UIP_CONF_BUFFER_SIZE and add "#define RF_CORE_CONF_CHANNEL 25"

#ifndef PROJECT_CONF_H_
#define PROJECT_CONF_H_
/*
 #undef QUEUEBUF_CONF_NUM
 #define QUEUEBUF_CONF_NUM          4

 #undef UIP_CONF_BUFFER_SIZE
 #define UIP_CONF_BUFFER_SIZE    140
*/

#define RF_CORE_CONF_CHANNEL                 25
#undef UIP_CONF_ROUTER
#define UIP_CONF_ROUTER                 0

3. Bulid slip-radio.bin using the following steps.
cd examples/ipv6/slip-radio
make clean
make TARGET=srf06-cc26xx BOARD=srf06/cc13xx slip-radio.bin

4. Flash slip-radio.bin to SmartRF06EB+CC1350EM using SmartRF Flash programmer 2.0.

5. Connect FT232 USB-to-Serial dongle to UART pins on SmartRF06EB and plug FT232 USB dongle to Raspberry Pi. You should see "ttyUSB0" get listed under /dev.

6. Refer to "Setup 6lbr to run 6LowPAN with CC2531 USB dongle on Raspberry Pi 2B" and revise "DEV_RADIO=/dev/ttyACM0" to "DEV_RADIO=/dev/ttyUSB0" in /etc/6lbr/6lbr.conf.

7. Use "sudo service 6lbr start" to start 6lbr and you can use Firefox to access to 6lbr web page ([bbbb:100]).




Then, I use anther SmartRF06EB+CC1350EM and a CC1350 SensorTag to act as Contiki SubG Hz 6LowPAN devices.

1. Build cc26xx-web-demo.bin for SmartRF06EB+CC1350EM and CC1350 SensorTag.
cd ../examples/cc26xx/cc26xx-web-demo
make clean
make TARGET=srf06-cc26xx BOARD=srf06/cc13xx cc26xx-web-demo.bin

2. Flash cc26xx-web-demo.bin to SmartRF06EB+CC1350EM and CC1350 SensorTag using SmartRF Flash programmer 2.0.


3. Check 6lbr Sensors web page and you will see these two device on it.


Monday, August 17, 2015

Setup 6lbr to run 6LowPAN with CC2531 USB dongle on Raspberry Pi 2B

1. Unzip and flash a CC2531 USB dongle with cc2531-slip-radio_contikimac.zip.
2. SSH login to Raspberry Pi.
3. sudo apt-get install libncurses5-dev
4. sudo apt-get install bridge-utils
5. sudo vi /boot/cmdline.txt file and add the following configuration parameter in the beginning of cmdline.txt
    dwc_otg.speed=1
6a. git clone --recursive https://github.com/cetic/6lbr
6b. cd 6lbr and run "sudo git submodule sync" and "sudo git submodule update --init"
7. cd 6lbr/examples/6lbr
8. make all plugins tools ---> This step takes lots of time so go for a break!
9. sudo make install
10. Create /etc/6lbr/6lbr.conf with the content below
      MODE=ROUTER

      RAW_ETH=1
      BRIDGE=0
      DEV_BRIDGE=br0
      DEV_TAP=tap0
      DEV_ETH=eth0
      RAW_ETH_FCS=0

      DEV_RADIO=/dev/ttyACM0
      BAUDRATE=115200

      LOG_LEVEL=3
11. Change to channel 25,which is used by cc26xx Contiki port
      $sudo /usr/lib/6lbr/bin/nvm_tool --update --channel 25 /etc/6lbr/nvm.dat
12. Run "/usr/lib/6lbr/bin/nvm_tool --print /etc/6lbr/nvm.dat" to make sure it switches to channel 25.

13. Plug CC2531 USB dongle to Raspberry Pi and the dongle should appear as /dev/ttyACM0. Run "sudo lsusb -v" to verify this.

14. run "sudo service 6lbr start" to start 6lbr.

15. Open browser like Firefox and input [bbbb::100].


How to setup Contiki Sniffer for 6LowPAN using CC2531 USB dongle or CC2538EM

The following steps show you how to setup Contiki Sniffer on Mac OS for 6LowPAN using CC2531 USB dongle in details.

1. Download pyserial-2.7.tar.gz and untar it by running "tar zxvf pyserial-2.7.tar.gz" under console terminal of Mac OS.

2. Install pySerial by running "sudo python setup.py install" under console terminal of Mac OS.

3. Download sensniff.py.

4. Download Contiki_Sniffer_CC2531EMK.hex to CC2531 USB dongle using TI CC Debugger and Flash Programmer.

p.s. If you want to use CC2538EM as sniffer, you have to set "#define CC2538_RF_CONF_SNIFFER_USB  1" in C:\contiki\platform\cc2538dk\contiki-conf.h and do make under "C:\contiki\examples\cc2538dk\sniffer". You will get sniffer.bin under "C:\contiki\examples\cc2538dk\sniffer" and flash is to CC2538EM using Flash Programmer 2.

5. Plugin CC2351 USB dongle or CC2538EM into Mac USB port and you should see it enum like /dev/tty.usbmodem1421. Please note that 1421 might be different from device to device.

6. Run "python sensniff.py -d /dev/tty.usbmodem1421 -b 460800" under console terminal of Mac OS.

p.s. CC2531 USB dongle needs you to press S1 or S2 button to make it work after you plug it into UAB port. I don't know why but if you cannot make it work, try it.

7. Download and install wireshark.

8. Run wireshark. Go to Edit->Preferences->Protocols->6LowPAN and add "aaaa::" to Context 0:.

9. Go to Edit->Preferences->Protocols->IEEE802.15.4 and check "TI CC24xx FCS format".

10. Go to Capture -> options -> Manage Interfaces -> New. Input /tmp/sensniff to "Pipe:" and save.

11. Start a new live capture on wireshark and enjoy it.

Tuesday, July 21, 2015

Setup Compile Environment on Windows Cygwin For CC2650/CC2538 Contiki 6LowPAN

The following step-by-step guide shows you how to setup compile environment on Win 7 Cygwin to build Contiki 6LowPAN For CC2650STK, CC2650DK, and CC2538DK.

1. Download and install Cygwin. During Cygwin installation, you have to stop at "Select Packages", put "make" in the seach box, and make sure you select make utility in Devel Category.



2. Install ARM GNU Compiler toolchain. Download and install gcc-arm-none-eabi-4_9-2015q2-20150609-win32.exe. It would be installed to C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q2 and you have to add the path of the installed ARM GNU compiler binaries to PATH environment variable in the Cygwin terminal. To do this, you can add the following line to .bashrc file.

export PATH=/cygdrive/c/Program\ Files\ \(x86\)/GNU\ Tools\ ARM\ Embedded/4.9\ 2015q2/bin/:$PATH

You have to restart Cygwin to enable PATH varibale and type "which arm-none-eabi-gcc" to confirm Cygwin uses correct arm-none-eabi-gcc version.

3. Download and install Msysgit from http://msysgit.github.io/. Remember to select "Use Git Bash only" during installion.





you also have to add the path of the installed Git binaries to PATH environment variable in the Cygwin terminal. To do this, you can add the following line to .bashrc file. You have to restart Cygwin to enable PATH varibale

export PATH=/cygdrive/c/Program\ Files/GNU/bin/:$PATH

4. Switch to C drive by run "cd /cygdrive/c/" under Cygwin. Then, run "git clone --recursive https://github.com/contiki-os/contiki"



5. To build cc26xx-web-demo for CC2650STK, run "cd /cygdrive/c/contiki/examples/cc26xx/cc26xx-web-demo/" and then "make BOARD=sensortag/cc2650 cc26xx-web-demo.bin".



6. After finishing, you will have cc26xx-web-demo.bin under C:\contiki\examples\cc26xx\cc26xx-web-demo

7. You can download cc26xx-web-demo.bin to CC2650STK by using TI Flash Programmer2.

8. For CC2538DK, you can do similar steps to make it work.