fl2440之initramfs文件系统制作与移植

来源:互联网 发布:卡乐xu3软件下载 编辑:程序博客网 时间:2024/05/23 16:04

*******************************************************************************************************************************************************

开发板           : fl2440

cpu              :s3c2440(arm920t)

交叉编译器  :arm-linux-gcc-4.5.4

PC操作系统:CentOS 6.7

linux内核版本:linux-3.0.0

****************************************************************************************************************************************************

1.Initramfs文件系统的制作与移植

1.1对根文件系统进行修改

由于制作initramfs文件系统启动时会在根文件系统中执行第一个init程序,它对uboot传过来的参数init=/linuxrc不予理睬,所以需要在上面制作的根文件系统里的根目录加入init程序,否则无法启动。init程序和linuxrc程序一样都是符号链接文件,它们都是指向/bin/busybox程序。

[zoulei@CentOS rootfs]$

总用量 60
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 apps
drwxrwxr-x 2 zoulei zoulei 4096 3月   8 05:52 bin
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 data
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 dev
drwxrwxr-x 4 zoulei zoulei 4096 8月  14 01:01 etc
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 info
drwxrwxr-x 3 zoulei zoulei 4096 3月   8 04:45 lib
lrwxrwxrwx 1 root   root     11 3月   8 05:52 linuxrc -> bin/busybox
drwxrwxr-x 6 zoulei zoulei 4096 12月 25 2016 mnt
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 proc
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 root
drwxrwxr-x 2 zoulei zoulei 4096 3月   8 05:52 sbin
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 sys
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 tmp
drwxrwxr-x 6 zoulei zoulei 4096 12月 25 2016 usr
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 var

[zoulei@CentOS rootfs]$ln -s bin/busybox/init

总用量 60
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 apps
drwxrwxr-x 2 zoulei zoulei 4096 3月   8 05:52 bin
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 data
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 dev
drwxrwxr-x 4 zoulei zoulei 4096 8月  14 01:01 etc
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 info
lrwxrwxrwx 1 zoulei zoulei   11 3月   6 04:05 init -> bin/busybox
drwxrwxr-x 3 zoulei zoulei 4096 3月   8 04:45 lib
lrwxrwxrwx 1 root   root     11 3月   8 05:52 linuxrc -> bin/busybox
drwxrwxr-x 6 zoulei zoulei 4096 12月 25 2016 mnt
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 proc
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 root
drwxrwxr-x 2 zoulei zoulei 4096 3月   8 05:52 sbin
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 sys
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 tmp
drwxrwxr-x 6 zoulei zoulei 4096 12月 25 2016 usr
drwxrwxr-x 2 zoulei zoulei 4096 12月 25 2016 var

1.2 添加内核对initramfs的支持

找到你的内核源码包所在的路径,然后进入内核目录,我的内核是linux-3.0

[zoulei@CentOS ~]$ cd fl2440/
[zoulei@CentOS fl2440]$ ls
3rdparty  bootloader  driver  kernel  program  rootfs  trunk
[zoulei@CentOS fl2440]$ cd kernel/
[zoulei@CentOS kernel]$ ls
linux-3.0  linux-3.0.tar.bz2
[zoulei@CentOS kernel]$ cd linux-3.0
[zoulei@CentOS linux-3.0]$ export TERM=vt100
[zoulei@CentOS linux-3.0]$ make menuconfig



[zoulei@CentOS linux-3.0]$ ls
arch     CREDITS        drivers   include  Kbuild   lib                   Makefile  modules.builtin  net  README          scripts   System.map  udisk32M.img  vmlinux
block    crypto         firmware  init     Kconfig  linuxrom-s3c2440.bin  mkimage   modules.order    pwd  REPORTING-BUGS  security  tags        usr           vmlinux.o
COPYING  Documentation  fs        ipc      kernel   MAINTAINERS           mm        Module.symvers   PWD  samples         sound     tools       virt
[zoulei@CentOS linux-3.0]$ du -h linuxrom-s3c2440.bin
3.0M    linuxrom-s3c2440.bin
[zoulei@CentOS linux-3.0]$ mv linuxrom-s3c2440.bin /tftp/

****************************************************************************************************************

注意:这里的/tftp/是我搭建的tftp服务器目录,这样的话就可以把linuxrom-s3c2440.bin上传到开发板,通过u-boot加载内核,

