QT远程调试fl2440的配置

前提要求

  1. 开发板上要有SSHD服务,可以从PC端使用SSH登录,(dropbear是一个轻量型的SSH。可以尝试下)。
    • 主要作用是把编译好的程序发送到远程设备上执行
  2. 开发板上要有gdb server 7.0 以上,PC上有gdb 7.5以上带PYTHON
    • 主要作用是用来调试程序

SSH的移植

参考我上篇SSH移植文章
移植后就可以一键远程发送运行程序了,可参看下面的“运行调试程序一节”

最近换了个文件系统重新弄QT居然出下面的错误了

SSH connection failure: SSH Protocol error: Host key of machine "192.168.10.110" has changed.

说是我开发板的密钥对更改了,我重新删除了~/.ssh/known_hosts里的内容,在terminal连接更新后,终端是能登录了,可QT还是出这个错,无语了,怎么弄都错,后来没办法,用终端ssh时会出现条错误信息:

sign_and_send_pubkey: signing failed: agent refused operation

在PC机上先删除所有./ssh/id*密钥对,然后依次使用 ssh-add -D —> ssh-add (不删除id*好像不能ssh-add,不知道为什么),然后ssh-keygen重新生成密钥对,这会再次ssh-add也没错了,先在开发板上设置个密码,使用ssh-cpy-id root@ip将PC上的密钥发布给开发板。将qt里的DEVICE设备全删了,重新新建个居然OK了,自己都不知道怎么就行了。

GDB的移植

查看qt说明:Supported GDB Versions

Starting with version 3.1, Qt Creator requires the Python scripting extension. GDB builds without Python scripting are not supported anymore and will not work.
The minimum supported version is GDB 7.5 using Python version 2.7, or 3.3, or newer.
For remote debugging using GDB and GDB server, the minimum supported version of GDB server on the target device is 7.0.

  • 本地最低版本要7.5并且带Python的,如果不支持python不能正常调试,而远程调试使用的gdb server版本最少要7.0

  • 由于调试时gdb运行在PC上,gdb server运行在开发板上,调试的程序是作为 gdb server的子程序运行的,gdb对gdb server发调试命令控制被调试程序的运行,所以这里说的gdb的移植包括gdb 在PC平台的编译 和 gdb server移植到ARM板上。

A. gdb编译

1. 下载:

查看PC机上的版本,下载能用的最好与你PC上的gcc一致的版本
下载地址

2. 配置:
tar -xf gdb-7.11.tar.xz
cd gdb-7.11/
./configure --target=arm-linux --with-python
3. 编译安装
anzyelay@ubuntu:gdb-7.11$ make
anzyelay@ubuntu:gdb-7.11$ sudo make install
anzyelay@ubuntu:gdb-7.11$ ls /usr/local/bin/
arm-none-linux-gnueabi-gdb  ccmake  cpack  gcore  gdbserver
arm-none-linux-gnueabi-run  cmake   ctest  gdb

安装后多出了arm-none-linux-gnueabi-gdb和arm-none-linux-gnueabi-run,名字虽然是这样,但这两货可是在PC上运行的。

B. gdb server移植

1. 配置:
anzyelay@ubuntu:gdb-7.11$ cd gdb/gdbserver/
anzyelay@ubuntu:gdb-7.11$ ./configure --host=arm-linux
2. 编译
anzyelay@ubuntu:gdb-7.11$ make
3.安装

将编译出来的gdbserver拷贝到开发板上

anzyelay@ubuntu:gdbserver$ cp gdbserver ~/Desktop/arm/myrootfs/bin/

运行调试程序

远程设备上启动SSHD服务

在开发板上运行sshd

/usr/local/sbin/sshd

添加连接设备

本节参考官方说明文档Qt Creator Manual->Connecting Embedded Linux Devices,
Qt Creator提供了对开发板的远程编译、调试、运行和应用程序的分析,首先需要你安装了交叉编译工具,并在Qt Creator里配置好,如下:

Select Tools > Options > Build & Run > Qt Versions > Add to add the Qt version for the embedded Linux.
Select Tools > Options > Build & Run > Compilers > Add to add the compiler for building the applications.

