Practical Tips: specific implementation of Gdbserver remote debugging

Source: Internet
Author: User
Article Title: Practical Tips: specific implementation of Gdbserver remote debugging. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The nfs target board is used to mount the local directory. First of all, you must activate the local nfs sharing service. The specific steps are as follows:

1. Go to the/etc directory, and add/home 192.168.0. * (rw, sync) to the vim exports file. Save the file and exit.

Note:/home is the name of the folder to be shared, 192.168.0. * This is the ip address of the client that is allowed to access the NFS server. If nfs fails, the Operation permission on the folder is indicated by the rw ro parameter. sync: data is synchronized to the memory and hard disk. You can also use async, at this time, the data is saved in the memory, instead of immediately written to the hard disk. You can remove the sync in the brackets.

2. restart the nfs service. The command is/sbin/service nfs restart.

3. Enter the command route del default to close the gateway (accelerate the mount speed)

4. mount 192.168.0.47 (the ip address of the Local Machine):/home/mnt is used to test whether the local machine has activated the nfs service.

In the cd/mnt directory, check whether the content in mnt is consistent with that in home. If the content is consistent, the nfs service has been activated.

When the nfs service of the local machine is activated, you also need to configure the IP address of the Development Board. Because the IP address of each development board is configured differently, assume that the IP address of the Development Board is 192.168.2.100.

To build a cross-compilation environment:

1. Generally, the c compiling environment is automatically installed when linux is installed. Therefore, you do not need to reinstall the gcc compiler.

2. Install the Cross Compiler

From linux.org. uk/pub/armlinux/toolchain/"> ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/download the cross-3.2.tar.bz2, which is stored in the/usr/local directory.

Switch to this directory:

# Cd/usr/local

# Mkdir arm

Then decompress cross-3.2.tar.bz2:

# Tar jxvf cross-3.2.tar.bz2? C/usr/local/arm

Decompress the package and copy the last arm in/usr/local/arm to/usr/local, that is, run the command cd/usr/local/arm/usr/local to copy the arm to/usr/local using cp-a arm/usr/local.

3. Add the PATH of the cross compiler to PATH. (two methods: a and B)

A, # export PATH = $ PATH:/usr/local/arm/bin

Note: (this is only valid under the current terminal ,)

B. Modify the/etc/profile file:

# Vim/etc/profile

Add the path settings as follows:

Export PATH = $ PATH:/usr/local/arm/bin

4. Make the new environment variable take effect.

# Source/etc/profile

5. Check whether the PATH is added to the PATH.

# Echo $ PATH

If/usr/local/arm/bin is displayed, the PATH of the cross compiler has been added to PATH. Since then, the cross compilation environment has been installed.

6. Test.

Let's test a simple example.

/* Hello. c */

# Include

Int main ()

{

Printf ("hello word! \ N ");

Return 0;

}

After the program is lost, confirm it is correct and save it. Enter the directory where the program file is located

# Arm-linux-gcc hello. c? O hello

(-O can be understood as "Generate as the target") arm-linux-gcc is the first time, and someone may ask where to come from, open the installed cross-compilation tool directory/usr/local/arm-linux/bin/and you will find an arm-linux-gcc file in it, this is the gcc compiler for arm CPU. In the future, you can use other compilation tool chain to see what the compiler is. After compilation, you can download it to the target machine for testing. Of course, you can test the correctness on a PC first. Using gcc hello. c? O hello, you can generate a program on the PC and run it. /Hello, you can find that the terminal displays hello! . A program compiled with arm-linux-gcc cannot run on a PC. After running the program, an error report is provided: the binary file cannot be executed. It indicates that the files compiled in the Cross-compilation environment are binary code files that can be executed by hardware.

[1] [2] Next page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.