Eclipse is a powerful IDE, though it's primary use is for the development of Java applications it's various plugins allow it to find use in many areas, including C development. This page will describe the process by which you can get eclipse setup for developing with Nano-RK.
- Install Eclipse *
First things first you should head on over to http://www.eclipse.org and get the latest version of eclipse.
If you are using linux it can be installed via the package manager.
- Install Eclipse CDT *
Once more if you are using eclipse you can install the CDT plugin via the package manager, however if you aren't it can be installed via the software update system in eclipse. More extensive instructions can be found at http://www.eclipse.org/cdt/.
- Get the current revision of Nano-RK *
Users can checkout a development copy of the code from subversion by typing:
svn checkout svn://nanork.org/srv/svn/repos/nano-RK
or go to our releases page for code snapshots. Make note of where you are putting this, as it will become relevant later.
- Create a NANO_HOME environment variable *
In order for builds and so forth to work nicely in eclipse, we need an environment variable that points to the location where you have checked out nano-RK. The process is quite simple, add the following lines to your .bash_login (or google adding environment variables for your particular shell).
NANO_HOME=<Path to Nano-RK> export NANO_HOME
You will have to re-open your shell for this to take effect, you can verify that you've done this properly with the following command:
Which should print the location of your nano-rk working copy.
- Creating a new project *
Create a new C project in eclipse using the new project wizard.
Select the project type as an empty makefile project, this should leave you with an empty folder looking something like:
- Makefile and nrk_cfg.h *
Create a make file (called makefile) in the root of your project and copy in the following:
# Platform name cc2420DK, firefly, micaZ, firefly2_1, firefly2_2, firefly2_3 PLATFORM = micaZ # Target file name (without extension). TARGET = main # Set the Port that you programmer is connected to PROGRAMMING_PORT = /dev/ttyUSB0 # PROGRAMMING_PORT = @ls /dev/tty.* | grep usb | head -n 1@ # programmer connected to serial device # Set platform specific defines # The following will be defined based on the PLATFORM variable: # PROG_TYPE (e.g. avrdude, or uisp) # MCU (e.g. atmega32, atmega128, atmega1281) # RADIO (e.g. cc2420) include $(NANO_HOME)/include/platform.mk ROOT_DIR - $(NANO_HOME) SRC = $(TARGET).c # Add extra source files. # For example: # SRC += $(ROOT_DIR)/src/platform/$(PLATFORM_TYPE)/source/my_src1.c # SRC += $(ROOT_DIR)/src/platform/$(PLATFORM_TYPE)/source/my_src2.c # Add extra includes files. # For example: # EXTRAINCDIRS += $(NANO_HOME)/src/platform/include EXTRAINCDIRS = # This is where the final compile and download happens include $(ROOT_DIR)/include/platform/$(PLATFORM)/common.mk
Create a nrk_cfg.h file with the following:
/*************************************************************** * [[NanoRK]] CONFIG * ***************************************************************/ #ifndef +nrk_cfg_h #define +nrk_cfg_h // NRK_REPORT_ERRORS will cause the kernel to print out information about // missed deadlines or reserve violations #define NRK_LOG_ERRORS #define NRK_ERROR_EEPROM_INDEX 0x200 #define NRK_REPORT_ERRORS // NRK_HALT_ON_ERRORS will cause the kernel to freeze on errors so that // it is easier to see debugging messages. //#define NRK_HALT_AND_LOOP_ON_ERROR //#define NRK_HALT_ON_ERROR #define IGNORE_BROWN_OUT_ERROR #define IGNORE_EXT_RST_ERROR // Disable a few common errors when connected to programmer //#define IGNORE_EXT_RST_ERROR //#define IGNORE_BROWN_OUT_ERROR // Enable the watchdog as a protective measure // This will only activate if the scheduler fails. #define NRK_WATCHDOG #define NRK_REBOOT_ON_ERROR //#define NRK_SOFT_REBOOT_ON_ERROR #define NRK_STATS_TRACKER #define NRK_SW_WDT #define NRK_MAX_SW_WDT 3 // If you want to disable the looping kernel error message when the system // halts, then include the following define. This will automatically // halt the error as well. //#define NRK_HALT_ON_ERROR // NRK_STACK_CHECK adds a little check to see if the bottom of the stack // has been over written on all suspend calls #define NRK_STACK_CHECK //#define KERNEL_STK_ARRAY // Leave NRK_NO_POWER_DOWN define in if the target can not wake up from sleep // because it has no asynchronously clocked // #define NRK_NO_POWER_DOWN // Max number of tasks in your application // Be sure to include the idle task // Making this the correct size will save on BSS memory which // is both RAM and ROM... #define NRK_MAX_TASKS 5 #define NRK_TASK_IDLE_STK_SIZE 128 // Idle task stack size min=32 #define NRK_APP_STACKSIZE 128 #define NRK_KERNEL_STACKSIZE 128 #define NRK_MAX_RESOURCE_CNT 1 #endif
- main.c *
Write what ever code you need in a file called main.c. (Presumably as your project increases in complexity you will use additional files, I will leave that to you).
- Make Targets *
By default clicking the build default button will run the make file without any arguments, however we want to be able to run both 'make clean' and 'make program' this can be done by simply adding two make targets in the make target panel.
If you've followed all of the steps correctly you should be able to see the same effects as running make, make clean, and make program from the console, but now you will be able to leverage the refactoring / syntax highlighting / awesomeness capabilities of eclipse.
Screenshot of the working IDE.