u-boot-2011.06在基于s3c2440开发板的移植之引导内核与加载根文件系统

转自:http://www.linuxidc.com/Linux/2012-09/70510p2.htm


三、根文件系统的制作

我们利用busybox来制作根文件系统

1.在下列网站下载busybox-1.15.0.tar.bz2

http://www.linuxidc.com/linux/2011-08/40704.htm

在当前目录下解压busybox

tar -jxvf busybox-1.15.0.tar.bz2

2.配置编译busybox

使用menuconfig来配置busybox:

make  menuconfig

修改下列内容:

Busybox Settings  ---> 
     Build Options  ---> 
       [*] Build BusyBox as a staticbinary (no shared libs) (编译成静态库)
     Busybox Library Tuning  --->  
       [*]   Tabcompletion         (tab缩进功能)                                            
       [*]     Usernamecompletion                                    
       [*]   Fancy shellprompts  (这两项在创建/etc/profile文件时要用,这样可以命令行有提示符显示)

只需修改上述几个选项,其他配置可以不去改动。

修改Makefile

emacsMakefile

在第164行,改为:

CROSS_COMPILE?=arm-linux-

在第190行,改为:

ARCH ?=arm

执行make命令编译busybox

3.利用下面命令安装busybox:

Make  CONFIG_PREFIX=/home/zhaocj/rootfs        install

其中/home/zhaocj/rootfs为指定的安装目录,如果还没有该目录,则需先要用mkdir命令创建该目录。之所以要指定目录,就是为了改变系统默认生成的_stall目录。

安装完毕后,会在/home/zhaocj/rootfs目录下生成bin、linuxrc、sbin、usr这四个目录和文件。

4.进入rootfs目录,自行添加其他目录和文件

首先要创建etc目录,以及在该目录下生成四个文件:etc/inittab、etc/fstab、etc/profile、etc/init.d/rcS

mkdir  etc

cd  etc

 

emacs  inittab

内容为:

::sysinit:/etc/init.d/rcS

::askfirst:-/bin/sh

::restart:/sbin/init

::ctrlaltdel:/sbin/reboot

::shutdown:umount-a -r

 

emacs  fstab

内容为:

#device       mount-point    type  options    dump  fsck order

proc          /proc          proc    defaults   0    0

sysfs           /sys           sysfs   defaults   0   0

tmpfs          /temp         tmpfs    defaults    0   0

tmpfs           /dev          tmpfs   defaults   0    0

 

emacs  profile

内容为:

#!/bin/sh

exportHOSTNAME=zhaocj

exportUSER=root

exportHOME=root

exportPS1="[$USER@$HOSTNAME \W]\#"

PATH=/bin:/sbin:/usr/bin:/usr/sbin

LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH

exportPATH LD_LIBRARY_PAT

 

mkdir  init.d

emacs  init.d/rcS

内容为:

mount -a

mkdir/dev/pts

mount -tdevpts devpts /dev/pts

echo/sbin/mdev > /proc/sys/kernel/hotplug

mdev -s

在根用户下增加该文件的执行权限

chmod +xrcS

 

回到主目录下,创建其他目录:

mkdir  dev  home temp  proc  sys

 

进入dev目录,并用根用户创建两个基本的设备文件:

mknod  console  c  5  1

mknod  null  c  1  3

至此,根文件系统创建完毕。

5.生成cramfs根文件系统

在这里我们要使用cramfs根文件系统,并把它烧写到nandflash中,因此要有编译cramfs的制作工具。在下列网站下载cramfs-1.1.tar.gz。

http://sourceforge.net/projects/cramfs/

在当前目录下解压cramfs-1.1.tar.gz,并编译:

tar zxvfcramfs-1.1.tar.gz

make

编译完成后,会生成mkcramfs和cramfsck两个可执行文件,其中mkcramfs工具是用来创建cramfs文件系统的。

利用mkcramfs压缩根文件系统,生成cramfs:

mkcramfs  rootfs  root-cramfs

rootfs为刚刚制作的根文件系统的目录,root-cramfs为最终生成的cramfs根文件系统。

6.最后,我们把root-cramfs文件烧写到nandflash中的0x800000至0x1000000中。

当完成以上三个部分内容后,uboot就能够正确引导linux内核以及加载根文件系统了。下面列出了uboot启动后在串口显示的内容:

U-Boot2011.06 (Aug 31 2012 - 15:08:19)

DRAM:  64 MiB

Flash: ##Unknown flash on Bank 1 - Size = 0x00000000 = 0 MB

2 MiB

NAND:  256 MiB

***Warning - bad CRC, using default environment

In:    serial

Out:   serial

Err:   serial

Net:   dm9000


Hit anykey to stop autoboot:  0


NANDread: device 0 offset 0x200000, size 0x400000 4194304 bytes read: OK


