您的位置:首页 > 运维架构 > Linux

Embedded Linux学习笔记—TQE9_i.MX6Q LTIB环境配置

2016-04-24 00:00 381 查看
LTIB是FreeScale提供的一种在不同目标平台下用于开发和部署BSP(板级支持包)的开发工具,官方的介绍:http://savannah.nongnu.org/projects/ltib/

TQ官方给出的TQE9内核版本是3.0.35,对应LTIB版本是L3.0.35_4.1.0

首先要准备的有:

Ubuntu 12.04(Server或Desktop版皆可,笔者在虚拟机中虚拟了一个Ubuntu Server,然后在host中ssh登陆)

L3.0.35_4.1.0_130816_source.tar.gz(LTIB源码包),下载地址:https://cache.nxp.com/secured/bsps/L3.0.35_4.1.0_130816_source.tar.gz?__gda__=1461212255_108cda6b7f5b9052caa07c8b9e3b8c6e&fileExt=.gz

L3.0.35_4.1.0_doc.tar.gz(LTIB官方文档包,内有详细步骤说明,可选),下载地址:https://cache.nxp.com/secured/32bit/doc/support_info/L3.0.35_4.1.0_docs.tar.gz?__gda__=1461230000_c448aafd5ae78e9ea0d0f8e6c0d7807c&fileExt=.gz






安装LTIB

解压源码包

tar zxvf L3.0.35_4.1.0_130816_source.tar.gz

安装LTIB,自行选择安装目录,笔者选择为 ~/EmbeddedLinux/L3.0.35_4.10

cd L3.0.35_4.1.0_130816_source
./install


编译LTIB

配置依赖环境

#!/bin/bash
# Install packages needed by LTIB
sudo aptitude -y install gettext libgtk2.0-dev rpm bison m4 libfreetype6-dev
sudo aptitude -y install libdbus-glib-1-dev liborbit2-dev intltool
sudo aptitude -y install ccache ncurses-dev zlib1g zlib1g-dev gcc g++ libtool
sudo aptitude -y install uuid-dev liblzo2-dev
sudo aptitude -y install tcl dpkg
sudo aptitude -y install asciidoc texlive-latex-base texinfo dblatex xutils-dev

# Packages required for 64-bit Ubuntu
# Do "uname -a" and see if the word "x86_64" shows up.
if uname -a|grep -sq 'x86_64'; then
sudo aptitude -y install ia32-libs libc6-dev-i386 lib32z1
fi

将上述代码保存为sh脚本,chmod加权限755运行即可

接下来安装官方提供的补丁

首先进入ltib文件夹

cd ~/EmbeddedLinux/L3.0.35_4.10/ltib

补丁文件代码

#!/usr/bin/env bash

# get the patch tarball and untar it
wget -O ubuntu-ltib-patch.tgz https://community.freescale.com/servlet/JiveServlet/downloadBody/93454 7fe8
-102-3-2834/ubuntu-ltib-patch.tgz
tar -xzvf ubuntu-ltib-patch.tgz

# execute the script which do the patching
ltibDir=`pwd`
cd ubuntu-ltib-patch
./install-patches.sh $ltibDir

将上述代码保存为sh脚本,chmod加权限755运行即可

添加sudo

sudo visudo

在文件末尾添加

username ALL = NOPASSWD: /usr/bin/rpm, /opt/freescale/ltib/usr/bin/rpm

Ctrl+X 保存 退出

检查系统路径/usr/include中是否有sys目录,若无,添加软链接

cd /usr/include
sudo ln -s i386-linux-gnu/sys sys

切换道LTIB安装目录,开始编译

cd ~/EmbeddedLinux/L3.0.35_4.10/ltib
./ltib


编译成功后会弹出mkconfig界面

第一个界面选择

Platform choice (Freescale iMX reference boards)  --->

第二个界面选择

Selection (imx6q)  --->

第三个界面选择

board (mx6q_sabresd)  --->

保存退出后自动开始编译u-boot,kernel等,成功后打印

Build Succeeded


编译过程中可能出现的问题

elftosb

