![嵌入式linux系統(tǒng)原理_第1頁](http://file4.renrendoc.com/view/852e00299da4c728b5dea8b487bdd0bb/852e00299da4c728b5dea8b487bdd0bb1.gif)
![嵌入式linux系統(tǒng)原理_第2頁](http://file4.renrendoc.com/view/852e00299da4c728b5dea8b487bdd0bb/852e00299da4c728b5dea8b487bdd0bb2.gif)
![嵌入式linux系統(tǒng)原理_第3頁](http://file4.renrendoc.com/view/852e00299da4c728b5dea8b487bdd0bb/852e00299da4c728b5dea8b487bdd0bb3.gif)
![嵌入式linux系統(tǒng)原理_第4頁](http://file4.renrendoc.com/view/852e00299da4c728b5dea8b487bdd0bb/852e00299da4c728b5dea8b487bdd0bb4.gif)
![嵌入式linux系統(tǒng)原理_第5頁](http://file4.renrendoc.com/view/852e00299da4c728b5dea8b487bdd0bb/852e00299da4c728b5dea8b487bdd0bb5.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年事業(yè)單位合同簽訂風(fēng)險防范與應(yīng)對措施
- 2025年廣州房地產(chǎn)交易合同居間操作流程
- 2025年數(shù)字視頻切換臺項目規(guī)劃申請報告模稿
- 2025年合作經(jīng)營居間投資協(xié)議書
- 2025年專業(yè)知識產(chǎn)權(quán)顧問合同范本
- 2025年債權(quán)轉(zhuǎn)讓合同協(xié)議示范
- 2025年信息技術(shù)咨詢顧問服務(wù)年合同
- 2025年農(nóng)村耕地流轉(zhuǎn)合同樣本
- 2025年住宿生權(quán)益協(xié)議
- 2025年傳統(tǒng)村落保護搬遷安置協(xié)議
- 消防器材與消防設(shè)施的維護與檢查
- 【理特咨詢】2024生成式人工智能GenAI在生物醫(yī)藥大健康行業(yè)應(yīng)用進(jìn)展報告
- 2025年中國中煤能源股份有限公司招聘筆試參考題庫含答案解析
- 2024年度碳陶剎車盤分析報告
- 2025年春新外研版(三起)英語三年級下冊課件 Unit6第1課時Startup
- 2025年1月 浙江首考英語試卷
- 2024建筑用輻射致冷涂料
- 2024版《糖尿病健康宣教》課件
- 2024年遼寧鐵道職業(yè)技術(shù)學(xué)院高職單招(英語/數(shù)學(xué)/語文)筆試歷年參考題庫含答案解析
- 社區(qū)工作者經(jīng)典備考題庫(必背300題)
- 彩色英文書寫紙(共9頁)
評論
0/150
提交評論