2012年06月25日
Ubuntu 12.04でtftpサーバをセットアップする
Ubuntu 12.04でtftpサーバをセットアップする手順を紹介します。
U-bootはnfsでuImageをロードすることもできるのですが、tftpのほうがnfsよりも早くロードが完了します。そのため開発時の毎回の起動時間を考えるとtftpサーバを立ててuImageはtftpでロードするほうが作業効率が上がります。
インストール
$ sudo apt-get install tftp tftpd
xinetdのセットアップ
tftpdは以前はinetdで管理されていましたが、今はxinetdで管理されます。
$ sudo vi /etc/xinetd.d/tftp
/etc/xinetd.d/tftp の内容は以下。
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /tftpboot
disable = no
}
/tftpboot ディレクトリを作成して、モードとオーナーの設定。
$ sudo mkdir /tftpboot $ sudo chmod -R 777 /tftpboot $ sudo chown -R nobody /tftpboot/
xinetdを再スタート。
$ sudo service xinetd restart
テスト
tftpコマンドを使ってファイルがとってこれることを確認する。
自分のIPアドレスを192.168.1.110とすると
$ ls -l uImage -rw-r--r-- 1 koba koba 2230644 Jun 25 15:48 uImage $ cp uImage /tftpboot/ $ cd /tmp $ tftp 192.168.1.110 tftp> get uImage Received 2244642 bytes in 0.1 seconds tftp> quit $ ls -l uImage -rw-r--r-- 1 koba koba 2230644 Jun 25 15:49 uImage $ cmp /tftpboot/uImage /tmp/uImage $
U-bootで試す
KZM-A9-GTボードでuImageをtftpでダウンロードして、それを起動する。
> setenv ipaddr 192.168.1.162 > setenv serverip 192.168.1.110 > tftpboot uImage; bootm
smc911x: detected LAN9221 controller
smc911x: phy initialized
smc911x: MAC 00:01:9b:04:04:10
Using smc911x-0 device
TFTP from server 192.168.1.110; our IP address is 192.168.1.162
Filename 'uImage'.
Load address: 0x43000000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
##############################################
done
Bytes transferred = 2230644 (220974 hex)
## Booting kernel from Legacy Image at 43000000 ...
Image Name: Linux-3.0.33-ltsi+
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2230580 Bytes = 2.1 MiB
Load Address: 41008000
Entry Point: 41008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Booting Linux on physical CPU 0
Linux version 3.0.33-ltsi+ (koba@koba-linux2) (gcc version 4.6.2 20110921 (release) [ARM/embedded-4_6-branch revision 182083] (GNU Tools for ARM Embedded Processors) ) #39 SMP PREEMPT Wed Jun 20 10:58:35 JST 2012
CPU: ARMv7 Processor [412fc098] revision 8 (ARMv7), cr=10c5387d
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: kzm9g
debug: ignoring loglevel setting.
Memory policy: ECC disabled, Data cache writealloc
On node 0 totalpages: 126976
free_area_init_node: node 0, pgdat c0452140, node_mem_map c0482000
Normal zone: 960 pages used for memmap
Normal zone: 0 pages reserved
Normal zone: 121920 pages, LIFO batch:31
HighMem zone: 32 pages used for memmap
HighMem zone: 4064 pages, LIFO batch:0
bootconsole [early_ttySC4] enabled
PERCPU: Embedded 7 pages/cpu @c0867000 s4640 r8192 d15840 u32768
pcpu-alloc: s4640 r8192 d15840 u32768 alloc=8*4096
pcpu-alloc: [0] 0 [0] 1
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 125984
Kernel command line: console=tty0 console=ttySC4,115200 root=/dev/nfs ip=dhcp ignore_loglevel earlyprintk=sh-sci.4,115200 root=/dev/mmcblk0p2
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 496MB = 496MB total
...
参考にしたページ
http://www.davidsudjiman.info/2006/03/27/installing-and-setting-tftpd-in-ubuntu/