Qtcreator remote debugging arm program via SSH

Source: Internet
Author: User
Tags openssl ssh ssh port

Environment:
Qt creator:qtcreator2.7.1
qt:qt4.7.0
ubuntu:12.04
arm-linux-gcc:4.5.1
Openssh-6.6p1
openssl-1.0.1t
zlib:zlib-1.2.11
One: Porting OpenSSH to the embedded Development Board
(1) Create a new directory/home/yangtq/ssh, create a new three below Compressed,source,install;install directory under new Ssh,ssl,zllib
(2) Download the source package to the compressed directory
OpenSSH http://www.openssh.com/portable.html
OpenSSL Http://www.openssl.org/source
Zlib http://www.zlib.net/
(3) Unzip the file to the source directory
Zlib:tar XVF zlib-1.2.11.tar.xz-c/home/yangtq/ssh/source/
Openssl:tar XVF openssl-1.0.1t.tar.gz-c/home/yangtq/ssh/source/
Openssh:tar XVF openssh-6.6p1.tar.gz-c/home/yangtq/ssh/source/
(4) Compiling zlib
4.1:cd/home/yangtq/ssh/source/zlib-1.2.11
./configure–prefix=/home/yangtq/ssh/install/zlib
4.2:vi Makefile
cc=arm-linux-gcc
Ar=arm-linux-ar RC
CPP =ARM-LINUX-GCC-E
ldshared=arm-linux-gcc
4.3:make-j4 && make Install
(5) Compiling OpenSSL
5.1:cd/home/yangtq/ssh/source/openssl-1.0.1t
5.2:./configure–prefix=/home/yangtq/ssh/install/openssl-0.9.8e OS/COMPILER:ARM-LINUX-GCC
5.3:make-j4 && make Install
(6) Compile SSH
6.1:cd/home/yangtq/ssh/source/openssh-6.6p1
6.2:./configure–host=arm-linux–with-libs–with-zlib=/home/yangtq/ssh/install/zlib–with-ssl-dir=/home/yangtq/ssh /install/openssl–disable-etc-default-login CC=ARM-LINUX-GCC Ar=arm-linux-ar
6.3:make
(7) Operation Development Board
(7.1) Make sure the following directory is on the target board, and if not, create a new one:
/usr/local/bin/
/usr/local/sbin/
/usr/local/etc/
/usr/local/libexec/
/var/run/
/var/empty/
(7.2) Copy the following files from the PC to the target board Linux system
In the/HOME/YANGTQ/SSH/SOURCE/OPENSSH-6.6P1 directory of the PC machine
SCP sftp ssh ssh-add ssh-agent ssh-keygen ssh-keyscan Copy to target board/usr/local/bin
moduli ssh_config sshd_config Copy to target board/USR/LOCAL/ETC
Sftp-server ssh-keysign Copy to target board/usr/local/libexec
SSHD Copy to target board/usr/local/sbin/
(7.3) Generate key file
Run in PC/home/yangtq/ssh/source/openssh-6.6p1/directory:
Ssh-keygen-t rsa-f ssh_host_rsa_key-n ""
Ssh-keygen-t dsa-f ssh_host_dsa_key-n ""
Ssh-keygen-t ecdsa-f ssh_host_ecdsa_key-n ""
Ssh-keygen-t ed25519-f ssh_host_ed25519_key-n ""
Copy the generated Ssh_host_*_key 3 files to the/usr/local/etc/directory on the target board
I copied it to the target board after my build and found it useless, so I executed the statement on the target board.
(7.4) Modify the target board passwd file.
Add the following line in the/etc/passwd
Sshd:x:74:74:privilege-separated Ssh:/var/empty/sshd:/sbin/nologin
(7.5) If the target board root user does not use passwd root
(7.6) test
To run on the target board:
/usr/local/sbin/sshd
You can use the PS command to see if SSHD is working
If you are prompted to run a missing dynamic connection library, you can search for the corresponding file on the host, copy it to the target board/lib/directory, and note the creation of a soft connection.
Ok. You can succeed without an accident.
On the host:
SSH root@10.0.0.26 (IP for Development Board)
Then you can enter the root password of the development Board.
The root password is the root of your development Board password, if the previous root does not have a password, need to reset, with passwd root, and then enter the password
Two: Remote deployment program to the Development Board
(1) qtcreator-> tools, options, device configuration as shown below

Host name: The IP address of the Development Board, and the user name and password are the settings of the Development Board. Finally set the play app to see if the connection is successful.
(2) If the device above is configured, you can start the remote debugging server associated to the process at Debug > Start debugging. tab, open the following interface, select the process you want to debug, Qtcreator will automatically call/usr/bin/gdbserver via SSH channel, Gdbserver attach to the process to be debugged (through PID attach to process)

Using this method, we do not need to log into the device, manually call Gdbserver to open the program ...
(3) After the sshd is turned on, no sftp-server service is found. If the SECURE-CRT software in the connection of the following error, although you can also use the terminal, but not transfer files, or very uncomfortable:
Failed to connect SFTP subsystem:remote host could not be sftp-server Installed:java.io.IOException:inputstream is CLO Sed
Problem Analysis: Obviously, this is not found in the SFTP sub-service.
Problem solving: Open/usr/local/etc/sshd_config, find this line:
Subsystem Sftp/usr/libexec/sftp-server
You see the problem. The SFTP sub-service indicated in the configuration file is not our directory, so it is modified to:
Subsystem Sftp/usr/local/libexec/sftp-server
Then kill the sshd, and then start to use Sftp-server.
Three: Remote deployment of the program to the Development Board via SSH
(1) Remote deployment Linux Device Add Open tool option Device Device Configuration tab Add a pass Linu device, here need to enter the device name, host name is (ARM) target Board IP address, SSH port default is 22, username and password is the account you need to login, Of course I recommend login to root, of course, here fill in the root account name of the target board password.

(2) Configure the build kit as shown in Figure Gdbserver

Device type: Select the FRIENDARMYANGTQ configured in the previous step
Compiler: Choose embedded Compiler
Debugger: Select Arm-linux-gdb
QT: Choose embedded QT to
(3) New project
(4) Add a project to a remote deployment
The purpose is to copy the execution file to the target board specified directory
Click on the "Edit" tab on the left to open
Xxx.pro
Project file, add the following code
Target.path =/opt
Installs + = target
The meaning of the above code add the target board file path, add the code and click on the left "project" tab, open the Run "Settings" tab, add remote deployment to the project, click Add, select "Deploy to remote Linux host", configure the device to select the devices added in ①.
(5) configuration items below you can see the target file path you just added, and the target board executable is stored here

(6) Run set –> run, the purpose is to run the program on the target board, and to display the print information locally, so as to achieve remote operation click on "Add" selection in "Remote device is running", parameter options-QWS if the target board has a window program then you need to add it.
(7) in the program set breakpoints, build and then click the Debug button, if normal operation, the results are as follows

You're ready to start debugging.
Reference:
(1) http://www.eeworld.com.cn/mcu/2015/1009/article_22810.html
(2) http://www.cnblogs.com/pied/p/6526969.html
(3) https://wenku.baidu.com/view/3f691962f524ccbff0218430.html

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.