Friday, 14 December 2012

Navstik: Getting Started

Navstik has got to be the best gift for somebody who works on micro-air vehicles. It is small, smart and packed with all the sensors that one could imagine. And, as I found out, it is even easy to use! Overall, this product reflects that a great amount of planning and skill has gone into its development.

I was able to flash the board with base code for navstik today. This post lays out all the steps.

Firstly, let us look at the required hardware:

  1. Navstik main board.
  2. IvyPro and IvyGS.
  3. Connecting cables.
  4. Your laptop/ computer.
The videos on the Navstik website show how to connect the wires. Anyways, it is kind of trivial if you can play with legos :P. Visit the navstik video library here.


Now let us set up our computer for programming navstik. I use Ubuntu (Maverick Meerkat) and recommend Linux for this activity. Follow these steps to get required software:
  1. Download the navstik base code from here.
  2. Go to the "Setting up JTAG Debugging" page on navstik website.  (http://navstik.org/home/how-tos/setting-up-jtag-debugging/). The instructions on installing OpenOCD are complete. Follow the links mentioned in the page and you will have OpenOCD running alongwith required FTDI libraries. I would recommend building OpenOCD from source as given here. After building OpenOCD, test it as given on the navstik webpage
  3. When you are sure that OpenOCD has been installed correctly and is able to identify Navstik boards, move on to installing Codebench for ARM EABI. Using this we will be compiling the navstik code to generate files that OpenOCD can flash onto our board. Download the lite version and install by executing the .bin file. 
/bin/sh ./filename.bin 
where filename will be replaced by the name of the downloaded bin file. An easy to use GUI will help in installing codebench. Just select Typical installation and continue with the next-next ritual. The installer will setup the path for this compiler but you may have to logout and log back in to your user profile in linux. If you get an error saying your system uses /bin/sh as system shell, run the following command in terminal:
sudo dpkg-reconfigure -plow dash

Select 'No' and rerun the .bin file.

Now we are all set to flash our Navstik board. Firstly, navigate to the navstik base code in your terminal and type make. This will invoke the compiler with appropriate flags and you will obtain several files in a new folder named build. Next, we need to configure IvyGS.cfg file to include the commands to program our board. For this, we create a tiny routine and place it anywhere in the IvyGS.cfg file.

proc program_device () {
flash write_image erase navstik.hex 0 ihex
reset run
shutdown
}
Note that there is a space between program_device and the brackets ().
Now, at the end of IvyGS.cfg file add these lines:
init
reset init
program_device ()
Copy the navstik.hex file from the build folder to the navstik base code folder containing the IvyGS.cfg file if you want to use the above routine as it is. Run OpenOCD again in the same way as you did during the test:
sudo openocd -f IvyGS.cfg
Congratulations! You have flashed your navstik board. Now it is time to write your own code and upload it. It is recommended that you fiddle with the main.c code in the src folder to start with and understand the different functions that navstik base code provides. Once you are done with writing your own code you just need to compile your code using make and upload it on the board by running OpenOCD.