因为文件系统和内核是集成在一起的,所以不需要制作文件系统映像。

***************************************************************************************************************

1.3添加U-boot对initramfs的支持

以下是在开发板上操作。


[fl2440@zoulei]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 8000000;nand write 30008000 100000 800000'

[fl2440@zoulei]# set bootcmd_initramdisk 'nand read 30008000 100000 800000;bootm 30008000'

[fl2440@zoulei]# set bootargs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'

[fl2440@zoulei]# set bootcmd 'run bootcmd_initramdisk'

[fl2440@zoulei]# save

Saving Environment to NAND...

Erasing Nand...

Erasing at 0x60000 -- 100% complete.

Writing to Nand... done

[fl2440@zoulei]# run bkr

dm9000 i/o: 0x20000300, id: 0x90000a46

DM9000: running in 16 bit mode

MAC: 08:00:3e:26:0a:51

could not establish link

operating at 100M full duplex mode

Using dm9000 device

TFTP from server 192.168.1.2; our IP address is 192.168.1.168

Filename 'linuxrom-s3c2440.bin'.

Load address: 0x30008000

Loading: T #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         #################################################################

         ###############################

done

Bytes transferred = 7121280 (6ca980 hex)

 

NAND erase: device 0 offset 0x100000, size 0x8000000

Skipping bad block at  0x005c0000                                          

Skipping bad block at  0x031a0000                                          

Erasing at 0x80e0000 -- 100% complete.

OK

 

NAND write: device 0 offset 0x100000, size 0x800000

Skip bad block 0x005c0000

 8388608 bytes written: OK

1.4启动引导

[fl2440@zoulei]# boot

NAND read: device 0 offset 0x100000, size 0x600000
Skipping bad block 0x00540000
 6291456 bytes read: OK
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   Linux Kernel
   Created:      2017-06-04  12:02:03 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3104356 Bytes = 3 MiB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK


Starting kernel ...


Uncompressing Linux... done, booting the kernel.
Linux version 3.0.0 (zoulei@CentOS.localdomain) (gcc version 4.5.3 (Buildroot 2012.02) ) #44 Sun Jun 4 05:01:17 PDT 2017
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.600 MHz, memory 101.400 MHz, peripheral 50.700 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock2 rootfstype=jffs2 init=/linuxrc console=ttyS0 console=tty1,115200
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 58724k/58724k available, 6812k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    DMA     : 0xffc00000 - 0xffe00000   (   2 MB)
    vmalloc : 0xc4800000 - 0xf6000000   ( 792 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .init : 0xc0008000 - 0xc002b000   ( 140 kB)
      .text : 0xc002b000 - 0xc0596528   (5550 kB)
      .data : 0xc0598000 - 0xc05cc200   ( 209 kB)
       .bss : 0xc05cc224 - 0xc060ae80   ( 252 kB)
SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:85
irq: clearing pending ext status 00000800
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [tty1] enabled
console [ttyS0] enabled
Calibrating delay loop... 202.54 BogoMIPS (lpj=506368)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
gpiochip_add: gpios 288..303 (GPIOK) failed to register
gpiochip_add: gpios 320..334 (GPIOL) failed to register
gpiochip_add: gpios 352..353 (GPIOM) failed to register
NET: Registered protocol family 16
S3C Power Management, Copyright 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C244X: Clock Support, DVS off
s3c-adc s3c24xx-adc: attached adc driver
bio: create slab <bio-0> at 0
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 99 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
Advanced Linux Sound Architecture Driver Version 1.0.24.
cfg80211: Calling CRDA to update world regulatory domain
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 bytes)
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.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 114
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 120x45
fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttyS0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: ttyS1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: ttyS2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
usbcore: registered new interface driver ub
at24 0-0050: 256 byte 24c02 EEPROM, writable, 8 bytes/write
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 42 at 0x000000540000
Bad eraseblock 257 at 0x000002020000
Bad eraseblock 398 at 0x0000031c0000
Bad eraseblock 644 at 0x000005080000
Creating 6 MTD partitions on "NAND":
0x000000000000-0x000000100000 : "boot loader"
ftl_cs: FTL header not found.
0x000000100000-0x000001000000 : "linux kernel"
ftl_cs: FTL header not found.
0x000001000000-0x000005000000 : "rootfs"
ftl_cs: FTL header not found.
0x000005000000-0x00000a000000 : "apps"
uncorrectable error : 
0x00000a000000-0x00000f000000 : "data"
ftl_cs: FTL header not found.
0x00000f000000-0x000010000000 : "backup"

