1. TFTP下载Linux内核
1.1 使用u-boot提供的mkimage工具将zImage制作成uImage
[wf@localhost tools]$ ./mkimage -n 'my_kernel' -A arm -O linux -T kernel -C none -a 0x50008000 -e 0x50008040 -d zImage uImage
Image Name: my_kernel
Created: Fri Apr 10 14:01:16 2020
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3758784 Bytes = 3670.69 kB = 3.58 MB
Load Address: 50008000
Entry Point: 50008040
1.2 配置TFTP服务器
如果系统没有安装tftp服务器,需要先安装:
yum install tftp-server
安装完成后,修改配置文件:/etc/xinetd.d/tftp
[wf@localhost tools]$ vim /etc/xinetd.d/tftp
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /opt/tftpboot -c
per_source = 11
cps = 100 2
flags = IPv4
}
如图所示,我的tftp服务器的文件夹为/opt/tftpboot
更改tftpboot文件夹的权限为777
[root@localhost opt]# chmod 777 tftpboot
[root@localhost opt]# ll
total 24
drwxr-xr-x 2 root root 4096 Apr 6 23:27 bins
drwxr-xr-x. 5 root root 4096 Dec 10 2018 cross-tools
drwxr-xr-x. 4 root root 4096 Oct 6 2019 dnw
drwxr-xr-x 4 root root 4096 Jan 19 22:34 linux
drwxr-xr-x. 2 root root 4096 Nov 29 2013 minitools
drwxrwxrwx 2 root root 4096 Apr 10 00:20 tftpboot
最后,重新启动xinetd服务,配置就完成了:
[root@localhost opt]# /etc/init.d/xinetd restart
Restarting xinetd (via systemctl): [ OK ]
另外,为了避免使用时出现上传或下载的错误,可以将SELinux关闭:
[root@localhost opt]# setenforce 0
setenforce: SELinux is disabled
修改/etc/selinux/config,将SELINUX一项改为"disabled",这样重启后,就不用再使用刚才的命令关闭SELinux了。
[root@localhost opt]# vim /etc/selinux/config
1
2 # This file controls the state of SELinux on the system.
3 # SELINUX= can take one of these three values:
4 # enforcing - SELinux security policy is enforced.
5 # permissive - SELinux prints warnings instead of enforcing.
6 # disabled - No SELinux policy is loaded.
7 SELINUX=disabled
8 # SELINUXTYPE= can take one of these two values:
9 # targeted - Targeted processes are protected,
10 # mls - Multi Level Security protection.
11 SELINUXTYPE=targeted
12 SELINUX=disable
13 iptables -F
1.3 TFTP下载uImage
MINI6410 # tftp 50008000 uImage
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:10:12:10:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.253
Filename 'uImage'.
Load address: 0x50008000
Loading: ##################################################################################################################################
##################################################################################################################################
##################################################################################################################################
###########################################################################################################################
done
#Bytes transferred = 3758848 (395b00 hex)
MINI6410 #
2. NFS启动文件系统
2.1 设置NFS服务器端挂载目录
修改/etc/exports,添加/opt/linux/rootfs *(rw,sync,no_root_squash),/opt/linux/rootfs为想挂载的目录
[root@localhost opt]# vim /etc/exports
1 /opt/linux/rootfs *(rw,sync,no_root_squash)
重启相关服务service nfs restart,service xinetd restart
[root@localhost opt]# service nfs restart
Restarting nfs (via systemctl): [ OK ]
[root@localhost opt]# service xinetd restart
Restarting xinetd (via systemctl): [ OK ]
2.2 设置启动参数
set bootargs console=ttySAC0,115200n8 proto=tcp ip=192.168.1.253 root=/dev/nfs nfsroot=192.168.1.100:/opt/linux/rootfs rw
MINI6410 # set bootargs console=ttySAC0,115200n8 proto=tcp ip=192.168.1.253 root=/dev/nfs nfsroot=192.168.1.100:/opt/linux/rootfs rw
MINI6410 # saveenv
Saving Environment to MMC...
Writing to MMC(0)... done
MINI6410 #
2.3 使用bootm命令启动linux内核及文件系统
MINI6410 # bootm 50008000
## Booting kernel from Legacy Image at 50008000 ...
Image Name: my_kernel
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 3758784 Bytes = 3.6 MiB
Load Address: 50008000
Entry Point: 50008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Initializing cgroup subsys cpu
Linux version 2.6.38-FriendlyARM (root@tzs-friendlyarm) (gcc version 4.5.1 (ctng-1.8.1-FA) ) #1 PREEMPT Mon Jan 6 14:14:31 HKT 2014
CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387f
CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: MINI6410
Memory policy: ECC disabled, Data cache writeback
CPU S3C6410 (id 0x36410101)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
可以看到,Linux内核及文件系统成功启动!
eth0: link down
eth0: link up, 100Mbps, full-duplex, lpa 0x4DE1
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
device=eth0, addr=192.168.1.253, mask=255.255.255.0, gw=255.255.255.255,
host=192.168.1.253, domain=, nis-domain=(none),
bootserver=255.255.255.255, rootserver=192.168.1.100, rootpath=
Freeing init memory: 1408K
one_wire_status: 4
FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
fa_cpu_pfn: module license 'Proprietary' taints kernel.
Disabling lock debugging due to kernel taint
FriendlyARM proprietary driver for mini6410 initialized.
[31/Dec/1999:17:01:49 +0000] boa: server version Boa/0.94.13
[31/Dec/1999:17:01:49 +0000] boa: server built Dec 30 2010 at 11:18:35.
[31/Dec/1999:17:01:49 +0000] boa: starting server pid=956, port 80
asoc: wm9713-hifi <-> samsung-ac97 mapping ok
Try to bring eth0 interface up......NFS root ...Done
Please press Enter to activate this console.
[root@FriendlyARM /]# ls
bin linuxrc study
data mnt sys
dev opt tmp
etc proc ttys1
fa-network-service root usr
home sbin var
lib sdcard www
[root@FriendlyARM /]#