Linux TFTP Setup

上一篇 / 下一篇  2009-04-21 15:29:30 / 个人分类:Linux

我的栏目
  • 栏目:Linux

1     Setup Test Environment with TFTP

1.1 General setup about the environment:

Firstly, you should make sure the environment as below:51Testing软件测试网&p O$C$L3Z%Z

1. Setup tftp on server or on your personal PC using tftp tool

0k| tf5m U1S+t+U1Vo.C0

Here is the detail on how to setup tftp on server51Testing软件测试网 [$? P7b W)i2\2W#g

You should plug the upper serial interface (another didn’t work!)

y9]p4wG6l0

 

R5eC3X f,zkl0

 51Testing软件测试网9w]*AS9_kCf

Configure the tftp server

+C4t.s7LBP0

# vi /etc/xinetd.d/tftp

O9o/W,LT:D[8F0

Change thedisable = no51Testing软件测试网+X,gy,OS(Pl

Configure the minicom like below:

&F/^lZmi(|0

# minicom –s

*zV&P5A&IC FG+j0

Then you pressOto configure the Serial Port Setup (you just need to change two of them) as below:

PEs|)`+B6ZOQ'`0R0

Serial Device: /dev/ttyS0

|.i#@6iw0

Bps/Par/Bits: 115200 8N151Testing软件测试网*k,O @'V;y$V U qQ"ft(w

 

C,I-\2]6c^%V0

Get the release package, then you do the actions like below:

bU qz0XP|0

# tar zxvf rootfs.tar.gz

`"M6un/^ t p0o@0Kx0

# mv rootfs /51Testing软件测试网%k ~%sEb+hQ\J-N

           # vi /etc/exports

^wd C3a5\x l0

           Add the contents: /rootfs *(rw,no_root_squash)51Testing软件测试网)aKKG:gL y7Q(r d7J

     # mv zImage /tftpboot51Testing软件测试网CYG1R"O$~#K*Uq yk

     # mv rootdemo.jffs2 /tftpboot

hEIL1r(n^BOsh#X0

 51Testing软件测试网~8Vb%inr

 

p!~~T#b c0Egu0

1.2 Download Redboot

1. Use real view ICE to download redboot

'D!LUU%F0

#The readboot has been setup in MX37 board51Testing软件测试网,Pl%hU[8?]

Use real ice include init_ddr.inc and press go after load completed

1{*k:C&BGi_ d e0

 

2d$C ?4l ?1F(O1]h&y0

2. Do "nand scan -o" under Redboot to force erase the whole 2GB NAND

7k {@8oC*v,\ E0

  flash and re-construct the bad block table.51Testing软件测试网 IO4ma6Dz

# nand scan -o51Testing软件测试网[j ]@6s QDX,T2k,d

 

X}/B.uOx~y*h0

3. Do "romupdate" under Redboot to save it into the NAND. -- This step51Testing软件测试网Z!K8Kb'i"o EUG;L

  is always needed after "nand scan -o" since the "scan" operation51Testing软件测试网5{,w:e9B9@?

  always erase everything including the Redboot itself.51Testing软件测试网4t'y{]2i z$Q'MqFb*A

# romupdate

/^vLq'd0

1.3 Boot up from nand flash

1.     Configure the script. of the MX3751Testing软件测试网)]q7y6uU$^%sC

# fconfig

[:i [u$r(sS+_v0

Then you should make sure the script. like below(and you should make sure theLocal IP addressis our MX37 board IP, theDefault server IP addressis tftp server IP):

#}#W{m E0

"N[P%].A1ID0 

.i L9z|+t&nx0

kobg!Z"h0 

't#E;F VUkR/u0

2. Burn the linux kernel51Testing软件测试网1`(ce,SsW2w

#fis init

2Lz0y;W7y2p0R0

#load -r -b 0x100000 zImage51Testing软件测试网4E$s d&Q lO"Sqw

#fis create -f 0x200000 kernel 

,p0M&p0DPg0

 51Testing软件测试网*A ib bJS4g_H

--Set SW2 1, 4, 5 on to boot from Nand on personality board51Testing软件测试网+I2hh1V3[9Gq

--Set SW2 all off to boot from Nor on personality board51Testing软件测试网#BE/ufS~

#fis create -f 0x100000 kernel 51Testing软件测试网 A;V*\K!Vd#a

 

P(Mu0UC0

3. Burn the linux rootfs51Testing软件测试网s'W dfr Q1X5@d aG

#load -r -b 0x100000 rootfs.jffs251Testing软件测试网m.`ba9u6n

#fis create -f 0x600000 rootfs.jffs251Testing软件测试网2Vae+bf6TH

 51Testing软件测试网+Y{ i[?(\F8H

Use fis list to confirm kernel/rootfs flash correctly.51Testing软件测试网'q ar6IYkbO4]

 

nYe#R$c\1].I0

3. use fconfig to change the boot script

7ZU T/E~J0

#fconfig

6AW6[7D7yV4x-`0

Run script. at boot:true51Testing软件测试网 d1sr bs3X#QA Aq

Boot script.:

$st}.v*Y0

.. fis load kernel

4Fw'WM7RWYD0

.. exec -c "noinitrd console=ttymxc0 root=/dev/mtdblock7 rw ip=dhcp rootfstype=cramfs"

U$L8K5xE{0

Enter script, terminate with empty line

"R"h| J l!JH0

fis load kernel;

;a*g&SF%Ur CPT4L0

e -c "noinitrd console=ttymxc0,115200 root=/dev/mtdblock2rw rootfstype=jffs2 ip=off"

V(j4p Oh-D%W'cP0

 

z%At!fJho9~r(s0

or51Testing软件测试网$RT:ERv

 

5P)P^L)J.E#of'M0

fis load kernel

0q H ?6HlD2N7D0

exec -c "noinitrd console=ttymxc0,115200 root=/dev/mtdblock8rw rootfstype=jffs2 ip=dhcp"51Testing软件测试网r]_.D6p.P | D1Q

 51Testing软件测试网OD2]0So ?-R9J

Boot script. timeout (1000ms resolution): 1

w;W aS5u T%w0

Use BOOTP for network configuration:true

QGpS'E&n0

Default server IP address:

Kn1IR `ABc0

Board specifics: 0

9B2Y3Q7^.Lg Ue0}+N#Y0

Console baud rate: 115200

"EI2M6XU*@d {*C#Xt0

Set eth0 network hardware address [MAC]: false

lj4kxY.CS0

GDB connection port: 9000

$H"Og7b dx9d0

Force console for special debug messages: false

s,u2Qc7v4q-r{;nB0

Network debug at boot time: false51Testing软件测试网[koO ?8C)J

Update RedBoot non-volatile configuration - continue (y/n)?y51Testing软件测试网tHT0E jzecD

... Read from 0x07ee0000-0x07eff000 at 0xa1fe0000: .

%@_7l?;EaA0

... Erase from 0xa1fe0000-0xa2000000: .

e\kz z*s-X0

... Program from 0x07ee0000-0x07f00000 at 0xa1fe0000: .

%t&f,bR@0

 

L-WN@)p%r0

Reset51Testing软件测试网8A)O_ |,vK6l

 

-X@u#G4\ b&\I0

1.4 Boot up from nfs server

If you want to boot up from nfs server, please use the script.

CuaZ"g E X,XDw0

#fconfig51Testing软件测试网:Gb6fQJtHbx t

Run script. at boot:true51Testing软件测试网L1Z}uuK!P [z-\ yc

Boot script.:

$XH)n%z?;K0

.. fis load kernel

1^.~)SsH;_D0

.. exec -c "noinitrd console=ttymxc0 root=/dev/mtdblock7 rw ip=dhcp rootfstype=cramfs"

([6z4j1m1o0

Enter script, terminate with empty line

7w v.g%iLL,w'z0

>>fis load kernel51Testing软件测试网DFoY @8O,khU-g)`

>>e -c "noinitrd console=ttymxc0 root=/dev/nfs nfsroot=xx.xx.xx.xx:/rootfs/Release/imx37demo_rootfs rw ip=dhcp"

*Rw Y-@e,Art0

 

tl(Z@M$\(Gsrse"OG0

>> 

-S([*my {#c*zi0

Boot script. timeout (1000ms resolution): 1

y){#agf&eR@6A9e0

Use BOOTP for network configuration:true51Testing软件测试网(A1NT{ [!a!zD

Default server IP address:xx.xx.xx.xx51Testing软件测试网6yK0ZvxK3_ S

Board specifics: 0

#|%wY9sk6y&e0

Console baud rate: 11520051Testing软件测试网5vV)y8\XtU

Set eth0 network hardware address [MAC]: false

$aI?!~hh0

GDB connection port: 900051Testing软件测试网/qg5ZMHa_

Force console for special debug messages: false

u Q&d.}e+T A;m8\^d0

Network debug at boot time: false51Testing软件测试网"dHg!Y:?[V

Update RedBoot non-volatile configuration - continue (y/n)?y51Testing软件测试网`"@Q/NM.~W*X

... Read from 0x07ee0000-0x07eff000 at 0xa1fe0000: .51Testing软件测试网 ~(q(qMk c

... Erase from 0xa1fe0000-0xa2000000: .

8UgZp_\6q-Z1a+E0

... Program from 0x07ee0000-0x07f00000 at 0xa1fe0000: .51Testing软件测试网0n)D|9\ d

 

]^0\/w(i\4X0

Reset

xs IC s[0

 

eJ3ygWW1x0

 

2 Ubuntu下安装tftp服务器的步骤

51Testing软件测试网7K.j)t1I9`r9kV'ku

Reference:http://www.oklinux.cn/html/network/ser/20080301/47786.html51Testing软件测试网@!k1W A2J`*X t

51Testing软件测试网#Aa!_];df4O`U

 

;}OT0q$i*{VF0

0S]NPa6}aL#o ]01、首先在Ubuntu下安装serverclient51Testing软件测试网@obk2]U ]

51Testing软件测试网 n/H!SXxiw

打开Ubuntu的终端,输入以下命令:51Testing软件测试网SUA{ CLO
sudo apt-get install tftpd-hpa tftp-hpa

)r4Qe+CwY0

5\;wW sd*h02、删除standalone的启动方式
\9DY3?9V"x,~&Hfa0update-rc.d -f tftpd-hpa remove
51Testing软件测试网]t \T)` nh

.Oe$f/~z03、新建用户tftpd及其主目录51Testing软件测试网F9MkY2\%A!a X6fhvb
sudo mkdir -p /home/tftpd
F(O W Z B(\;h C:TR0sudo useradd -s /bin/false -g nogroup -d /home/tftpd [-p PASSWORD] tftpd51Testing软件测试网;\_D b1F^4]U
示例
:sudo useradd -s /bin/false -g nogroup -d /home/tftpd tftpd
SA1g F-Ji(f^0
加密码:sudo useradd -s /bin/false -g nogroup -d /home/tftpd tftpd -p 123456
51Testing软件测试网Vf-S ~ Y.j_

51Testing软件测试网R4Z'b$?#U b

install xinetd51Testing软件测试网*x}:bPp'PP2G,F0UK

~0?;f#xO8lA(z}0sudo apt-get install xinetd51Testing软件测试网SSHL g o,L

51Testing软件测试网1E S+]L3}f

 51Testing软件测试网0~ SUV^@s

y r_O M04.配置一下/etc/default/tftpd-hpa,就可以了51Testing软件测试网*H3~4rjJv8gM+\
#Defaults for tftpd-hpa51Testing软件测试网 V&zM;w@/v2B
RUN_DAEMON="yes"
:` v4x!zZ:l#c0|T0OPTIONS="-l -s /home/ttk/tftpboot"

+kO$rFHD0

}B)kP8yZI0 

