Developing for AVR with NetBeans? Easy as 1-2-3!
Please if you are a Vim or Emacs user don't hit me.. :-)
The following is done on Debian Etch but you can do approximatively the same things on Windows or *BSD.
Why use Netbeans ?
- Multiplatform
- In my opinion easier than Eclipse
- Mobility pack with flow design is so.. so.. hhm.. hu... sorry..
- Powerful completion
- Powerful & easy folding
- Powerful & easy Ethernut Makefile integration
- Beautiful syntax highlight
- And all the rest !...
So first, install Netbeans and C/C++ pack on your computer, refer to : http://www.netbeans.org/
Prepare a dir where Netbeans will find the Makefile, call it proj1 :
$ mkdir *your build dir*/proj1
Copy the simple Makefile from the ethernut demo programs on your new dir :
$ cp simple/Makefile *your build dir*/proj1/
Note that it's very important to have your project on the same dir that all the demo programs. On my computer my build dir is called nutapp and is on ethernut-4.2.1 dir.
Modify this Makefile :
$ vim proj1/Makefile ... PROJ = proj1 ...
Be sure that your Makefile look like :
PROJ = proj1 include ../Makedefs SRCS = $(PROJ).c OBJS = $(SRCS:.c=.o) LIBS = $(LIBDIR)/nutinit.o -lnutos -lnutarch -lnutdev -lnutcrt $(ADDLIBS) TARG = $(PROJ).hex all: $(OBJS) $(TARG) $(ITARG) $(DTARG) include ../Makerules clean: rm -rf $(OBJS) rm -rf $(TARG) $(ITARG) $(DTARG) rm -rf $(PROJ).eep rm -rf $(PROJ).obj rm -rf $(PROJ).map rm -rf $(PROJ).dbg rm -rf $(PROJ).cof rm -rf $(PROJ).mp rm -rf $(SRCS:.c=.lst) rm -rf $(SRCS:.c=.bak) rm -rf $(SRCS:.c=.i)
Now open Netbeans, clic on File -> New Project
Select C/C++ project -> C/C++ project from existing code
Now, on the new window, field "Existing Makefile" select where is your Makefile, then -> Next
A new window appear, and in the field include dir add ethernut-4.2.1/nut/include/ and ethernut-4.2.1/nut/dev/
-> Next -> Finish
Add a new .c file, call it proj1.c :
// Jfguchens - Public Domain source #include <stdio.h> #include <string.h> #include <io.h> #include <dev/board.h> int main(void) { FILE *Uart; u_long Baudrate = 115200; /* * Register Serial device */ NutRegisterDevice(&DEV_UART,0,0); /* * Open device in read/write */ Uart = fopen(DEV_UART_NAME, "r+"); /* * Set Baudrate */ _ioctl(_fileno(Uart), UART_SETSPEED, &Baudrate); for(;;) { /* wait for space character */ while(getc(Uart) != 0x20); fputs("Hello NetBeans world !\n", Uart); } }
You can now build your project and burn it to your flash. Then plug a serial cable from your card to your computer, open minicom with 115200 baudrate, switch on your card, press space and Enjoy !
--jfg 09:17, 16 April 2007 (UTC)