ftl_cs: FTL header not found.
PPP generic driver version 2.4.2
PPP Deflate Compression module registered
PPP BSD Compression module registered
dm9000 Ethernet Driver, V1.31
dm9000 dm9000: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000a at c4862300,c4864304 IRQ 51 MAC: e2:54:dd:c7:79:11 (random)
usbcore: registered new interface driver rt2800usb
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: New USB device found, idVendor=1d6b, idProduct=0001
usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
usb usb1: Product: S3C24XX OHCI
usb usb1: Manufacturer: Linux 3.0.0 ohci_hcd
usb usb1: SerialNumber: s3c24xx
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
usbserial: USB Serial Driver core
USB Serial support registered for ch341-uart
usbcore: registered new interface driver ch341
USB Serial support registered for cp210x
usbcore: registered new interface driver cp210x
cp210x: v0.09:Silicon Labs CP210x RS232 serial adaptor driver
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
USB Serial support registered for GSM modem (1-port)
usbcore: registered new interface driver option
option: v0.7.2:USB Driver for GSM modems
s3c2440-usbgadget s3c2440-usbgadget: S3C2440: increasing FIFO to 128 bytes
mousedev: PS/2 mouse device common for all mice
input: gpio-keys as /devices/platform/gpio-keys/input/input0
samsung-ts s3c2440-ts: driver attached, registering input device
input: S3C24XX TouchScreen as /devices/virtual/input/input1
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
ALSA device list:
  No soundcards found.
Netfilter messages via NETLINK v0.30.
nf_conntrack version 0.5.0 (917 buckets, 3668 max)
ctnetlink v0.93: registering with nfnetlink.
xt_time: kernel timezone is -0000
ip_set: protocol 6
IPVS: Registered protocols (TCP, UDP, AH, ESP)
IPVS: Connection hash table configured (size=4096, memory=32Kbytes)
IPVS: Creating netns size=1008 id=0
IPVS: ipvs loaded.
IPVS: [rr] scheduler registered.
IPVS: [wrr] scheduler registered.
IPVS: [lc] scheduler registered.
IPVS: [wlc] scheduler registered.
IPVS: [lblc] scheduler registered.
IPVS: [lblcr] scheduler registered.
IPVS: [dh] scheduler registered.
IPVS: [sh] scheduler registered.
IPVS: [sed] scheduler registered.
IPVS: [nq] scheduler registered.
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_CLUSTERIP: ClusterIP Version 0.8 loaded successfully
arp_tables: (C) 2002 David S. Miller
TCP cubic registered
NET: Registered protocol family 17
Registering the dns_resolver key type
usb 1-1: new full speed USB device number 2 using s3c2410-ohci
usb 1-1: New USB device found, idVendor=05e3, idProduct=0606
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 1-1: Product: USB Hub 2.0
hub 1-1:1.0: USB hub found
hub 1-1:1.0: 4 ports detected
Empty flash at 0x007c1720 ends at 0x007c1800
Empty flash at 0x007d3024 ends at 0x007d3800
Empty flash at 0x00e347b0 ends at 0x00e34800
Empty flash at 0x00e3a454 ends at 0x00e3a800
Empty flash at 0x010a8b70 ends at 0x010a9000
Empty flash at 0x010ab928 ends at 0x010ac000
Empty flash at 0x010b3ac8 ends at 0x010b4000
Empty flash at 0x010b5100 ends at 0x010b5800
Empty flash at 0x0174d84c ends at 0x0174e000
Empty flash at 0x032f5018 ends at 0x032f5800
Empty flash at 0x0332602c ends at 0x03326800
Empty flash at 0x0332f980 ends at 0x03330000
Empty flash at 0x03e6988c ends at 0x03e6a000
Freeing init memory: 140K
dm9000 dm9000: eth0: link down


Copyright (C) 2017 zoulei121<zouleix@gmail.com>
root login: root

Password:


OK!





原创粉丝点击