How to debug remotely with Gdbserver on an arm target board under Windows

Source: Internet
Author: User

因某种需要,要在Windows平台上进行程序开发,目标板是基于Micrel芯片(ARMv4t)做的,上面运行有Linux最小系统,只有最基本的命令,需要在Windows平台上交叉编译能在ARMv4t上运行的目标代码,并且还要能进行远程调试。基于这些需求,初步计划按以下步骤进行:1、先在Windows平台上交叉编译一个简单的C语言程序,并上传到开发板上,能正常运行即可;2、交叉编译gdbserver,并上传到开发板;3、进行远程调试。按上述计划,首先要找一个Windows环境下的交叉编译环境,参考了http://www.veryarm.com/arm-none-linux-gnueabi-gcc 下载了arm-2011.03-41-arm-none-linux-gnueabi.exe Windows安装版(个人感觉在Windows下用安装版比较好,解压版需要设定PATH),安装成功后,用C写了一个简单的Hello,World!,使用如下命令进行编译:

ARM-NONE-LINUX-GNUEABI-GCC Hello.c-o Hello
The target board and the Windows host are connected via Ethernet and serial port, Ethernet is used for uploading files and serial port is used for terminal access. The target board and the Windows host use TFPT for file delivery. There is a TFTP server running on Windows, such as:

Download the compiled Hello program on the Windows host by running the following command on the target board via the serial terminal:
tftp -gr hello 10.32.2.10
Using commandschmod 755 helloThe following error message appears when you execute after adding Execute permissions:
Illegal Instruction
This means that the program can run, but the instructions are not correct, which is probably the reason why the target schema was not specified when cross-compiling on Windows (in Ubuntu, a program that was cross-compiled using the above command can perform normally). In order to solve this problem, first through the serial port terminal to see the target board startup information, understand that the arm chip is the ARMV4T architecture, and then usearm-none-linux-gnueabi-gcc --target-helpLook at the ARM schema types supported by the cross compiler and find that the command can specify the target type through-march=option, so the compile command changes to:
arm-none-linux-gnueabi-gcc -march=armv4t hello.c -o hello -g
The compiled program can run on the target machine! (Good luck)
The first step is complete, then cross-compiling gdbserver. The previously installed Arm-2011.03-41-arm-none-linux-gnueabi.exe contains the Arm-none-linux-gnueabi-gdb.exe command that runs under Windows, and you need to run Gdbserver on the target board for remote debugging. Then on the GDB official website (http://ftp.gnu.org/gnu/gdb) download gdb7.6 code. Suddenly, since Arm-2011.03-41-arm-none-linux-gnueabi.exe contains gdb that executes on Windows, does it also contain gdbserver that run the line on Linux? Enter the installation directory a search, Bingo, sure enough, in the installation directory Codesourcery\sourcery_g++_lite\arm-none-linux-gnueabi\libc\armv4t\usr\bin, good luck. If you put the gdbserver in this directory on the target version, you can run it. The second step is complete (I am sometimes lazy, in the windows will not compile themselves)
The third step is relatively easy, run the command start Gdbserver on the target board:
./gdbserver 10.32.2.80:3333 Hello
The IP in the above command is the target board's own IP address, the port number itself is specified, as long as there is no conflict on the line, the following hello is the debug program containing debugging information. Then run Arm-none-linux-gnueabi-gdb.exe under Windows and after entering the GDB prompt, execute the target remote 20.32.2.80:3333 on the gdbserver of the destination board. Then execute the file hello at the gdb prompt, which is to load the program under Windows, then set the endpoint by the GDB command and then Debug.

How to debug remotely with Gdbserver on an arm target board under Windows

Related Article

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.