4412 development board learning gdb debugging and gdbserver

Because there are a lot of small partners are transferred over from the microcontroller, we are used to JLINK debugger on the microcontroller to change very accustomed to on Linux. Indeed, if we can set breakpoints, step through, watch variables, it really is too cool, then our Linux can do it, the answer is of course yes.      

      In the previous article the gdb debugger has done a brief side story | use gdb debugging a program, but the previous article, we carried on ubuntu application debugging, debugging is not carried out in the ARM board compared to other software development, embedded software debugging tools is limited, I am sure there are a lot of people still use debugging tools most primitive way to print. In this issue we introduce a possible approach to the ARM board debug application code.

The basic idea

      In this way a remote debugging, the target system must include gdbserver program, the host program must be installed gdb. Generally there is a linux release can run gdb, but we can not directly use the release of gdb remote debugging to do, but to get the source code package gdb, make a simple configuration for the arm platform, recompile the corresponding gdb, such armv4.

     Next, we follow the ideas of the Master, together to build this debugging environment. In any ARM board, can be built.

iTOP4412 built environment

Build step

Step One: Download gdb archive

   Download: http: //ftp.gnu.org/gnu/gdb/ here we are gdb-7.8.1.tar.gz download this version.

Step Two: Compile and install gdb

     After the gdb compressed into ubuntu, we extract the generated file into, illustrated as follows:

Generating Makefile, enter the following command: target as the target platform, prefix for the installation path.

/configure -target=arm-none-linux-gnueabi --prefix=/home/arm-linux-gdb/arm-linux-gdb

As shown below:

Compiling gdb, enter make, successful compilation is shown below:

 Install gdb, enter the command make install, for a while we started on ubuntu is this gdb, the installation was successful as shown below:

Into the source code under gdb gdb / gdbserver directory, as shown below:

Generating Makefile, enter the following command: target as the target platform, prefix for the installation path.

./configure -target=arm-none-linux-gnueabi --prefix=/home/arm-linux-gdb/arm-linux-gdbserver

 

 Then execute make command, note that this cross compiler must write an absolute path. As shown below:

make CC=/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-gcc
编译过程中会出现以下错误:

Config.h we open the file in the current path, as shown below:

Comment out approximately 196 rows HAVE_SYS_REG_H the macro definition, as shown below:

Comment out line 116 #include <sys / reg.h> header, as shown below:

Save and exit, then compile again. Successful compilation is shown below:

After compilation, using the installation make install command, generates a folder after installation in the installation path, as shown below:

The third step in the ARM board set up remote debugging environment

     The gdb / gdbserver under gdbserver bin files copied to the development board folder.

Copy done as shown below:

test

Test code:

Compile the test program, compile time to add -g parameter, after the compilation is complete, we test the code on the development board via NFS, and then start the server, enter the following command at the path where the test code, which is 192.168.2.230 of ubuntu IP, 5000 is the port number.

gdbserver 192.168.2.230:5000 ./test

Start successfully as shown below:

 In the test program test directory to start gdb on ubuntu, where we have just started gdb is installed gdb, we enter the following command:

/home/arm-linux-gdb/arm-linux-gdb/bin/arm-none-linux-gnueabi-gdb test

After a successful start as shown below:

Development board connector, enter the following command, 192.168.2.23 is the IP development board, the port number 5000.

target remote 192.168.2.23:5000

After successful connection boards prints the following information, as shown below:

Next, we can use the command on ubuntu to set breakpoints, step through program development board of the

Guess you like

Origin www.cnblogs.com/liyue3/p/12015717.html