##Booting kernel from Legacy Image at 31000000 ...

   Image Name:  linux

   Created:     2012-09-01  14:46:43 UTC

   Image Type:  ARM Linux Kernel Image (uncompressed)

   Data Size:   2428888 Bytes = 2.3 MiB

   Load Address: 31000000

   Entry Point: 31000040

   Verifying Checksum ... OK

   XIP Kernel Image ... OK

OK


Startingkernel ...

UncompressingLinux... done, booting the kernel.


BootingLinux on physical CPU 0

Linuxversion 3.4.6 (zcj@qihao) (gcc version 4.2.2) #3Sat Sep 1 22:44:40 CST 2012

CPU:ARM920T [41129200] revision 0 (ARMv4T), cr=00007177

CPU: VIVTdata cache, VIVT instruction cache

Machine:SMDK2440

Memorypolicy: ECC disabled, Data cache writeback

CPU S3C2440A(id 0x32440001)

S3C24XX Clocks, Copyright 2004 SimtecElectronics

S3C244X: core 400.000 MHz, memory 100.000MHz, peripheral 50.000 MHz

CLOCK:Slow mode (1.500 MHz), fast, MPLL on, UPLL on

Built 1zonelists in Zone order, mobility grouping on. Total pages: 16256

Kernelcommand line: root=/dev/mtdblock3 ro noinitrd init=/linuxrcconsole=ttySAC,115200 rootfstype=cramfs mem=64M

PID hashtable entries: 256 (order: -2, 1024 bytes)

Dentrycache hash table entries: 8192 (order: 3, 32768 bytes)

Inode-cachehash table entries: 4096 (order: 2, 16384 bytes)

Memory:64MB = 64MB total

Memory:59980k/59980k available, 5556k reserved, 0K highmem

Virtualkernel memory layout:

    vector : 0xffff0000 - 0xffff1000   (   4 kB)

    fixmap : 0xfff00000 - 0xfffe0000   ( 896kB)

    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)

    lowmem : 0xc0000000 - 0xc4000000   (  64 MB)

    modules : 0xbf000000 - 0xc0000000   (  16MB)

      .text : 0xc0108000 - 0xc0545868   (4343 kB)

      .init : 0xc0546000 - 0xc0570000   ( 168 kB)

      .data : 0xc0570000 - 0xc05a67a0   ( 218 kB)

       .bss : 0xc05a67c4- 0xc05cf1dc   ( 163 kB)

NR_IRQS:99

irq:clearing subpending status 00000002

sched_clock:32 bits at 200 Hz, resolution 5000000ns, wraps every 4294967291ms

Console:colour dummy device 80x30

Calibratingdelay loop... 49.56 BogoMIPS (lpj=123904)

pid_max:default: 32768 minimum: 301

Mount-cachehash table entries: 512

CPU:Testing write buffer coherency: ok

Settingup static identity map for 0x304355a0- 0x3043561c

gpiochip_add:registered GPIOs 0 to 23 on device: GPIOA

gpiochip_add:registered GPIOs 32 to 47 on device: GPIOB

gpiochip_add:registered GPIOs 64 to 79 on device: GPIOC

gpiochip_add:registered GPIOs 96 to 111 on device: GPIOD

gpiochip_add:registered GPIOs 128 to 143 on device: GPIOE

gpiochip_add:registered GPIOs 160 to 167 on device: GPIOF

gpiochip_add:registered GPIOs 192 to 207 on device: GPIOG

gpiochip_add:registered GPIOs 224 to 234 on device: GPIOH

gpiochip_add:registered GPIOs 256 to 271 on device: GPIOJ

NET:Registered protocol family 16

S3C Power Management, Copyright 2004Simtec Electronics

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C244X: Clock Support, DVS off

bio:create slab at 0

SCSIsubsystem initialized

usbcore:registered new interface driver usbfs

usbcore:registered new interface driver hub

usbcore:registered new device driver usb

s3c-i2cs3c2440-i2c: slave address 0x10

s3c-i2cs3c2440-i2c: bus frequency set to 97 KHz

s3c-i2cs3c2440-i2c: i2c-0:S3C I2C adapter

AdvancedLinux Sound Architecture Driver Version 1.0.25.

NET:Registered protocol family 2

IP routecache hash table entries: 1024 (order: 0, 4096 bytes)

TCPestablished hash table entries: 2048 (order: 2, 16384 bytes)

TCP bindhash table entries: 2048 (order: 1, 8192 bytes)

TCP: Hashtables configured (established 2048 bind 2048)

TCP: reno registered

UDP hashtable entries: 256 (order: 0, 4096 bytes)

UDP-Litehash 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.

NetWinderFloating Point Emulator V0.97 (extended precision)

jffs2:version 2.2. (NAND) (SUMMARY)  ?2001-2006 Red Hat, Inc.

