Installing the Development Environment (OSX and Windows)

Install Virtualbox virtualization software. If you are given the option to also install the USB driver and the Host-only network driver, install them as well.

Check that you have a Host-only adapter and that its DHCP server is enabled. To do this enter >> Preferences >> Network and select the Host-only adapter vboxnet0. If you don't have an adapter vboxnet0, add one. Select the Edit icon for vboxnet0 and ensure that DHCP Server has these settings:

 [*] Enable Server

      Server Address: [192.168.56.100]
         Server Mask: [255.255.255.0]
 Lower Address Bound: [192.168.56.101]
 Upper Address Bound: [192.168.56.254]

Download both of the virtual machine files into the same directory.

  • [attachment:linux-dev.ovf?format=raw linux-dev.ovf]
  • [attachment:linux-dev-disk1.vmdk?format=raw linux-dev-disk1.vmdk]

Select the >> Import Appliance option in Virtualbox to import linux-dev.ovf. Follow the Import Appliance dialogue, selecting all of the default options.

You are now ready to power up the virtual machine!

Flashing Your First Nano-RK Application

Power up the virtual machine and initiate an SSH connection using you favorite SSH client (e.g. PuTTY, OpenSSH). The Virtualbox window only allows for a single, very slow terminal, so all development will be done through a secure shell. The SSH login parameters are:

  Address: 192.168.56.101 OR 192.168.56.102 (try both)
 Username: dev
 Password: multihop

You should now have terminal access in the development VM. This terminal will be the standard way in which users interact with the development environment (no graphical applications). The nano-RK directory should be the only directory in your home. This is the directory which contains all of the files and tools necessary for Nano-RK development.

Let's make sure that the Nano-RK toolchain is up-to-date. Enter the nano-RK directory and perform a subversion update:

dev@ubuntu:~$ cd nano-RK/
dev@ubuntu:~/nano-RK$ svn update

In order to flash an application onto a Firefly sensor node, we must first make sure that the node is being recognized by the VM. Connect the Firefly node to the host machine and enter Devices >> USB Devices. Enable FTDI FT232R USB UART to connect the Firefly node to the VM. You may have to restart the VM in order to get it to recognize the node successfully. Once done, use the dmesg utility inside the VM to confirm that the device is attached to ttyUSB0.

We are now ready to flash our first application onto a Firefly sensor node. Navigate to /home/dev/nano-RK/projects/examples/basic_tasks/.

dev@ubuntu:~/nano-RK$ cd projects/examples/basic_tasks/
dev@ubuntu:~/nano-RK/projects/examples/basic_tasks$ ls
main.c  makefile  nrk_cfg.h

The basic_tasks directory contains the three files necessary for compiling and flashing the Basic Tasks application. Most Nano-RK applications are comprised of these three files. main.c contains the application code, makefile configures the compilation and programming, and nrk_cfg.h configures the behavior of the Nano-RK OS under this application.

Use vi or your favorite text editor (install via apt-get package manager) to study the main.c. The application code describes four tasks which toggle LEDs on the Firefly at different periods. Browse the makefile and confirm that PLATFORM is set to firefly3 and that PROGRAMMING_PORT is set to /dev/ttyUSB0. The application will fail if these variables are not set correctly.

To compile the application use the make command:

dev@ubuntu:~/nano-RK/projects/examples/basic_tasks$ make

...
...
...
Creating Symbol Table: main.sym
avr-nm -n main.elf > main.sym

Size after:
main.elf  :
section      size      addr
.data         596   8389120
.text       27636         0
.bss         1300   8389716
.stab       60108         0
.stabstr    37727         0
Total      127367

Errors: none
Platform: firefly3
-------- end --------

There should now be a main.hex file in the directory. This file contains the hexadecimal representation of you binary executable. To flash main.hex onto your Firefly sensor node, use make program:

dev@ubuntu:~/nano-RK/projects/examples/basic_tasks$ make program
avrdude -b 57600 -F -p atmega128 -P /dev/ttyUSB0 -c arduino -V -U flash:w:main.hex 

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9704
avrdude: Expected signature for ATMEGA128 is 1E 97 02
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex" 
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (28232 bytes):

Writing | ################################################## | 100% 7.48s

avrdude: 28232 bytes of flash written

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

If you see the output above, you have successfully flashed the Firefly node! You should be rewarded with a blinking light show from your Firefly. Before leaving the directory, make sure to delete non-source files with a make clean:

dev@ubuntu:~/nano-RK/projects/examples/basic_tasks$ make clean

...
...
...
./../src/kernel/source/nrk_stack_check.d ../../../src/kernel/source/nrk_event
s.d ../../../src/kernel/source/nrk_task.d ../../../src/kernel/source/nrk_time
.d ../../../src/kernel/source/nrk_idle_task.d ../../../src/kernel/source/nrk_
scheduler.d ../../../src/kernel/source/nrk_driver.d ../../../src/kernel/sourc
e/nrk_reserve.d ../../../src/kernel/source/nrk_sw_wdt.d ../../../src/kernel/h
al/atmega128rfa1/nrk_timer.d ../../../src/kernel/hal/atmega128rfa1/nrk_status
.d ../../../src/kernel/hal/atmega128rfa1/nrk_ext_int.d ../../../src/kernel/ha
/atmega128rfa1/nrk_watchdog.d ../../../src/kernel/hal/atmega128rfa1/nrk_cpu.d
Errors: none
Platform: firefly3
-------- end --------

For more example projects to read and try out, check out the /home/dev/nano-RK/projects/examples directory.

linux-dev.ovf - Development VM OVF File (5.7 kB) Maxim Buevich, 10/14/2011 12:30 pm