/opt/freescale/ltib/usr/src/rpm/BUILD/elftosb-3.0.35-4.0.0/common/stdafx.h:30:36: fatal error: /usr/include/sys/types.h: No such file or directory
compilation terminated.
make[1]: *** [AESKey.o] Error 1
make[1]: Leaving directory `/opt/freescale/ltib/usr/src/rpm/BUILD/elftosb-3.0.35-4.0.0/bld/linux'
make: *** [all] Error 2
error: Bad exit status from /home/cody/i.mx6/ltib/tmp/rpm-tmp.77914 (%build)

RPM build errors:
Bad exit status from /home/cody/i.mx6/ltib/tmp/rpm-tmp.77914 (%build)
Build time for elftosb: 1 seconds

Failed building elftosb
Died at ./ltib line 1392.
traceback:
main::build_host_rpms:1392
main::host_checks:1447
main:554

解决

diff -rupN elftosb-11.09.01/common/stdafx.h elftosb-11.09.01-new/common/stdafx.h
--- elftosb-11.09.01/common/stdafx.h	2011-03-01 05:05:19.000000000 +0100
+++ elftosb-11.09.01-new/common/stdafx.h	2013-05-07 06:03:56.399989483 +0200
@@ -27,7 +27,7 @@ // For Linux systems only, types.h only defines the signed
// integer types.  This is not professional code.
// Update: They are defined in the header files in the more recent version of redhat enterprise gcc.-#include "/usr/include/sys/types.h"
+#include <sys/types.h>
#include <stdint.h> //typedef unsigned long uint32_t;
//typedef unsigned short uint16_t;diff -rupN elftosb-11.09.01/stdafx.h elftosb-11.09.01-new/stdafx.h
--- elftosb-11.09.01/stdafx.h	2013-05-07 06:04:25.055987505 +0200
+++ elftosb-11.09.01-new/stdafx.h	2013-05-07 06:03:23.671990775 +0200
@@ -27,7 +27,7 @@ // For Linux systems only, types.h only defines the signed
// integer types.  This is not professional code.
// Update: They are defined in the header files in the more recent version of redhat enterprise gcc.-#include "/usr/include/sys/types.h"
+#include <sys/types.h> //typedef unsigned long uint32_t;
//typedef unsigned short uint16_t;
//typedef unsigned char uint8_t;

将以上代码保存为:elftosb-types_h-fix.patch,并放在/opt/freescale/pkgs/目录

然后

nano ~/EmbeddedLinux/L3.0.35_4.10/ltib/dist/lfs-5.1/elftosb/elftosb.spec


在相应位置添代码(第3、7行)

..
Source : %{name}-%{version}-%{release}.tar.gz
Patch0 : elftosb-types_h-fix.patch
BuildRoot : %{_tmppath}/%{name}
...
%setup -n %{name}-%{version}-%{release}
%patch0 -p1
%Build
make
...

删除elftosb文件夹

sudo rm -rf /opt/freescale/ltib/usr/src/rpm/BUILD/elftosb-3.0.35-4.0.0


Failed building busybox

/opt/freescale/usr/local/gcc-4.6.2-glibc-2.13-linaro-multilib-2011.12/fsl-linaro-toolchain/bin/../lib/gcc/arm-fsl-linux-gnueabi/4.6.2/../../../../arm-fsl-linux-gnueabi/bin/ld: cannot find /lib/ld-linux.so.3
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
error: Bad exit status from /home/cody/i.mx6/ltib/tmp/rpm-tmp.92805 (%build)

RPM build errors:
Bad exit status from /home/cody/i.mx6/ltib/tmp/rpm-tmp.92805 (%build)
Build time for busybox: 46 seconds

Failed building busybox

NOTE: ltib用一般用户编译,而CROSS_COMPILE的值没传过来,,,,增加一般用户的环境变量或在makefile添加CROSS_COMPILE的值

编辑base_libs.spec文件,注释两行代码

nano ~/EmbeddedLinux/L3.0.35_4.10/ltib/dist/lfs-5.1/base_libs/base_libs.spec


注释

...
perl -w -e '
# @ARGV = grep { `file $_` =~ m,ASCII C program text, } @ARGV;
# exit (0) unless @ARGV;


参考博文

http://blog.csdn.net/girlkoo/article/details/44535979

http://my.oschina.net/mjRao/blog/368215?fromerr=hkWB9k97

http://www.cnblogs.com/openusb/p/3437290.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Embedded Linux TQE9 i.MX6Q LTIB