ROMFS MTD(C) 2007 Red Hat, Inc.

msgmnihas been set to 117

ioscheduler noop registered

ioscheduler deadline registered

ioscheduler cfq registered (default)

Console:switching to colour frame buffer device 30x40

fb0: s3c2410fb frame buffer device

Serial:8250/16550 driver, 4 ports, IRQ sharing enabled

s3c2440-uart.0: ttySAC0 at MMIO 0x50000000(irq = 70) is a S3C2440

console[ttySAC0] enabled

s3c2440-uart.1: ttySAC1 at MMIO 0x50004000(irq = 73) is a S3C2440

s3c2440-uart.2: ttySAC2 at MMIO 0x50008000(irq = 76) is a S3C2440

lp:driver loaded but no devices found

ppdev:user-space parallel port driver

brd:module loaded

loop:module loaded

UniformMulti-Platform E-IDE driver

ide-gddriver 1.18

ide-cddriver 5.00

S3C24XX NAND Driver, (c) 2004 SimtecElectronics

s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=220ns

s3c24xx-nand s3c2440-nand: NAND ECC disabled

NANDdevice: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)

NAND_ECC_NONEselected by board driver. This is not recommended!

Scanningdevice for bad blocks

Baderaseblock 615 at 0x000004ce0000

Baderaseblock 807 at 0x0000064e0000

Creating4 MTD partitions on "NAND":

0x000000000000-0x000000080000: "UBoot"

0x000000080000-0x000000100000: "Para"

0x000000200000-0x000000600000: "Kernel"

0x000000800000-0x000001000000: "rootfs"

dm9000Ethernet Driver, V1.31

ohci_hcd:USB 1.1 'Open' Host Controller (OHCI) Driver

s3c2410-ohci s3c2410-ohci: S3C24XXOHCI

s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned busnumber 1

s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000

hub1-0:1.0: USB hub found

hub1-0:1.0: 2 ports detected

usbcore:registered new interface driver libusual

usbcore:registered new interface driver usbserial

usbcore:registered new interface driver usbserial_generic

USBSerial support registered for generic

usbserial:USB Serial Driver core

usbcore:registered new interface driver ftdi_sio

USB Serialsupport registered for FTDI USB Serial Device

ftdi_sio:v1.6.0:USB FTDI Serial Converters Driver

usbcore:registered new interface driver pl2303

USBSerial support registered for pl2303

mousedev:PS/2 mouse device common for all mice

s3c2410_wdt: S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irqdisabled

TCP:cubic registered

NET:Registered protocol family 17

drivers/rtc/hctosys.c:unable to open rtc device (rtc0)

ALSAdevice list:

  No soundcards found.

VFS:Mounted root (cramfs filesystem) readonly on device 31:3.

Freeinginit memory: 168K


Pleasepress Enter to activate this console.


当我们按下回车键后,会看到linux的提示符:

[root@zhaocj /]#

 

在该提示符下就可以运行一些linux命令了,如:

[root@zhaocj /]#ls

bin      etc      lib     proc     sys      usr

dev      home    linuxrc  sbin     temp

相关阅读:

U-Boot源代码下载地址 http://www.linuxidc.com/Linux/2011-07/38897.htm

U-Boot-2011.06启动流程分析 http://www.linuxidc.com/Linux/2011-07/39310.htm

u-boot-2011.06在基于s3c2440开发板的移植之编译配置 http://www.linuxidc.com/Linux/2011-10/45455.htm

u-boot-2011.06在基于s3c2440开发板的移植之NorFlash启动 http://www.linuxidc.com/Linux/2011-10/45456.htm

u-boot-2011.06在基于S3C2440开发板的移植之解决raise: Signal # 8 caught http://www.linuxidc.com/Linux/2011-10/454554.htm

u-boot-2011.06在基于s3c2440开发板的移植之支持NandFlash读写 http://www.linuxidc.com/Linux/2011-10/45457.htm

u-boot-2011.06在基于s3c2440开发板的移植之硬件ECC http://www.linuxidc.com/Linux/2011-10/454558.htm

u-boot-2011.06在基于s3c2440开发板的移植之DM9000 http://www.linuxidc.com/Linux/2012-09/70507.htm

u-boot-2011.06在基于s3c2440开发板的移植之nandflash启动 http://www.linuxidc.com/Linux/2012-09/70508.htm

u-boot-2011.06在基于s3c2440开发板的移植之支持YAFFS2 http://www.linuxidc.com/Linux/2012-09/70509.htm

u-boot-2011.06在基于s3c2440开发板的移植之引导内核与加载根文件系统 http://www.linuxidc.com/Linux/2012-09/70510.htm

u-boot-2011.06在基于s3c2440开发板的移植之结束篇 http://www.linuxidc.com/Linux/2012-09/70511.htm

你可能感兴趣的:(Linux)