CTge"X)]v Vs*V8Uo0

4O#B6C M7_:c6N%h05、新建xinetd启动文件51Testing软件测试网SkE)Ql3L ^4_
cat /etc/xinetd.d/tftpd
H-Y9Yw,b U,x0service tftp
9d!_7HnG/Z]z0{51Testing软件测试网 Mze8rmK@
disable = no
?P/S.p1l9[4\F0socket_type = dgram
u4Y:N9zI XE|0wait = no51Testing软件测试网.E1QkG;i&Ry2c
user = root51Testing软件测试网k+hV]{6u8y
protocol = udp51Testing软件测试网4z2f-qb2K UCS:l
server = /usr/sbin/in.tftpd51Testing软件测试网5_fjC4q
server_args = -s /home/tftpd -p -c -U 077 -u tftpd #//
表示tftp操作目录在/home/tftpd
aKs(X F8o Y&d P0
log_on_success = PID HOST DURATION51Testing软件测试网G$LH;f3J
log_on_failure = HOST
#G'o|%iW'y+b0}

3RhG7S`Htf0

2A%QNH*[wN~O051Testing软件测试网{]p+aBMYxN p2s
6
、注释掉/etc/inetd.conf文件中tftpd启动
7G~G `6K&?#]_g p lgg0#tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
51Testing软件测试网1~BI.i*S%l"Ir5X#m

51Testing软件测试网 S0KEL j x4\_7{

if you have other network connections, such as WiFi, dual-eth cards, pls shutdown the others if tftp is not working.

;Q,V,AT JB%le"u ~x0

@s3O&C"CA07、重新启动xinetd服务51Testing软件测试网Xoz/?#E0lu8EP:U)R
sudo /etc/init.d/xinetd restart

2Oh!~"e,_D7E/Bor051Testing软件测试网7Bwz)G}/`#\#v Bn

8测试tftpd服务是否成功
-@Alj8d&[r2Z0
tftp localhost
7BA%l_ w)by-\!J0tftp> put 123.log
,x)BE|sI0tftp> put 123.log test.log
;CN W } US^0tftp> get test.log
2I Bd-S#G7b0tftp> get test.log abc.log51Testing软件测试网GZ&L_~fX"? KZ
tftp> verbose51Testing软件测试网4q!A2B!|j f|,Z
Verbose mode on.51Testing软件测试网$n#gtvR ^5YH3K-T
tftp> trace
B3OHK7V0Packet tracing on.51Testing软件测试网kD(}\o6V%c
tftp> put kkk.log51Testing软件测试网N"[F&v4W'f:^?
sent DATA
{-n&d-yO0received ACK51Testing软件测试网S2_$To U G4HS
.........
?4I5t)xNH7jO0sent DATA
.?&g q k$l4e~#W#g0received ACK51Testing软件测试网8bKd u;v|b(p
Sent 12999997 bytes in -1.5 seconds [-69987938 bit/s]51Testing软件测试网F9P)jv)Q)e-_ C(T.m/Q$A

[7ktL-@QR0
:在哪个目录执行tftp命令,那么上传的文件就是这个目录下的所有文件,下载的文件将只能是server目录下的那些文件!
*qBy9A7`/D`0因为evb板子和Liunx下的usb0网卡连接,所以设置usb0网卡地址51Testing软件测试网5e/Z4Z'Pa\ ?,H,S,{4y
ifconfig看看是不是有网卡51Testing软件测试网*\2Iv }P,^2vPb
然后51Testing软件测试网:m q:p(W*vc*Z2G
sudo ifconfig usb0 192.168.100.1因为blob默认的地址server地址是192.168.100.1所以需要这样设置才行

9je'nbzJ3d051Testing软件测试网D8~INS[Wu

ps:51Testing软件测试网6p/[:U4YL$i9W(MP Sp
如果发生Ubuntutftp不能使用,那么一定是server出现了问题
,
1`-d6G}6? s H0
liunx下再执行一次sudo /etc/init.d/xinetd restartok51Testing软件测试网*DB.B6h{G:e];X0w
可以使用tftp localhost测试主机的server是否可以传送数据

:?8^h9y"~(F0

 

T1^ qu5kE+T1[0

TAG: Linux TFTP

 

评分:0

我来说两句

Open Toolbar