具体可参考我上篇文章QT creator交叉编译配置。文章介绍了如何添加上述两个配置,而要想远程运行调试,先要把远程设备加入进来,具体如下:

Select Tools > Options > Devices > Add > Generic Linux Device > Start Wizard.

在此处ADD 选择”Generic Linux Device“添加进来,连接的保护有PASSWORD和SSH KEY两种方式,随意选一种(DEVICE上必须先有SSH的支持),然后填写开发板的IP一路点OK之类就行,完成后它会测试下能否连通,成功如下:
这里写图片描述
测试好后在KIT中选择device type
这里写图片描述

一键推送位置

在工程建立时选择交叉编译KIT,或在PROJECT里ADD KIT ,然后 点击到RUN如下图:
这里写图片描述
此时的远程路径是空的。具体设置看参考:
Qt Creator Manual->Deploying Applications to Embedded Linux Devices
这里写图片描述
在工程文件中添加如下两条保存:
target.path = /root //程序传送(deploy)到开发板的目录位置。
INSTALLS += target
这里写图片描述
保存后在看如下图多出来了可执行文件的HOST和DEVICE保存路径,,在参数栏加上qws如下;
这里写图片描述
此时点击运行就能看到程序在开发板上运行了。可以看到调试窗口显示:
这里写图片描述

调试程序

同样的,调试前要先配置,在调试器项里选择我们刚才编译好的gdb如下:
这里写图片描述
在kit里将交叉编译的KIT里的调试器换成我们刚才设置的
这里写图片描述
配置好调试器后,在QT里选择DEBUG
这里写图片描述
然后点击调试就行了
这里写图片描述

erorr

1. qt devices test:SSH connection failure: Server rejected key.

  • 具体错误信息:
    使用密钥验证过不了。

    Connecting to host...
    SSH connection failure: Server rejected key.
    
    Device test failed.
  • 原因及解决方法:
    设置的公钥没有加到开发板的公钥列表里,手动加入即可

    anzyelay@ubuntu:tmp$ ssh-copy-id -i /home/anzyelay/.ssh/qtc_id.pub root@192.168.10.110
    Now try logging into the machine, with "ssh 'root@192.168.10.110'", and check in:
    
      ~/.ssh/authorized_keys
    
    to make sure we haven't added extra keys that you weren't expecting.
    
    anzyelay@ubuntu:tmp$ 
    

2.qt连接错误,SSH Protocol error

  • 具体错误信息:

    Connecting to host...
    SSH connection failure: SSH Protocol error: Server and client capabilities don't match. Client list was: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,ssh-dss.
    Server list was ssh-ed25519.
    
    Device test failed.
  • 原因及解决方法:
    Server和client的通信协议不一致。qt里的使用的SSH是QT自带的不是PC机上的,我服务器只使能了ed25519,修改配置使能ecdsa就可

    HostKey /etc/ssh/ssh_host_ecdsa_key

3.QT无法远程连接到DEVICE上

  • 具体错误信息:
    ssh以经移植好并用command试过是可用的,但在用QT配置devices时TEST过不了。Devices test显示如下:

    Connecting to host...
    SSH connection failure: The remote host closed the connection
    
    Device test failed.
  • 原因及解决方法:
    网上找了很多方法都不对,后来我怀疑是pc上的ssh版本与新编译的arm机上的ssh不兼容,所以干脆再编译个PC机的版本,依然不行。第二天开机再试时OK了,难首要重启???原因未知。。。。

4.configure: error: python is missing or unusable

  • 具体错误信息:

    checking whether to use python... yes
    checking for python... /usr/bin/python
    checking for python2.7... no
    configure: error: python is missing or unusable
    make[1]: *** [configure-gdb] Error 1
    make[1]: Leaving directory `/home/anzyelay/Downloads/gdb-7.11'
    make: *** [all] Error 2
  • 原因及解决方法:
    查看版本是OK的,而PC中也是有python2.7的。

    anzyelay@ubuntu:gdb-7.11$ python -V
    Python 2.7.3

    网上说是缺少 python headers,尝试如下安装了-DEV后OK。

    anzyelay@ubuntu:gdb-7.11$ sudo apt-get install python2.7-dev

5. 如果点击

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值