Remote Debugging in Eclipse using BeagleBoard

In this post I will show you how to debug remotely in Eclipse.

First you should install “gdb”. On host device (PC you may call) write in terminal:

 sudo apt-get install gdb-multiarch 

When finished, go to your beagleboard console (you can use ssh or serial connection) and install gdb server:

 sudo apt-get install gdbserver 

Now go to eclipse and create a project as desribed in previous post and paste this code. This code flashes the user led for 10 seconds. We will use this code for our example debugging.


//============================================================================
// Name : HelloWorld.cpp
// Author : F. Can Akinci
// Version :
// Copyright : wlbeagleboard.wordpress.com
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdio.h>
#include <unistd.h>
using namespace std;

int main() {

cout << "LED Flash Start"<<endl;

FILE *LEDHandle=NULL;
char *LEDBrightness = "/sys/class/leds/beagleboard::usr0/brightness";

for(int i=0; i<10; i++){

if((LEDHandle = fopen(LEDBrightness,"r+"))!=NULL){
fwrite ("1",sizeof(char), 1, LEDHandle);
fclose(LEDHandle);
}

sleep(1);

if((LEDHandle = fopen(LEDBrightness,"r+"))!=NULL){
fwrite ("0",sizeof(char), 1, LEDHandle);
fclose(LEDHandle);
}

sleep(1);

}

cout << "LED flash end" << endl;
return 0;

}

Go to Run -> Debug Configuration and in Remote Application part, change GDB debugger to “gdb-multiarch”

Screenshot from 2014-08-04 00:13:11

Then in connection tab, type your beagleboard’s static ip address (which is 10.42.0.50 for me) and a random port number(lets take 12345)

Screenshot from 2014-08-04 00:16:25

 

Then, in terminal tab (connected to beagleboard via ssh) in eclipse, write

 sudo gdbserver 10.42.0.1:12345 HelloWorld 

Screenshot from 2014-08-04 00:35:06

In this code 10.42.0.1 is my host pc’s ip adress, you should write your own’s. HelloWorld is the executable files name, you should also check yours and write it there.

Then click debug. If everything works perfect, debug perspective will open. And when you step into first “sleep”, the LED on BB should be on.Screenshot from 2014-08-04 00:29:28

Similarly, when you step into other “sleep”, the LED should turn off. That’s it. If you have any questions, write it in a comment!

About these ads