版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Chapter
4.
Development
Tools2021/8/131****(Linux
shell
command
list)Using
a
Practical
Project
WorkspaceGNU
Cross-Platform
Development
ToolchainC
Library
AlternativesIntegrated
Development
EnvironmentsTerminal
Emulators4.1UsingaPracticalProjectWorkspace2021/8/132Directorybootldrbuild-toolsdebugdocimageskernelprojectrootfssysappstmptoolsContentThe
bootloader
or
bootloaders
for
your
targetThe
packages
and
directories
needed
to
build
the
cross-platformdevelopment
toolchainThe
debugging
tools
and
all
related
packagesAll
the
documentation
you
will
need
for
your
projectThe
binary
images
of
the
bootloader,
the
kernel,
and
the
root
filesystemready
to
be
used
on
the
targetThe
different
kernel
versions
you
are
evaluating
for
your
targetYour
own
source
code
for
this
projectThe
root
filesystem
as
seen
by
the
target's
kernel
at
runtimeThe
system
applications
required
for
your
targetA
temporary
directory
to
experiment
and
store
transient
filesThe
complete
cross-platform
development
toolchain
and
C
librarythe
environment
variables2021/8/133export
PROJECT=daq-moduleexportPRJROOT=/home/karim/controlproject/${PROJECT}export
TARGET=i386-linuxexport
PREFIX=${PRJROOT}/toolsexport
TARGET_PREFIX=${PREFIX}/${TARGET}export
PATH=${PREFIX}/bin:${PATH}$: cd
$PRJROOT4.2
GNU
Cross-PlatformDevelopment
Toolchain2021/8/134GNU
Toolchain
BasicsKernel
Headers
SetupBinutils
SetupBootstrap
Compiler
SetupC
Library
SetupFull
Compiler
SetupFinalizing
the
Toolchain
Setup4.2.1
GNU
Toolchain
Basics2021/8/135Configuring
and
building
an
appropriate
GNUtoolchain
is
a
complex
and
delicate
operationthat
requires
a
good
understanding
of
thedependencies
between
the
different
softwarepackages
and
their
respective
roles.
Thisknowledge
is
required,
because
the
GNUtoolchain
components
are
developed
and
releasedindependently
from
one
another.4.2.1.1
Component
versionsKernelHostI386TargetPPCbinutils
gcc2.10.1
2.95.3glibc2.2.1PatchesNoPPCPPCI386i386i386ARM2.4.1-rmk12.10.1
2.95.32.13.2.
1
3.2.12.10.1
2.95.32.2.32.3.12.1.3NoNoYes[3]PPCI386ARMMIPS2.10.1
2.95.32.8.1 egcs-1.1.22.2.32.0.6Yes[3]Yes[4]I386SuperH2.11.2
3.0.12.2.4Yes[5]Sparc2021/8/136PPC2.4.02.10.1
2.95.22.1.3No4.2.1.2
Build
requirements2021/8/137To
build
a
cross-platform
development
toolchain,
youwill
need
a
functional
native
toolchain.
Mostmainstream
distributions
provide
this
toolchain
aspart
of
their
packages.
If
it
was
not
installed
on
yourworkstation
or
if
you
chose
not
to
install
it
to
savespace,
you
will
need
to
install
it
at
this
point
using
theprocedure
appropriate
to
your
distribution.
With
aRed
Hat
distribution,
for
instance,
you
will
need
toinstall
the
appropriate
RPM
packages.4.2.1.3
Build
overview2021/8/138With
the
appropriate
tools
in
place,
let
us
take
alook
at
the
procedure
used
to
build
the
toolchain.These
are
the
five
main
steps:Kernel
headers
setupBinary
utilities
setup3.Bootstrap
compiler
setupC
library
setupFull
compiler
setup4.2.2
Kernel
Headers
Setup2021/8/139the
first
thing
you
need
to
do
is
download
a
copyof
that
kernel
into
the
directory
**${PRJROOT}/kernel
;
then
extract
it
using
theappropriate
command.
eg.$
tar
xvzf
linux-2.4.18.tar.gz$
tar
xvjf
linux-2.4.18.tar.bz2
;For
all
kernels
up
to
2.4.18,
the
tar
commandcreates
a
directory
called
linux
that
contains
theextracted
files
from
the
archive.Starting
with
2.4.19,
however,
the
kernel
extracts
immediatelyinto
a
directory
that
has
the
version
number
appended
to
its
name.Hence,
Linux
2.4.19
extracts
directly
into
the
linux-2.4.19directory.
This
avoids
accidently
overwriting
an
older
kernel
witha
new
one.
If
you
are
using
a
kernel
that
is
older
than
2.4.19,
Imend
that
you
rename
the
directory
right
away
to
avoid
anyaccidental
overwriting:$
mv
linux
linux-2.4.18With
the
kernel
now
extracted,
we
proceed
to
configuring
it:$
cd
linux-2.4.18$
make
ARCH=i386CROSS_COMPILE=i386-linux-
menuconfigAs
you
probably
noticed,
the
values
of
ARCH
andCROSS_COMPILE
depend
on
your
target's
architecture
type.Had
this
been
a
PPC
target
and
an
i386
host,
we
would
haveusedARCH=ppc
and
CROSS_COMPILE=powerpc-linux-.2021/8/1310Wecan
now
create
the
include
directory
required
for
the
toolchainand
copy
the
kernel
headers
to
it:$
mkdir
-p
${TARGET_PREFIX}/include$
cp
-r
include/linux/
${TARGET_PREFIX}/include$
cp-r
include/asm-i386/
${TARGET_PREFIX}/include/asm$
cp
-r
include/asm-generic/
${TARGET_PREFIX}/includeKeep
in
mind
that
we
are
using
a
PPC
host
and
an
i386
target.Hence,
the
asm-i386
directory
in
the
path
above
is
the
directorycontaining
the
target-specific
headers,
not
the
host-specific
ones.
Ifthis
were
a
PPC
target,
for
example,
we
would
have
to
replaceasm-i386
with
asm-ppc.2021/8/13114.2.3
Binutils
Setup2021/8/1312The
binutils
package
includes
the
utilities
most
oftenused
to
manipulate
binary
object
files.
The
two
mostimportant
utilities
within
the
package
are
the
GNUassembler,
as,
and
the
linker,
ld.
Others like
follow:gasp
:The
GNU
assembler
pre-processorar
:Creates
and
manipulates
archive
contentnm
:Lists
the
symbols
in
an
object
file…size
:Lists
the
sizes
of
sections
within
an
object
fileThe
first
step
in
setting
up
the
binutils
package
is
to
extract
its
source
codefrom
the
archive
we
downloaded
earlier:$
cd
${PRJROOT}/build-tools$
tar
xvzf
binutils-2.10.1.tar.gzThis
will
create
a
directory
called
binutils-2.10.1
with
the
package'scontent.
We
can
now
move
to
the
build
directory
for
the
second
part
of
thebuild
process,
the
configuration
of
the
package
for
cross-platformdevelopment:$
cd
build-binutils$
../binutils-2.10.1/configure
--target=$TARGET--prefix=${PREFIX}2021/8/1313During
its
run,
configure
checks
for
the
availability
of
certainresources
on
the
host
and
creates
appropriate
Makefiles
foreach
tool
in
the
package.
Since
the
command
is
not
beingissued
in
the
directory
containing
the
binutils
source
code,
the
result
of
the
configure
command
will
be
found
in
thedirectory
where
it
was
issued,
the
build-binutils
directory.With
the
Makefiles
now
ready,
we
can
build
the
actualutilities:$
makeWith
the
package
now
built,
we
can
install
the
binutils:$
make
installThe
binutils
have
now
been
installed
inside
the
directorypointed
to
by
PREFIX.
You
can
check
to
see
that
they
havebeen
installed
properly
by
listing
the
appropriate
directory:2021/8/1314$
ls
${PREFIX}/bini386-linux-addr2line
i386-linux-ld2021/8/1315i386-linux-nmi386-linux-readelfi386-linux-sizei386-linux-ari386-linux-asi386-linux-c++filti386-linux-gaspi386-linux-objcopy
i386-linux-stringsi386-linux-objdump
i386-linux-stripi386-linux-ranlibNotice
that
the
name
of
each
utility
is
prepended
by
thevalue
of
TARGET
we
set
earlier.
Had
the
target
been
apowerpc-linux,
for
instance,
the
names
of
the
utilitieswould
have
been
prepended
with
powerpc-linux-.
Whenbuilding
an
application
for
a
target,
we
can
therefore
usethe
appropriate
tools
by
prepending
the
name
of
the
targettype.4.2.4
Bootstrap
Compiler
SetupIncontrasttothebinutilspackage,thegcc
package
containsonlyone
utility,the
GNUcompiler,alongwithsupportcomponents
such
as
runtimelibraries.At
thisstage,
wewill
buildthebootstrapcompiler,whichwillsupportonlythe
Clanguage.Later,once
the
Clibrary
hasbeen
compiled,we
will
pilegccwithfullC++support.2021/8/1316Again,
we
start
by
extracting
the
gcc
package
from
the
archive
wedownloaded
earlier:$
cd
${PRJROOT}/build-tools$
tar
xvzf
gcc-2.95.3.tar.gzThis
will
create
a
directory
called
gcc-2.95.3
with
the
package'scontent.
We
can
now
proceed
to
the
configuration
of
the
build
in
thedirectory
we
had
prepared
for
the
bootstrap
compiler:$
cd
build-boot-gcc$../gcc-2.95.3/configure--target=$TARGET--prefix=${PREFIX}>
--without-headers
--with-newlib
--enable-languages=cThis
will
output
similar
to
that
printed
by
the
binutilsconfiguration
utility
we
discussed
earlier.
Here
too,
configurechecks
for
the
availability
of
resources
and
builds
appropriateMakefiles.2021/8/1317With
the
Makefiles
ready,
we
can
now
build
the
compiler:$
make
all-gccThe
compile
time
for
the
bootstrap
compiler
is
comparableto
that
of
the
binutils.
Here,
too,
you
may
see
warningsduring
the
compilation,
and
you
can
safely
ignore
them.With
the
compilation
complete,
we
can
now
install
gcc:$
make
install-gccThe
bootstrap
compiler
is
now
installed
alongside
thebinutils,
and
you
can
see
it
by
relisting
the
content
of${PREFIX}/bin.
The
name
of
the
compiler,
like
theutilities,
is
prepended
with
the
name
of
the
target
and
iscalled
i386-linux-gcc
in
our
example.2021/8/13184.2.5CLibrarySetup2021/8/1319The
glibc
package
is
made
up
of
a
number
of
libraries
and
isthe
most
delicate
and
lengthy
package
build
in
our
cross-platform
development
toolchain.
It
is
an
extremely
importantsoftware
component
on
which
most,
if
not
all,
applicationsavailable
or
being
developed
for
your
target
will
rely.
Note
thatalthough
the
glibc
package
is
often
called
the
C
library—aconfusion
maintained
within
GNU's
own
documentation—glibc
actually
generates
many
libraries,
one
of
which
is
theactual
C
library,
libc.
We
will
discuss
the
complete
list
oflibraries
generated
by
glibc
in
Chapter
6.
Until
then,
I
willcontinue
to
use
"C
library"
and
"glibc"
interchangeably.20First,
we
must
extract
the
glibc
package
and
its
add-ons,
as
wewould
do
when
setting
up
the
C
library:$
cd
${PRJROOT}/build-tools$
tar
xvzf
glibc-2.3.1.tar.gz$
tar
-xvzf
glibc-linuxthreads-2.3.1.tar.gz
--directory=glibc-2.3.1Next,
we
must
configure
glibc
and
install
its
headers:$mkdir
build-glibc-headers$
cd
build-glibc-headers$
../glibc-2.3.1/configure
--host=$TARGET
--prefix="/usr"
\>
--enable-add-ons
--with-headers=${TARGET_PREFIX}/include$
make
piling=yes
install_root=${TARGET_PREFIX}
\202>1/8p/1r3efix=""
install-headersInstalling
the
headers
is
achieved
by
using
the
install-headersMakefile
target.Next,
we
create
a
dummy
stubs.h
file
required
for
gcc
tobuild
(a
version
of
this
file
will
be
generated
properly
duringthe
installation
of
the piled
glibc):$
mkdir
-p
${TARGET_PREFIX}/include/gnu$
touch
${TARGET_PREFIX}/include/gnu/stubs.hFinally,
we
can
build
the
bootstrap
gcc
compiler:$
cd
${PRJROOT}/build-tools/build-boot-gcc$
../gcc-3.2.1/configure
--target=$TARGET
-->prefix=${PREFIX}
\
--disable-shared
--with->headers=${TARGET_PREFIX}/include
\>
--with-newlib
--enable-languages=c$
make
all-gcc2021/8/13214.2.6
FullCompilerSetup2021/8/1322We
are
now
ready
to
install
the
full
compiler
for
yourtarget
with
both
C
and
C++
support.
Since
we
hadalready
extracted
the
compiler
from
its
archive
inSection
4.2.4,
we
will
not
need
to
repeat
this
step.Overall,
the
build
of
the
full
compiler
is
much
simplerthan
the
build
of
the
bootstrap
compiler.From
the
build-tools/build-gcc
directory
enter:$
cd
${PRJROOT}/build-tools/build-gcc$
../gcc-2.95.3/configure--target=$
TARGET
--prefix=${PREFIX}
\--enable-languages=c,c++$
make
all$
make
install4.2.7
Finalizing
the
Toolchain
Setup2021/8/1323Regardless
of
the
type
of
host
or
the
gcc
version
you
use,
adirectory
similar
to
${PREFIX}/lib/gcc-lib/i386-linux/2.95.3will
be
created
during
the
building
of
the
cross-platformdevelopment
toolchain.
As
you
can
see,
the
directory
path
ismade
up
of
the
target
type
and
the
gcc
version.
Yourparticular
directory
should
be
located
in
${PREFIX}/lib/gcc-lib/${TARGET}/GCC_VERSION,
where
GCC_VERSION
isthe
version
of
gcc
you
are
using
in
your
cross-platformdevelopment
toolchain.4.3CLibraryAlternatives2021/8/1324Given
the
constraints
and
limitations
of
embeddedsystems,
the
size
of
the
standard
GNU
C
librarymakes
it
an
unlikely
candidate
for
use
on
our
target.Instead,
we
need
to
look
for
a
C
library
that
willhave
sufficient
functionality
while
being
relativelysmall.Here
are
the
two
most
important
C
libraryalternatives:
uClibc
and
diet
libc.4.4Integrated
Development
Environments2021/8/1325Many
integrated
development
environments
(IDEs)are
available
for
Linux.
Most
of
these
IDEs
areusually
used
to
develop
native
applications.Nevertheless,
they
can
be
customized
for
cross-development
by
setting
the
appropriate
compilernames
in
the
IDE's
configuration.
Table
4-8
provides
a
list
of
open
source
IDEs,
their
locations,and
the
list
of
embedded
Linux-relevant
programminglanguages
they
support.Table
4-8.
Open
source
IDEs
It
means
free-paymentIDELocationSupportedlanguagesAnjutaAda,
bash,
C,
C++,
Java,
make,
Perl,PythonEclipseC,C++,JavaGlimmerAda,
bash,
C,
C++,
Java,
make,
Perl,Pyt
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 安保前期进驻项目方案(2篇)
- 中国聚酰亚胺薄膜(PI膜)市场行情调研及投资前景深度调研报告2024-2030年
- 关于学纸艺的作文
- 施工现场重大危险源控制目标和管理方法
- 口才训练第七天震撼演讲开场白设计
- 《献给母亲的歌》晚会节目串词礼仪主持
- 陕西省咸阳市2022-2023学年高一年级下册第二次月考化学 含解析
- 汽车电气化热管理系统全球前11强生产商排名及市场份额(by QYResearch)
- 乡村振兴视域下农业绿色发展评价研究
- 重症监护病房(icu)医院感染管理指南课件
- 2023-2024学年重庆市小学语文一年级期末自测试题附参考答案和详细解析
- 2023医院卫生院行风建设长效机制管理制度
- 2023年副主任医师(副高)-急诊医学(副高)考试历年真题拔高带答案必考
- 2023年副主任医师(副高)-肾内科学(副高)考试历年真题荟萃带答案拔高
- 植物侵染性病害的发生与流行及植物病害的诊断
- 绿化养护重点难点分析及解决措施
- 全国气象台站经纬度海拔信息
- 卫生监督协管员考核试卷及答案
- EIM Starter Unit 6 This is delicious单元知识要点
- 维修工绩效考核表
- 2023年山东省德州市中考化学试卷(word解析卷)
评论
0/150
提交评论