Sunday, March 8, 2015

Build and run Nuttx inside Eclipse


In the previous posts I showed how to get started with Nuttx and set up and test simple network features, here I would like to show how to integrate Nuttx building environment with Eclipse.

First of all we need to download Eclipse and, of course JRE (Java Runtime Environment) that is used to run Eclipse.
Please refer to the following links to download all the necessary:

In the specific I used JRE Version 1.8.0_31 end Eclipse Luna SR2.

In order to install Eclipse we just need to unzip and untar the tarball downloaded.
I did it in my home directory:

#cd
#tar zxvf eclipse-cpp-luna-SR2a-linux-gtk.tar.gz

and install JRE:

#cd eclipse/
#tar zxvf jre-8u31-linux-i586.tar.gz
# mv jre1.8.0_31 jre

Let's now move on the top of the home directory
# cd ..
and let's create a simple and convenient text file to launch Eclipse.

Use your preferred text editor and create a text file starteclipse containing:

PATH=/home/user/nuttx_workdir/nuttx-code/misc/buildroot/build_arm/staging_dir/bin:/home/user/nuttx_workdir/nuttx-stellaris/misc/buildroot/build_arm_nofpu/staging_dir/bin:$PATH ./eclipse/eclipse

give execution permission to the file:

#chmod +x starteclipse

and launch it:

#./starteclipse

If everything went right you should see eclipse appearing on your desktop.
We can now import Nuttx building environment in it:
As showed in the screen-shoot below select File->New->Makefile Project with Existing Code 



A wizard will pop up, be sure to fill it with Project Name ad Existing Code Location and press Finish.


Now in the Project explorer you will see the Nuttx project, right-click it and select Properties from the context menu:


Select Environment on the Properties Windows and add a New Environment Variable as showed in the picture: CROSSDEV= arm-elf-, basically we are setting the same environment as we do from command line (see the previous post).

Press OK on the “New Variable” window and OK on the “Properties” window.




We are now ready, we can build Nuttx within Eclipse, just right click the Build in the context Menu

 


You can now “Clean Project” or modify it and “Rebuild Project” in a easy and handy way.

I also found really handy to launch the simulator inside Eclipse; in order to do it, select Run->External Tools->External Tools Configuration...



Here you can instruct Eclipse, to launch Qemu emulating the Stellaris platform and run Nuttx image.
In the Windows that will appear:
  1. select New,
  2. give a Name (e.g. start_qemu_stellaris),
  3. select the location where Qemu has been installed, if you use Xubuntu 14.04 /usr/bin/qemu-system-arm
  4. insert the Qemu parameters we used on the command line in the previous post
  5. click Run


You can now run Qemu just selecting it from Run->External Tools.
In case you have a real target you can use External Tools to run OpenOCD.