Beruflich Dokumente
Kultur Dokumente
ab &'##m %(111)
1 +enera!itie"
F#r t$e Lab" in t$i" c#ur"e y#u ,i!! u"e a de"-t#. P/ a" deve!#.ment "y"tem and a /A'ME 0it a" tar*et "y"tem( 1n t$e P/ u"e a recent Linux di"tributi#n !i-e 2ebian "3ueeze #r 4buntu 15(4(
A 2e"-t#. P/ ,it$ a rem#vab!e $ard di"- a" deve!#.ment "y"tem( ##tab!e $ard di"- ,it$ y#ur Linux deve!#.ment "y"tem(
T$e /A'ME 0it $a" &am#n* #t$er") t$e 7#!!#,in* 7eature" A T#radex embedded b#ard ,it$ 8"ca!e .r#ce""#r Mem#ry mana*ement unit I1 Exten"i#n b#ard ,it$ LE2", di. ",itc$e", +PI1 ",itc$e", di*itia! I1" An L/2 2i".!ay T,# "eria! inter7ace" 4A'T0 and 4A'T1 1ne Et$ernet inter7ace &'9-4:, ET;)
6eria! /ab!e t# !in- t$e tar*et "y"tem ,it$ a t$e deve!#.ment "y"tem u"in* "eria! c#mmunicati#n .#rt" /r#""-#ver Et$ernet cab!e bet,een t$e tar*et "y"tem and t$e deve!#.ment "y"tem
5 Ex.erimenta! 6etu.
T$e 7#!!#,in* 7i*ure "$#," t$e ex.erimenta! "etu.( /1M5 cr#""-#ver '65<5 cab!e /1M1 1=5(1>?(5(1 et$1 cr#""-#ver Et$ernet cab!e et$0 LA%@Internet Development System Target System 1=5(1>?(5(100 ET; 4A'T0 4A'T1
Fi*ure 1: 2eve!#.ment 6y"tem and Tar*et 6y"tem T# ma-e t$e "et-u. #.erati#na!, .r#ceed a" 7#!!#," 1( /#nnect t$e 7ir"t "eria! .#rt /1M1 &at t$e b#tt#m #7 t$e bac- .!ane) #n t$e 26 t# t$e 7ir"t "eria! .#rt &4A'T0) #n t$e T6 5( /#nnect t$e #n b#ard Et$ernet ada.ter #n t$e 26 &c$ec- i7 it i" a""i*ned t# eth1) t# t$e #n!y Et$ernet ada.ter eth0 #n t$e T6( <( In"ert t$e rem#vab!e di"- in t$e deve!#.ment "y"tem and b##t t$e Linux "y"tem LA In"tructi#n" F6-501< Pa*e 1
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
LA In"tructi#n"
F6-501<
Pa*e 5
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
t##!c$ain, a r##t 7i!e"y"tem, a -erne! ima*e and a b##t!#ader ima*e( ui!dr##t i" u"e7u! main!y 7#r .e#.!e ,#r-in* ,it$ "ma!! #r embedded "y"tem", u"in* vari#u" /P4 arc$itecture" &x?>, A'M, MIP6, P#,erP/, etc() : it aut#mate" t$e bui!din* .r#ce"" #7 y#ur embedded "y"tem and ea"e" t$e cr#""-c#m.i!ati#n .r#ce""( In t$i" !ab ,e u"e t$e 7ir"t .art #7 bui!dr##t: +enerate a cr#""-c#m.i!ati#n t##! c$ain 7#r t$e A'M .!at7#rm( 6ec#nd, ,e bui!d a "im.!e r##t 7i!e "y"tem( T$e -erne! ima*e, #n t$e #t$er $and, need" t# be .atc$ed 7#r #ur .!at7#rm and ,i!! be .r#vided( Fina!!y, t$e b##t !#ader i" a!ready in"ta!!ed #n y#ur b#ard( F#r t$e cr#""-deve!#.ment "#7t,are t$e 7#!!#,in* direct#ry "tructure i" u"ed: /opt/crosstools +-- arm -> arm-2012.02 (link to the current toolchain) +-- arm-2012.09 +-- arm-linux -> arm-unknown-linux-uclibcgnueabi +-- arm-unknown-linux-uclibcgnueabi +-- bin +-- lib +-- many other sub directories +-- arm-2010.09 (an older tool chain) +-- the same sub structure as above
LA In"tructi#n"
F6-501<
Pa*e <
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
$ make menuconfig Buildroot 2012.02 Configuration
Target Architecture (arm) ---> select arm if nothing selected Target Architecture Variant (generic_arm) ---> must be gen arm Target ABI (EABI) ---> select EABI if nothing is there Build options ---> adopt defaults Toolchain ---> Toolchain menu Kernel Headers (Linux 2.6.35.x kernel headers)-->(select 2.6.35) ... [*] Thread library debugging ... Binutils Version (binutils 2.21) ---> select this ... GCC compiler Version (gcc 4.5.x) ---> select this ... [*] Build/install a shared libgcc? ... [*] Build a gdb server for the target [*] Build a gdb for the host ... [*] Enable MMU support [*] Use software floating point by default [*] Enable large file support Select exit and return to Buildroot configuration Continue in menu: Buildroot 2012.02 Configuration System configuration ---> Set hostname to carme Set baudrate to 38400 --- The following menus are used to build a root file system. You will do that later. Thus, unselect all. Package Selection for the target ---> unselect all Target filesystem options ---> unselect all Bootloaders ---> unselect all Kernel ---> unselect all --Load an Alternate Configuration File Save an Alternate Configuration File Select exit
LA In"tructi#n"
F6-501<
Pa*e 4
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
A#u ,i!! "ee bui!dr##t d#,n!#adin* "#7t,are .ac-a*e" 7r#m t$e Internet and c#m.i!in* t$#"e .ac$a*e"( T$i" ,i!! ta-e "evera! minute"( +ive y#u a brea-( T$e re"u!t #7 t$e ma-e run ,i!! be in direct#ry: output/host/usr/( It may !##- !i-e t$i":
student@~/crosstools/buildroot-2012.02/output/host/usr$ ls -l total 32 lrwxrwxrwx arm-linux -> arm-unknown-linux-uclibcgnueabi drwxr-xr-x 5 student student arm-unknown-linux-uclibcgnueabi drwxr-xr-x 2 student student bin <-- contains utilities drwxr-xr-x 3 student student include drwxr-xr-x 2 student student info drwxr-xr-x 4 student student lib <-- contains libraries drwxr-xr-x 3 student student libexec drwxr-xr-x 4 student student man drwxr-xr-x 11 student student share
B$ere i" t$e A'M cr#"" c#m.i!er &arm-!inux-*cc) E $ cd output $ find . -name arm-linux-gcc ./host/usr/bin/arm-linux-gcc ;ere it i"( Inv#-e it #n t$e c#mmand !ine:
$ ./host/usr/bin/arm-linux-gcc --ver Using built-in specs. COLLECT_GCC=./bin/arm-linux-gcc COLLECT_LTO_WRAPPER=/home/student/labs/buildroot2012.02/output/host/usr/libexec/gcc/arm-unknown-linuxuclibcgnueabi/4.5.3/lto-wrapper Target: arm-unknown-linux-uclibcgnueabi Configured with: /home/student/labs/buildroot-2012.02/output/toolchain/gcc4.5.3/configure --prefix=/home/student/labs/buildroot-2012.02/output/host/usr --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-unknownlinux-uclibcgnueabi --enable-languages=c --withsysroot=/home/student/labs/buildroot-2012.02/output/host/usr/arm-unknownlinux-uclibcgnueabi/sysroot --with-build-timetools=/home/student/labs/buildroot-2012.02/output/host/usr/arm-unknown-linuxuclibcgnueabi/bin --disable-__cxa_atexit --enable-target-optspace --disablelibquadmath --disable-libgomp --with-gnu-ld --disable-libssp --disablemultilib --enable-tls --enable-shared --withgmp=/home/student/labs/buildroot-2012.02/output/host/usr --withmpfr=/home/student/labs/buildroot-2012.02/output/host/usr --withmpc=/home/student/labs/buildroot-2012.02/output/host/usr --disable-nls --enable-threads --disable-decimal-float --with-float=soft --with-abi=aapcslinux --with-pkgversion='Buildroot 2012.02' --withbugurl=http://bugs.buildroot.net/ Thread model: posix gcc version 4.5.3 (Buildroot 2012.02)
I7 y#u *et "#met$in* !i-e t$i" t$atC" 7ine( %#, c#m.i!e a "ma!! .r#*ram( Brite a "ma!! $e!!# .r#*ram &in direct#ry @tm.)
LA In"tructi#n"
F6-501<
Pa*e :
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111) $cat >> /tmp/hello.c #include <stdio.h> int main(void) { printf("hello\n"); return 0; } Ctrl/D
$ ./host/usr/bin/arm-linux-gcc -o /tmp/hello /tmp/hello.c $ file /tmp/hello hello: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped A#u *#t an executab!e 7i!e 7#r t$e A'M .r#ce""#r(
LA In"tructi#n"
F6-501<
Pa*e >
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111) $ arm-linux-gcc -o hello /tmp/hello.c c#mmand "$#u!d *ive t$e "ame re"u!t a" ab#ve(
<(<(> Fa!!bacI7 y#ur cr#""t##! c$ain d#e" n#t ,#r- y#u 7ind mine at t$e 7#!!#,in* !#cati#n: $tt.:@@.ari"(net!ab(b7$(c$@Fmy71@i7410-15@cr#""t##!"-arm-5015(05(tar(bz5 2#,n!#ad t$e 7i!e crosstools-arm.2012.02.tar.bz2 t# t$e /tmp direct#ry( T$en c$an*e t# t$e direct#ry /opt/crosstools and untar t$e tar 7i!e( T$i" ,i!! create and .#.u!ate t$e /opt/crosstools/arm-2012.02 direct#ry( /reate t$e "#7t !in- arm in direct#ry /opt/crosstools( Ada.t t$e PAT; variab!e a" ab#ve and te"t t$e t##!c$ain in t$e "ame ,ay $ arm-linux-gcc -v A#u "$#u!d *et #ut.ut !i-e t$i": Usinsg built-in specs. Target: arm-none-linux-gnueabi, etc, etc Configured with: a lot of directories Thread model: posix gcc version 4.5.3
LA In"tructi#n"
F6-501<
Pa*e 7
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
Add t$e direct#ry tftpboot in /opt/( T$i" i" t$e !#cati#n #7 t$e -erne! ima*e" d#,n!#aded by t$e TFTP c!ient #7 t$e b##t !#ader( T$e name #7 t$e current ima*e t$at i" re3ue"ted by t$e b##t !#ader mu"t be uImage-carme( T$e -erne! tarba!! ab#ve, $#,ever, $a" been c!eaned( T$ere i" n# -erne! ima*e in it but it c#ntain" a .config 7i!e t# rebui!d t$e -erne! ima*e( T$e -erne! bui!d i" c#ntr#!!ed by a Ma-e7i!e in t$e linux-2.6.35.9-CARME direct#ry t$e t#. !eve! ma-e 7i!e, and by Ma-e7i!e" in m#"t "ub"e3uent direct#rie"( Ma-e "ure t$at t$e 7#!!#,in* ma-e variab!e" are "et c#rrect!y in t$e t#. !eve! ma-e 7i!e: A'/; Garm /'166H/1MPILEG eit$er @ab"-.at$-t#-cr#""c#m.i!er #r arm-!inuxI%6TALLHM12HPAT;G@#.t@carme@r##t7" T$e /'166H/1MPILE variab!e ".eci7ie" t$e !#cati#n #7 t$e cr#""-c#m.i!er &arm-!!inux*cc)( A#u $ave t#, #.ti#n": &1) y#u may ".eci7y eit$er t$e ab"#!ute .at$ t# t$e cr#""c#m.i!er, #r &5) y#u may re!y #n t$e PAT; variab!e( T$e 7ir"t #.ti#n i" rec#mmended be cau"e y#u ,i!! u"e t$e -erne! bui!d .r#cedure t# bui!d y#ur #,n -erne! m#du!e" I#ut #7 t$e -erne! "#urce treeJ( T$e -erne! deve!#.er" rec#mmend t# u"e t$e "ame t##!-c$ain 7#r t$e -erne! a" ,e!! a" 7#r -erne! m#du!e"( I7 y#u u"e t$e "ec#nd met$#d it i" .#""ib!e t$at t$e PAT; variab!e ".eci7ie" a di77erent t##!-c$ain( T# .er7#rm t$e -erne! bui!d y#u may ,ant t# u"e t$e 7#!!#,in* c#mmand "e3uence: $make menuconfig and t$en $make uImage(
T$e "ec#nd c#mmand .r#duce" a -erne! ima*e at t$e 7#!!#,in* !#cati#n: /opt/carme/kernel/linux-2.6.35.9-CARME/arch/arm/boot/uImage /#.y &a" r##t) t$e uImage 7i!e t# /opt/tftpboot/uImage-carme-2.6.35.9-CARME-2010.09( %ext, create a "ymb#!ic !in- uImage-carme 7#r t$i" ima*e 7i!e in @#.t@t7t.b##t( Fallback A#u may *et a -erne! ima*e #n t$e !ab "erver at $tt.:@@.ari"(net!ab(b7$(c$@Fmy71@i7410-15@uIma*e-5(>(<:(=-/A'ME 2#,n!#ad t$i" -erne! ima*e t# t$e direct#ry /opt/tftpboot, .er$a." u"e t$e ,*et uti!ity( Lin- t$e 7i!e ,it$ uImage-carme( %#, y#u $ave .#.u!ated t$e direct#rie" /opt/carme/kernel, /opt/tftpboot, and /opt/crosstools/arm-2012.09( B$at remain" i" t$e r##t 7i!e "y"tem(
<(: /reatin* a "im.!e Linux '##t Fi!e 6y"tem 7#r t$e Tar*et Mac$ine &/A'ME)
In "ecti#n <(< y#u #n!y bui!d t$e t##! c$ain, a!t$#u*$ y#u c#u!d $ave d#ne m#re( 'eca!! t$at t$e bui!dr##t "#7t,are #77er" y#u t$e #.ti#n t# create a r##t 7i!e "y"tem inc!udin* a LA In"tructi#n" F6-501< Pa*e ?
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
bu"yb#x( T$e bu"yb#x i" a c#!!ecti#n #7 uti!itie"( %#tice t$at in a P/ 4nix eac$ c#mmand im.!emented a" a "e.arate .r#*ram( %#, it i" time t# bui!d t$e bu"yb#x and t$e r##t 7i!e "y"tem( +# bac- t# t$e ~/somewhere/crosstools/buildroot-2012.02 direct#ry( e7#re y#u c#ntinue ,it$ t$e c#n7i*urati#n ta"-, "ave t$e current .config 7i!e( T$en ty.e $ make menuconfig A#u ,i!! be bac- in t$e ui!dr##t 5015(05 /#n7i*urati#n "creen( /$ec- t$e 7#!!#,in* "ettin*" and .er$a." add m#re( A#u may iterate t$i" .r#ce""( 6e!ect Package Selection for the target ---> *ivin*
[*] BusyBox BusyBox Version (BusyBox 1.19.x) ---> 1.19 is OK (package/busybox/busybox-1.19.x.config) BusyBox configuration file to use? default location is: package/busybox/busybox-1.18.x.config [*] Show packages that are also provided by busybox customize the package selection by the following selections Audio and video libraries and applications ---> nothing Compressors and decompressors ---> take all Debugging, profiling and benchmark ---> nothing Development tools ---> nothing Games ---> nothing Graphic libraries and applications (graphic/text) ---> select the directfb stuff, free fonts etc Hardware handling ---> select hdparm, hwdata, makedevs Interpreter languages and scripting ---> nothing Libraries ---> select Compression and decompression ---> take defaults Crypto ---> select openssl Database ---> nothing Filesystem ---> select libsysfs Graphics ---> select freetype,jpeg,libpng,libungif (defaults) Hardware handling ---> defaults Java scripts ---> nothing Networking ---> Networking -*- libpcap should be selcted (tcpdump) Other ---> nothing Text and terminal handling ---> nothing JSON/XML ---> nothing Miscellaneous ---> default Networking applications ---> select
LA In"tructi#n"
F6-501<
Pa*e =
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
select dropbear, ethtool, netstat-nat, openssh, tcpdump, tinyhttpd Package managers ---> nothing Real-Time ---> nothing Shell and utilities ---> select select bash, dash, file, screen, sudo, which System tools ---> select select all from kmod on Text editors and viewers ---> select ed, less, nano, vim Host utilities ---> nothing Filesystem images ---> select select tar Bootloaders ---> nothing Kernel ---> nothing exit and save the configuration in .config
T$e re"u!t i" a tem.!ate 7#r r##t 7i!e "y"tem in direct#ry ./output/target
student@:~/crosstools/buildroot-2012.02$ total 56 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 3 student student 4096 Feb 28 drwxr-xr-x 6 student student 4096 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 lrwxrwxrwx 1 student student 11 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 2 student student 4096 Mar 16 drwxr-xr-x 3 student student 4096 Mar 16 drwxr-xr-x 6 student student 4096 Mar 16 drwxr-xr-x 4 student student 4096 Mar 16 ls -l ./output/target/ 10:30 21:54 09:55 09:33 10:30 09:45 09:33 09:33 09:33 09:33 10:30 09:33 09:45 09:55 09:55 bin dev etc home lib linuxrc -> bin/busybox mnt opt proc root sbin sys tmp usr var
It !##-" !i-e a Linux r##t 7i!e indeed( A#u a!"# 7ind a tar 7i!e 7#r t$at r##t 7i!e "y"tem in output/images/rootfs.tar( 4ntar it &a" r##t) in direct#ry /opt/carme/rootfs2012.09( T$en "ymb#!ic !in- t$i" direct#ry ,it$ rootfs( T$i" tec$ni3ue a!!#," y#u t# ex.eriment ,it$ di77erent ver"i#n" #7 t$e r##t 7i!e "y"tem( T$e current ver"i#n can be 7#und by t$e "ymb#!ic !in- rootfs( 1ur /A'ME "#7t,are 7#r t$e tar*et "y"tem i" n#, ready( T$e 3ue"ti#n i": 2#e" it b##t #n t$e tar*et "y"temE e7#re y#u can c$ec- t$at, y#u need t# .re.are t$e net,#r- and "#me "ervice" !i-e TFTP, 2;/P, F%6 #n t$e 26(
LA In"tructi#n"
F6-501<
Pa*e 10
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
<(:(1 Fa!!bacA#u may *et a "am.!e r##t 7i!e "y"tem #n t$e !ab "erver at $tt.:@@.ari"(net!ab(b7$(c$@Fmy71@i7410-15@r##t7"-5015(05-v1(tar(bz5 In"ta!! t$e r##t 7i!e in t$i" tar ba!! in t$e direct#ry @#.t@carme *ivin* "ub-direct#ry rootfs-2012.02-v1( T$en !in- t$i" direct#ry "ymb#!ica!!y ,it$ rootfs(
LA In"tructi#n"
F6-501<
Pa*e 11
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
# start services up /etc/init.d/nfs-kernel-server start up /etc/init.d/isc-dhcp-server start # stop services in reverse order down /etc/init.d/isc-dhcp-server stop
d#,n
@etc@init(d@n7"--erne!-"erver "t#.
No l /opt/carme No No
'un t$i" minic#m termina! "#7t,are by ty.in* &a" r##t) $minicom carme
LA In"tructi#n"
F6-501<
Pa*e 15
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
# /etc/exports: the access control list for filesystems # # which may be exported to NFS clients. See exports(5). # # Example for NFSv4: # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt) # /srv/nfs4/homes gss/krb5i(rw,sync) # /opt/carme/rootfs 192.168.2.0/24(rw,no_root_squash, no_subtree_check,sync,fsid=0) 5( 'em#ve t$e %F6 re!ated "ym!in-" 7r#m t$e /etc/rc.?d/ direct#rie"( T$e %F6 "erver need #n!y be "tarted ,$en y#u ,#r- ,it$ t$e tar*et "y"tem( T# ac$ieve t$at y#u may ,ant t# u"e t$e u.@d#,n c#mmand" in t$e /etc/network/interface 7i!e( <( 6ettin* de7au!t" &im.#rtant) T$e /etc/default/portmap 7i!e "$#u!d c#ntain t$e 7#!!#,in* !ine: OPTIONS=-i eth1 T$e 7#!!#,in* "cri.t" may be u"ed t# re"tart b#t$ t$e n7"--erne!-"erver &a!"# "tart" n7"c#mm#n): /etc/init.d/nfs-kernel-server start 'eca!! t$at /opt/carme/rootfs i" a "ymb#!ic !in- t# t$e .r#.er r##t 7i!e "y"tem( I7 y#u ,ant c$an*e t$i" !in- y#u "$#u!d "t#. t$e n7"--erne!-"erver 7ir"t, c$an*e t$e !in-, and re"tart t$e n7"--erne!-"erver( M#untin* t$e ex.#rted /opt/carme/rootfs direct#ry #7 t$e deve!#.ment "y"tem &26) #n t$e r##t direct#ry @ #7 t$e tar*et "y"tem &T6) a!!#," y#u t# deve!#. y#ur "#7t,are any,$ere in y#ur $#me direct#ry tree #n y#ur 26 a" n#n-r##t u"er( At t$e end #7 y#ur deve!#.ment .r#ce"" y#u c#.y t$e executab!e 7i!e&") int# t$e direct#ry &a" r##t) /opt/carme/rootfs/usr/local/bin #n t$e 26( T$en ",itc$ t# t$e minic#m ,ind#,( I7 t$e n7"-m#unt i" c#rrect!y e"tab!i"$ed y#u "im.!y run t$e executab!e 7r#m t$e /usr/local/bin direct#ry #n t$e T6( I7 y#u u"e t$e make uti!ity #n t$e 26, it i" "u**e"ted t# de7ine an install tar*et in t$e Makefile t$at c#ntain" c#mmand" t# c#.y t$e executab!e 7i!e&") int# t$e /opt/carme/rootfs/usr/local/bin direct#ry( In t$i" ca"e, run in t$e 26 c#mmand ,ind#,: make install a" r##t, #r sudo make install a" y#u( ;int: ecau"e t$e %F6 "erver i" #n!y u"e7u! ,$en t$e /A'ME -it i" c#nnected it i" better ,$en y#u "tart t$e %F6 "erver #n!y i7 y#u c#n7i*ure t$e inter7ace eth1( T# c$ec- ,$at direct#rie" t$e %F6 "erver i" ex.#rtin* u"e t$e c#mmand $ sudo showmount --exports localhost
LA In"tructi#n"
F6-501<
Pa*e 1<
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
LA In"tructi#n"
F6-501<
Pa*e 14
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
!#ader i" ca.ab!e t# *et an IP addre"" and t# run t$e b##t .r#t#c#!( In it" current c#n7i*urati#n it d#,n!#ad" t$e Linux -erne! ima*e 7r#m t$e 26( T$u" t$e 26 "y"tem "$#u!d run t$e t7t. "erver( %#rma!!y t$e t7t. "erver i" "tarted by t$e inetd( T$u" c$ec- t,# t$in*": 1( I" t$e .ac-a*e t7t.d in"ta!!edE I7 n#t in"ta!! it( 5( I" t$e 7#!!#,in* !ine .re"ent in t$e /etc/inetd.conf 7i!e: # run this only on machines acting as "boot servers." tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /opt/tftpboot \
T$e TFTP "erver &t7t.d) u"e" t$e direct#ry /opt/tftpboot a" de7au!t direct#ry( Ma-e "ure t$at t$e current -erne! ima*e uImage-carme i" t$ere(
** Unable to use mmc 0:1 for fatload ** Wrong Image Format for bootm command ERROR: can't get kernel image! dm9000 i/o: 0x8000000, id: 0x90000a46 DM9000: running in 32 bit mode MAC: 00:14:2d:00:1a:de operating at 100M full duplex mode BOOTP broadcast 1 *** Unhandled DHCP Option in OFFER/ACK: 19
LA In"tructi#n"
F6-501<
Pa*e 1:
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
*** Unhandled DHCP Option in OFFER/ACK: 2 *** Unhandled DHCP Option in OFFER/ACK: 28 *** Unhandled DHCP Option in OFFER/ACK: 44 *** Unhandled DHCP Option in OFFER/ACK: 45 *** Unhandled DHCP Option in OFFER/ACK: 46 *** Unhandled DHCP Option in OFFER/ACK: 19 *** Unhandled DHCP Option in OFFER/ACK: 2 *** Unhandled DHCP Option in OFFER/ACK: 28 *** Unhandled DHCP Option in OFFER/ACK: 44 *** Unhandled DHCP Option in OFFER/ACK: 45 *** Unhandled DHCP Option in OFFER/ACK: 46 DHCP client bound to address 192.168.2.100 TFTP from server 192.168.2.1; our IP address is 192.168.2.100 Filename 'uImage-carme'. Load address: 0xa1000000 Loading: ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ################################################################# ######################################################### done Bytes transferred = 2620388 (27fbe4 hex) ## Booting kernel from Legacy Image at a1000000 ... Image Name: Linux-3.0.4-CARME Created: 2012-02-16 16:28:40 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2620324 Bytes = 2.5 MB Load Address: a0008000 Entry Point: a0008000 Verifying Checksum ... OK Loading Kernel Image ... OK OK Starting kernel ... Uncompressing Linux... done, booting the kernel. [ 0.000000] Linux version 3.0.4-CARME (student@adv-linux) (gcc version 4.5.1 (Sourcery G++ Lite 2010.09-50) ) #5 PREEMPT Thu F2 [ 0.000000] CPU: XScale-PXA270 [69054117] revision 7 (ARMv5TE), cr=0000397f [ 0.000000] CPU: VIVT data cache, VIVT instruction cache [ 0.000000] Machine: CARME Colibri PXA270 [ 0.000000] Ignoring unrecognised tag 0x54410008 [ 0.000000] Memory policy: ECC disabled, Data cache writeback [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256 [ 0.000000] Kernel command line: root=/dev/nfs ip=:::::eth0: console=ttyS0,38400n8 display=qvga [ 0.000000] PID hash table entries: 256 (order: -2, 1024 bytes) [ 0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes) [ 0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes) [ 0.000000] Memory: 64MB = 64MB total [ 0.000000] Memory: 59988k/59988k available, 5548k reserved, 0K highmem [ 0.000000] Virtual kernel memory layout: [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
LA In"tructi#n"
F6-501<
Pa*e 1>
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
[ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] [ 0.000000] 1321528ms [ 0.000000] [ 0.000627] [ 0.080331] [ 0.080785] [ 0.081019] [ 0.082107] [ 0.091742] [ 0.193404] [ 0.201157] [ 0.202669] [ 0.203845] [ 0.215412] [ 0.216027] [ 0.304044] [ 0.304512] [ 0.305587] bytes) [ 0.305756] [ 0.305862] [ 0.305895] [ 0.305933] [ 0.305998] [ 0.307319] [ 0.308573] [ 0.308647] [ 0.308672] [ 0.308699] [ 0.309287] [ 0.309474] [ 0.322483] [ 0.324378] [ 0.325255] [ 0.327415] [ 0.330442] [ 0.330495] [ 0.330748] [ 1.497421] [ 2.547231] [ 2.576554] [ 2.616591] [ 2.677928] [ 2.708427] [ 2.719151] [ 2.779336] [ 2.795079]
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB) DMA : 0xffc00000 - 0xffe00000 ( 2 MB) vmalloc : 0xc4800000 - 0xe8000000 ( 568 MB) lowmem : 0xc0000000 - 0xc4000000 ( 64 MB) modules : 0xbf000000 - 0xc0000000 ( 16 MB) .init : 0xc0008000 - 0xc0029000 ( 132 kB) .text : 0xc0029000 - 0xc0493eb0 (4524 kB) .data : 0xc0494000 - 0xc04b6be0 ( 139 kB) .bss : 0xc04b6c04 - 0xc04d483c ( 120 kB) Preemptible hierarchical RCU implementation. NR_IRQS:288 nr_irqs:288 288 sched_clock: 32 bits at 3250kHz, resolution 307ns, wraps every Console: colour dummy device 80x30 Calibrating delay loop... 310.88 BogoMIPS (lpj=1554432) pid_max: default: 32768 minimum: 301 Security Framework initialized Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok NET: Registered protocol family 16 bio: create slab <bio-0> at 0 usbcore: registered new interface driver usbfs usbcore: registered new interface driver hub usbcore: registered new device driver usb cfg80211: Calling CRDA to update world regulatory domain Switching to clocksource oscr0 NET: Registered protocol family 2 IP route cache hash table entries: 1024 (order: 0, 4096 bytes) TCP established hash table entries: 2048 (order: 2, 16384 TCP bind hash table entries: 2048 (order: 1, 8192 bytes) TCP: Hash tables configured (established 2048 bind 2048) TCP reno registered UDP hash table entries: 256 (order: 0, 4096 bytes) UDP-Lite hash table entries: 256 (order: 0, 4096 bytes) NET: Registered protocol family 1 RPC: Registered named UNIX socket transport module. RPC: Registered udp transport module. RPC: Registered tcp transport module. RPC: Registered tcp NFSv4.1 backchannel transport module. NetWinder Floating Point Emulator V0.97 (double precision) PMU: registered new PMU device of type 0 Installing knfsd (copyright (C) 1996 okir@monad.swb.de). JFFS2 version 2.2. (NAND) 2001-2006 Red Hat, Inc. JFFS2: default compression mode: priority msgmni has been set to 117 io scheduler noop registered io scheduler deadline registered io scheduler cfq registered (default) pxa2xx-uart.0: ttyS0 at MMIO 0x40100000 (irq = 22) is a FFUART console [ttyS0] enabled pxa2xx-uart.1: ttyS1 at MMIO 0x40200000 (irq = 21) is a BTUART pxa2xx-uart.2: ttyS2 at MMIO 0x40700000 (irq = 20) is a STUART brd: module loaded loop: module loaded nbd: registered device at major 43 Uniform Multi-Platform E-IDE driver ide-gd driver 1.18
LA In"tructi#n"
F6-501<
Pa*e 17
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
[ 2.811073] physmap platform flash device: 02000000 at 00000000 [ 2.829973] physmap-flash.0: Found 2 x16 devices at 0x0 in 32-bit bank. Manufacturer ID 0x000089 Chip ID 0x000018 [ 2.860899] Intel/Sharp Extended Query Table at 0x0031 [ 2.876282] Intel/Sharp Extended Query Table at 0x0031 [ 2.891663] Using buffer write method [ 2.902562] cfi_cmdset_0001: Erase suspend on write enabled [ 2.921527] Using physmap partition information [ 2.935192] Creating 3 MTD partitions on "physmap-flash.0": [ 2.951958] 0x000000000000-0x000000040000 : "Bootloader" [ 2.974930] 0x000000040000-0x000000440000 : "Kernel" [ 2.997371] 0x000000440000-0x000002000000 : "Rootfs" [ 3.020975] Using configured DiskOnChip probe address 0x4000000 [ 3.039353] dm9000 Ethernet Driver, V1.31 [ 3.168145] eth0: dm9000e at c485a000,c485c004 IRQ 210 MAC: 00:14:2d:00:1a:de (chip) [ 3.195944] mousedev: PS/2 mouse device common for all mice [ 3.212880] i2c /dev entries driver [ 3.226649] TCP cubic registered [ 3.236646] NET: Registered protocol family 17 [ 3.250092] NET: Registered protocol family 15 [ 3.263497] lib80211: common routines for IEEE802.11 drivers [ 3.280527] Registering the dns_resolver key type [ 3.294720] XScale iWMMXt coprocessor detected. [ 3.356251] dm9000 dm9000: eth0: link down [ 5.446231] dm9000 dm9000: eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1 [ 5.466819] Sending DHCP requests ., OK [ 5.516175] IP-Config: Got DHCP answer from 192.168.2.1, my address is 192.168.2.100 [ 5.539954] IP-Config: Complete: [ 5.549689] device=eth0, addr=192.168.2.100, mask=255.255.255.0, gw=192.168.2.1, [ 5.572290] host=CARME, domain=carme.develoment.local, nisdomain=(none), [ 5.593804] bootserver=192.168.2.1, rootserver=192.168.2.1, rootpath=/opt/carme/rootfs [ 5.680125] VFS: Mounted root (nfs filesystem) on device 0:13. [ 5.698096] Freeing init memory: 132K INIT: version 2.88 booting mount: mounting / on failed: No such file or directorymount: mounting tmpfs on /dev/shm failed: No such file or directory Starting logging: OK Starting rsyslog daemon: OK Initializing random number generator... done. Starting network... ip: RTNETLINK answers: File exists Starting dropbear sshd: generating rsa key... generating dsa key... OK Generating RSA Key... Generating public/private rsa1 key pair. Your identification has been saved in /etc/ssh_host_key. Your public key has been saved in /etc/ssh_host_key.pub. The key fingerprint is: 6c:b4:79:9c:62:e5:7d:4f:ce:ca:d4:8e:f4:ed:f6:17 The key's randomart image is: +--[RSA1 2048]----+ | | | | | . . |
LA In"tructi#n"
F6-501<
Pa*e 1?
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
| o * o | | S = . . .| | o o . E | | o *| | + =+| | +oO| +-----------------+ Generating RSA Key... Generating public/private rsa key pair. Your identification has been saved in /etc/ssh_host_rsa_key. Your public key has been saved in /etc/ssh_host_rsa_key.pub. The key fingerprint is: 81:4f:f9:d2:c2:e1:e9:d9:1d:16:be:7e:6c:72:4b:4b The key's randomart image is: +--[ RSA 2048]----+ | | | . . | | . = . | | = * . . | | S o + | | . = o o | | o . o.E | | ..o=. | | .=o. | +-----------------+ Generating DSA Key... THIS CAN TAKE A MINUTE OR TWO DEPENDING ON YOUR PROCESSOR! Generating public/private dsa key pair. Your identification has been saved in /etc/ssh_host_dsa_key. Your public key has been saved in /etc/ssh_host_dsa_key.pub. The key fingerprint is: 60:91:68:9c:f8:c6:33:60:01:fd:26:9e:fd:f8:34:03 The key's randomart image is: +--[ DSA 1024]----+ |.o.+ o.. | | = = .. | | . * o | | . O. . | | . *Eo S | | o .. | | o+ | | ...o | | .. | +-----------------+ Generating ECDSA Key... THIS CAN TAKE A MINUTE OR TWO DEPENDING ON YOUR PROCESSOR! Generating public/private ecdsa key pair. Your identification has been saved in /etc/ssh_host_ecdsa_key. Your public key has been saved in /etc/ssh_host_ecdsa_key.pub. The key fingerprint is: 3a:d9:4a:11:3f:8c:56:2b:ca:9d:6c:19:42:1c:7b:f5 The key's randomart image is: +--[ECDSA 256]---+ | . . | | . o . . | | + o . E |
LA In"tructi#n"
F6-501<
Pa*e 1=
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
| . . * . | | . * S | | . * X . | | o @ . | | o o | | . | +-----------------+ Starting sshd: OK Starting tinyhttpd: done INIT: Entering runlevel: 1 Welcome to Buildroot carme login: root
[root@carme ~]# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:14:2D:00:1A:DE inet addr:192.168.2.100 Bcast:192.168.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4255 errors:0 dropped:0 overruns:0 frame:0 TX packets:2172 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:4683004 (4.4 MiB) TX bytes:340404 (332.4 KiB) Interrupt:210 Base address:0xa000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
[root@carme ~]# ping 192.168.2.1 PING 192.168.2.1 (192.168.2.1): 56 data bytes 64 bytes from 192.168.2.1: seq=0 ttl=64 time=0.529 ms 64 bytes from 192.168.2.1: seq=1 ttl=64 time=0.508 ms --- 192.168.2.1 ping statistics --2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 0.508/0.518/0.529 ms [root@carme ~]# ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8): 56 data bytes --- 8.8.8.8 ping statistics --2 packets transmitted, 0 packets received, 100% [root@carme ~]# route -n Kernel IP routing table Destination Gateway Genmask 0.0.0.0 192.168.2.1 0.0.0.0 192.168.2.0 0.0.0.0 255.255.255.0 [root@carme ~]# packet loss Flags Metric Ref UG 0 0 U 0 0 Use Iface 0 eth0 0 eth0
L#* in t$e T6 7r#m t$e minic#m termina! a" u"er r##t( %# .a"",#rd i" re3uired( T$e "u.eru"er i" t$e #n!y u"er #n t$e T6( A#u are in bu"ine"" ,$en t$e c#mmand Ils -l /I #n t$e T6 &in t$e minic#m ,ind#,) and t$e "ame c#mmand in t$e direct#ry /opt/carme/rootfs "$#, t$e "ame 7i!e"(
LA In"tructi#n"
F6-501<
Pa*e 50
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111) B$at can *# ,r#n*E
T$e T6C" b##t me""a*e" are n#t $eard by t$e 26( -D c$ec- t$e net,#r- "ettin*" 2#,n!#adin* #7 t$e -erne! may time #ut( -D "eri#u"( Per$a." t$e net,#r- mana*er "$ut" unex.ected!y d#,n t$e inter7ace eth1( I7 t$e -erne! can be d#,n!#aded, t$e -erne! b##t", but a -erne! .anic i" .r#duced ,$i!e m#untin* t$e r##t 7i!e "y"tem: -D c$ec- i7 t$e tar*et mac$ine i" c#n7i*ured c#rrect!y( Ma-e "ure t$at t$e tar*et "y"tem -n#," ,$ere %F6 "erver i"( T$e #.ti#n nextserver "$#u!d be 192.168.2.1( T$e T6C" r##t 7i!e "y"tem cann#t be m#unted -D c$ec- t$e net,#r-in* c#n7i*urati#n and retry( I7 it 7ai!" m#re t$an t$ree time", t$ere i" a "eri#u" .r#b!em( 6#me device" are mi""in*: !##- at t$e !#* t# 7ind #ut ,$ic$ device"( Find #ut t$e ty.e, min#r and maL#r number #7 t$e device( Brite a "cri.t t# create t$e mi""in* n#de"( Let t$e init .r#ce"" run t$e "cri.t(
LA In"tructi#n"
F6-501<
Pa*e 51
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
baudrate=38400 ipaddr=192.168.2.100 serverip=192.168.2.1 netmask=255.255.255.0 bootfile="uImage26" oldbootCMD=bootm 80000 || dhcp && bootm autoBootMMC=mmcinit;fatload mmc 0 0xA0000000 /carme/autorun.bin && go 0xA0000000 bootLinux=mmcinit;fatload mmc 0 0xA1000000 uImage26 && bootm ethaddr=00:14:2D:00:1B:04 bootargs=root=/dev/nfs ip=:::::eth0: console=ttyS0,38400N8 display=xvga ^ stdout=serial console bit rate stdin=serial check in inittab, line stderr=serial ttyS0::respawn.. -L ttyS0 38400 Environment size: 505/261884 bytes
A#u "ee $ere, am#n* #t$er t$in*", t$at t$e Et$ernet addre"" i" 00:14:2D:00:1B:04(
I2#,n#adJ t$e .r#*ram t# t$e tar*et "y"tem &a" r##t): $sudo cp ./hello /opt/carme/rootfs/usr/local/bin 'un t$e .r#*ram #n t$e tar*et "y"tem: LA In"tructi#n" F6-501< Pa*e 55
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111) $cd /usr/local/bin $./hello hello
Exercise- : Brite a ma-e 7i!e t# bui!d t$e $e!!# ,#r!d .r#*ram( Fir"t, ma-e a "im.!e ma-e 7i!e, t$en ,rite a *eneric ma-e 7i!e( Exercise-!: Lin- t$e $e!!# .r#*ram "tatica!!y a" ,e!! a" dynamica!!y( B$at i" t$e di77erenceE
B$y: may be u"e7u! 7#r rem#te c#n7i*urati#n( A#u "e!ected t$e #.en""$ in "ecti#n <(4 I/reatin* 6im.!e '##t7"J /#n7i*urati#n 7i!e" @etc@""$dHc#n7i* A!!#, r##t !#*in 6.eci7y t$e !#cati#n 7#r t$e -ey" 0ey *enerati#n ,i!! ta-e a !#n* time #n t$e tar*et( +enerate -ey" #n t$e deve!#.ment "y"tem and c#.y it t# t$e .r#.er !#cati#n &"ee ""$dHc#n7i*) Ada.t &"im.!i7y) t$e "tart u. "cri.t in @etc@init(d@6:0""$d L#* in 7r#m a termina! ,ind#, #n t$e 26( Trace t$e 66; tra77ic u"in* tc.dum. #n t$e tar*et "y"tem
/***************************************************************
LA In"tructi#n"
F6-501<
Pa*e 5<
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
* GLOBAL VARIABLES **************************************************************/ static off_t led_reg_ofs=IO_BASE+LED_OFFSET; /*must be page aligned*/ static char *ledAddr = NULL; /*LED IO addr in VM*/ /**************************************************************** * main ***************************************************************/ int main(int argc, char* argv[]) { int fd, i; printf("Blink\n"); /* * Try to open the memory device special file */ if ((fd = open(MEM_DEV, O_RDWR|O_SYNC)) == -1) { perror("at open "); return -1; } /* mmap mem dev to memory region */ ledAddr = mmap(NULL, /* start address */ MAP_LENGTH, /* the IO space */ PROT_READ|PROT_WRITE, /* read and write */ MAP_SHARED, /* share this mapping with all processes */ fd, /* /dev/mem */ led_reg_ofs); /* IO memory region addr */ for (i = 0; i < MAX_LOOPS; i++) { *(volatile unsigned char *) ledAddr = LED_PATTERN; sleep(1); *(volatile unsigned char *) ledAddr = ~LED_PATTERN; sleep(1); } /* cleanup and exit */ *(volatile unsigned char *) ledAddr = 0x0; munmap(ledAddr, MAP_LENGTH); close(fd); return 0; }
ui!d t$e executab!e .r#*ram 7i!e in t$e "ame ,ay a" y#u bui!t t$e $e!!# .r#*ram( B$at $a..en" #n t$e b#ardE 2i"cu"" $#, t$i" .r#*ram d#e" it" ,#r-( E".ecia!!y, 7ind #ut ,$at exact!y t$e "y"tem ca!! mmap() d#e"( B$at i" t$e di77erence in "ize bet,een a "tatica!!y !in-ed and dynamica!!y !in-ed .r#*ramE Ta-e t$i" blink.c a" an exam.!e( Ma-e a *eneric ma-e 7i!e 7#r t$i" blink.c .r#*ram( Extend t$e .r#*ram "# t$at it re.#rt" .eri#dica!!y t$e "tate #7 ",itc$ array L0((L7 in " "in*!e byte i7 t$e ",itc$ re*i"ter #77"et i" e3ua! t# 0x3200(
LA In"tructi#n"
F6-501<
Pa*e 54
I-7410: Advanced Linux, Part Embedded Linux LA In"tructi#n" at t$e TI %et!ab &'##m %(111)
LA In"tructi#n"
F6-501<
Pa*e 5: