Embedded Freaks..

December 16, 2008

Setting Netbeans for Embedded Linux Application Development

Filed under: embedded-linux, embedded-tips — Tags: , — kunilkuda @ 6:57 pm

I’m using Netbeans as my IDE to build embedded linux application. Here’s the small guide to setup your Netbeans for cross compiler IDE.

Setup The Toolchain

I’m using CodeSourcery GCC toolchain for my TS-7260 ARM9 board. Download their lite toolchain package, and install it somewhere in your system. For me, I installed it into $HOME/CodeSourcery. It doesn’t matter where you put it, as long you can remember its place.

Setup The Netbeans

I’m using the new Netbeans 6.5. Download and install it (anywhere you like). Then run it. Open Tools->Options->C/C++.

netbeans_c_option

On your left pane, there’s Tool Collection pane. Click add..Fill the Base Directory field with the directory where you put the CodeSourcery (until bin/ directory). Fill the Tool Collection Name with the name of the toolchain (I named it CodeSourcery_ARM_Toolchain, but you can choose anything that you like).

add_new_toolAfter that, fill up the C/C+/GDB compiler path (eg. take a look at the 1st picture).

Ok that’s it. Now your Netbeans can be used as IDE for CodeSourcery’s cross compiler.

Testing Your Setup

Create new C/C++ project: File ->New Project->C/C++->C/C++ Application. Let’s name our test project as ts_hello, and leave everything (except for the name) as default. Once the project is created, modify its properties: Right click the project name on Project View->Properties.

project_prop_cross_compileGoto Build->Tool Collection, and select the cross toolchain.

Then, goto the C Compiler->Additional options. This is where you inform the compiler what kind of target architecture that you want. For TS-72xx, add “-march=armv4t -static“. For TS-78xx, add “-march=armv5t -static“.

That’s it. The project is now configured for ARM920T target.

Now, for the infamous hello world program, add new C files on the project, and type:

#include
#include

/*
* Hello world for TS-7260 with Netbeans 6.5
*/
int main(int argc, char** argv) {
printf("Hello Worldn");
return (EXIT_SUCCESS);
}

Remember this carefully, you are cross-compiling. You cannot run the binary on your host (ie. on your PC). What you can do is build the binary, put it inside the ARM’s root filesystem, and run it from your board. So, goto Run->Clean and Build Main Project to compile the program.

If everything is okay, copy the ts_hello executable file into your root fs (I’m using NFS, so I just need to copy it locally). Like this:


# sudo cp dist/Debug/CodeSourcery_ARM_Toolchain-Linux-x86/ts_hello /nfs/tmp/mnt/root/

Then boot your board, and run your hello world with:


# ./root/ts_hello

6 Comments »

  1. Hi,

    Do you use NetBeans to debug embedded applications?

    Comment by Daniil — February 19, 2009 @ 5:53 pm

  2. Hi Daniil,

    Currently my debugging portion consist of printk/printf, so no need for GDB (or cross GDB) under Netbeans yet..Maybe someday I’ll need it, and repost on this blog.

    Comment by kunilkuda — February 20, 2009 @ 6:05 pm

  3. Unfortunatlly,
    NetBeans isn’t the only IDE you need.
    Also you need AvrStudio or eclipse or IAR for debugging 🙂
    I found that NetBeans isn’t suted to debug using arm-elf-gdb for example.

    Comment by Daniil — March 6, 2009 @ 4:44 pm

  4. I’m trying to debug lpc2138 program with arm-elf-gdb. I know how to use eclipse, but what with NetBeans? Is it sutable for debugging? If not sutable – why?

    Comment by Vitaliy — March 26, 2009 @ 5:20 pm

  5. Sorry..I haven’t gone that far. Probably in the next 2 months I’ll find it out.

    Comment by kunilkuda — March 30, 2009 @ 10:26 am

  6. It should be possible to debug via GNU GDB using NetBeans now. NetBeans has had GNU GDB support since version 6.7 onwards.

    Comment by Nick — October 11, 2009 @ 5:32 am


RSS feed for comments on this post. TrackBack URI

Leave a comment