文章目录
前言
本教程主要包含QT+ARM环境搭建、TFTP工具使用、ldd命令ARM适配三个部分。解决ARM开发板调试过程中的代码编译、文件传输以及依赖库的检查问题。
1.QT+ARM交叉编译
相关教程详见QT5.9.9+ARM开发环境搭建【详细步骤】,本文不再赘述。
2.ARM板时间检查
由于部分ARM板没有配备电池或长期处于断电状态,导致系统内时间不准确,会导致一些列的问题,因此需要在系统中输入date
命令进行检查;
如果时间不准确的话,可以手动设置时间:
bash
date -s "2024-12-18 12:54:40"
3.网络连接配置
(1)网络连接如下
(2)确保ARM开发板和调试电脑在一个局域网下:
使用ifconfig
查看开发板的IP
查看调试电脑的IP
(3)查看是否能在ARM板上Ping通电脑,如果不能Ping通则需要关闭调试电脑的防火墙
4.TFTP工具使用
(1)下载TFTP工具,可以用来和ARM板传输数据: TFTP工具下载
(2)按照如下步骤配置
(3)可以查看电脑端共享文档的目录有哪些文件
(4)文件传输
例如 :从电脑端获取AAAA.tar.gz
这个文件,下载到ARM板中的/root目录
然后在ARM板系统中,输入如下命令
bash
cd /root/
tftp -g -l AAAA.tar.gz 192.168.1.111
即可完成文件的传输
5.ldd命令的ARM适配
工程需要在用ldd命令查看arm开发板上可执行文件文件需要的动态库缺失情况 但是arm板子上执行ldd命令会提示command not
found,另外arm板子也无法使用apt-get命令,而ldd本质上是一个脚本命令,同时ubuntu系统中有ldd命令,所以只要移植过去即可
(1)在Ubuntu虚拟机中搜索ldd或按照如下步骤查找
bash
cd /usr/bin
find -name ldd
(2)复制到任意位置,然后用文本编辑器打开开始修改:
- 修改第一行
#! /bin/bash
为#! /bin/sh
- 修改
RTLDLIST=" XXXX "
中的内容为你开发板对应的内容,步骤见下
。
(3)查看开发板对应内容方法很简单,首先进入开发板
bash
cd /lib
find -name ld-linux*
就可以找到这个内容了
因此我需要把RTLDLIST="xxxxxxxx"
修改为RTLDLIST="/lib/ld-linux-armhf.so.3"
,然后保存退出即可
编辑之后的ldd文件如下,也可以参考:
bash
#! /bin/sh
# Copyright (C) 1996-2016 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <http://www.gnu.org/licenses/>.
# This is the `ldd' command, which lists what shared libraries are
# used by given dynamically-linked executables. It works by invoking the
# run-time dynamic linker as a command and setting the environment
# variable LD_TRACE_LOADED_OBJECTS to a non-empty value.
# We should be able to find the translation right at the beginning.
TEXTDOMAIN=libc
TEXTDOMAINDIR=/usr/share/locale
RTLDLIST="/lib/ld-linux-armhf.so.3"
warn=
bind_now=
verbose=
while test $# -gt 0; do
case "$1" in
--vers | --versi | --versio | --version)
echo 'ldd (Ubuntu GLIBC 2.23-0ubuntu11.3) 2.23'
printf $"Copyright (C) %s Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
" "2016"
printf $"Written by %s and %s.
" "Roland McGrath" "Ulrich Drepper"
exit 0
;;
--h | --he | --hel | --help)
echo $"Usage: ldd [OPTION]... FILE...
--help print this help and exit
--version print version information and exit
-d, --data-relocs process data relocations
-r, --function-relocs process data and function relocations
-u, --unused print unused direct dependencies
-v, --verbose print all information
"
printf $"For bug reporting instructions, please see:\\n%s.\\n" \
"<https://bugs.launchpad.net/ubuntu/+source/glibc/+bugs>"
exit 0
;;
-d | --d | --da | --dat | --data | --data- | --data-r | --data-re | \
--data-rel | --data-relo | --data-reloc | --data-relocs)
warn=yes
shift
;;
-r | --f | --fu | --fun | --func | --funct | --functi | --functio | \
--function | --function- | --function-r | --function-re | --function-rel | \
--function-relo | --function-reloc | --function-relocs)
warn=yes
bind_now=yes
shift
;;
-v | --verb | --verbo | --verbos | --verbose)
verbose=yes
shift
;;
-u | --u | --un | --unu | --unus | --unuse | --unused)
unused=yes
shift
;;
--v | --ve | --ver)
echo >&2 $"ldd: option \`$1' is ambiguous"
exit 1
;;
--) # Stop option processing.
shift; break
;;
-*)
echo >&2 'ldd:' $"unrecognized option" "\`$1'"
echo >&2 $"Try \`ldd --help' for more information."
exit 1
;;
*)
break
;;
esac
done
nonelf ()
{
# Maybe extra code for non-ELF binaries.
return 1;
}
add_env="LD_TRACE_LOADED_OBJECTS=1 LD_WARN=$warn LD_BIND_NOW=$bind_now"
add_env="$add_env LD_LIBRARY_VERSION=\$verify_out"
add_env="$add_env LD_VERBOSE=$verbose"
if test "$unused" = yes; then
add_env="$add_env LD_DEBUG=\"$LD_DEBUG${LD_DEBUG:+,}unused\""
fi
# The following command substitution is needed to make ldd work in SELinux
# environments where the RTLD might not have permission to write to the
# terminal. The extra "x" character prevents the shell from trimming trailing
# newlines from command substitution results. This function is defined as a
# subshell compound list (using "(...)") to prevent parameter assignments from
# affecting the calling shell execution environment.
try_trace() (
output=$(eval $add_env '"$@"' 2>&1; rc=$?; printf 'x'; exit $rc)
rc=$?
printf '%s' "${output%x}"
return $rc
)
case $# in
0)
echo >&2 'ldd:' $"missing file arguments"
echo >&2 $"Try \`ldd --help' for more information."
exit 1
;;
1)
single_file=t
;;
*)
single_file=f
;;
esac
result=0
for file do
# We don't list the file name when there is only one.
test $single_file = t || echo "${file}:"
case $file in
*/*) :
;;
*) file=./$file
;;
esac
if test ! -e "$file"; then
echo "ldd: ${file}:" $"No such file or directory" >&2
result=1
elif test ! -f "$file"; then
echo "ldd: ${file}:" $"not regular file" >&2
result=1
elif test -r "$file"; then
RTLD=
ret=1
for rtld in ${RTLDLIST}; do
if test -x $rtld; then
dummy=`$rtld 2>&1`
if test $? = 127; then
verify_out=`${rtld} --verify "$file"`
ret=$?
case $ret in
[02]) RTLD=${rtld}; break;;
esac
fi
fi
done
case $ret in
0|2)
try_trace "$RTLD" "$file" || result=1
;;
1)
# This can be a non-ELF binary or no binary at all.
nonelf "$file" || {
echo $" not a dynamic executable"
result=1
}
;;
*)
echo 'ldd:' ${RTLD} $"exited with unknown exit code" "($ret)" >&2
exit 1
;;
esac
else
echo 'ldd:' $"error: you do not have read permission for" "\`$file'" >&2
result=1
fi
done
exit $result
# Local Variables:
# mode:ksh
# End:
(4)将ldd命令拷贝到开发板的 sbin目录下,可使用cp命令
(5)查看一下有没有移植成功 ldd --version
(6)然后就可以在开发板上使用ldd命令了
参考文献
TFTP相关教程也可参考
TFTP软件使用:
https://blog.csdn.net/wkd_007/article/details/129018831
TFTP命令使用:
https://blog.csdn.net/bytxl/article/details/50378496
ldd的ARM适配:
https://blog.csdn.net/qq_41873311/article/details/124759376