Linux-2.6.32.67内核裁剪与移植之内核启动与根文件系统制作(1)

时间:2022-09-19 09:06:10

                         Linux-2.6.32.67内核裁剪与移植之内核启动与根文件系统制作

                                                                                                     作者:赵凯

                                                                                 QQ: 1205958201

                                                第一部分:内核启动与根文件系统制作

 注:转载请注明出处哦!

1.      修改内核以支持s3c2440开发板

在顶层的makefile中,将

ARCH             ?= $(SUBARCH)

CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

修改为:

ARCH            ?= arm

CROSS_COMPILE?= arm-linux-

2.      修改内核中的时钟设置

进入/arch/arm/mach-s3c2440/mach-smdk2440.c中,将

static void __init smdk2440_map_io(void)

{

s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));

s3c24xx_init_clocks(xxx);  //是多少搞忘了,改成12M

s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));

}修改为

static void __init smdk2440_map_io(void)

{

s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));

s3c24xx_init_clocks(12000000);

s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));

}

然后执行命令:[root@localhost linux-4.1.2]# make s3c2410_defconfig;使用arch/arm/configs/s3c2410_defconfig文件来配置内核,它生成.config配置文件,以后可以使用make menuconfig修改配置了。执行上述命令的运行结果如下:

[root@localhost linux-2.6.32.67]# make s3c2410_defconfig

  HOSTCC  scripts/basic/fixdep

  HOSTCC  scripts/basic/docproc

  HOSTCC  scripts/basic/hash

  HOSTCC  scripts/kconfig/conf.o

  HOSTCC  scripts/kconfig/kxgettext.o

  SHIPPED scripts/kconfig/zconf.tab.c

  SHIPPED scripts/kconfig/lex.zconf.c

  SHIPPED scripts/kconfig/zconf.hash.c

  HOSTCC  scripts/kconfig/zconf.tab.o

  HOSTLD  scripts/kconfig/conf

#

# configuration written to .config

#执行命令:make uImage生成uImage镜像;

这个时候出现错误:

"mkimage" command not found - U-Boot images will not be built

make[1]: *** [arch/arm/boot/uImage]错误 1

make: *** [uImage]错误 2

解决方法:

由于前几天移植uboot,在uboot源码目录下tools目录中已经生成了mkimage,只需要将其路径在环境变量中声明即可,在etc/bashrc文件的末尾添加如下语句:

export PATH:=$PATH/Mydir/u-boot-2014.04/tools

然后更新一下bashrc脚本:source /etc/bashrc

但是这样不保险,因为后面可能清除掉mkimage,保险的做法是将mkimage复制到/usr/bin目录下,可以用echo $PATH看下PATH的内容,可以看到包含/usr/bin路径,这时候不用进行修改。这里采用第二种方法。

然后继续执行命令:make uImage生成uImage镜像,输出的结果如下:

CHK     include/config/kernel.release

  CHK     include/generated/uapi/linux/version.h

  CHK     include/generated/utsrelease.h

make[1]: include/generated/mach-types.h”是最新的。

  CHK     include/generated/bounds.h

  CHK     include/generated/asm-offsets.h

  CALL    scripts/checksyscalls.sh

  CHK     include/generated/compile.h

  Kernel: arch/arm/boot/Image is ready

  Kernel: arch/arm/boot/zImage is ready

  UIMAGE  arch/arm/boot/uImage

Image Name:   Linux-4.1.2

Created:      Thu Jul 16 22:59:31 2015

Image Type:   ARM Linux Kernel Image (uncompressed)

Data Size:    2808992 Bytes = 2743.16 kB = 2.68 MB

Load Address: 30108000

Entry Point:  30108000

  Image arch/arm/boot/uImage is ready

这个时候可以将生成的uImage拷贝到tftp目录,然后下载到开发板上:

[root@localhost linux-4.1.2]# cd arch/arm/boot

[root@localhost boot]# cp uImage /var/lib/tftpboot

启动开发板:

ZK2440 # tftp 0x32000000 uImage

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

DM9000: running in 16 bit mode

MAC: 0a:1b:2c:3d:4e:5f

operating at 100M full duplex mode

Using dm9000 device

TFTP from server 192.168.1.8; our IP address is 192.168.1.6

Filename 'uImage'.

Load address: 0x32000000

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

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

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

         402.3 KiB/s

done

Bytes transferred = 2809056 (2adce0 hex)

提示下载成功,然后从0x32000000启动,可以看到内核的打印信息:

EmbedSky> tftp 0x32000000 uImage

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

MAC: 0a:1b:2c:3d:4e:5f

TFTP from server 192.168.1.8; our IP address is 192.168.1.6

Filename 'uImage'.

Load address: 0x32000000

Loading: checksum bad

checksum bad

checksum bad

checksum bad

checksum bad

T #################################################################

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

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

done

Bytes transferred = 2809000 (2adca8 hex)

EmbedSky> bootm 0x32000000

## Booting image at 32000000 ...

   Image Name:   Linux-4.1.2

   Created:      2015-07-17   4:28:37 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    2808936 Bytes =  2.7 MB

   Load Address: 30108000

   Entry Point:  30108000

   Verifying Checksum ... OK

OK

 

Starting kernel ...

 

Uncompressing Linux... done, booting the kernel.

 

Error: unrecognized/unsupported machine ID (r1 = 0x000000a8).

。。。。。。。。。

内核无法正常启动,因为Linux内核中的机器码一定要与bootloader的机器码一致,否则便会出现内核启动不了。在u-bootkernel中都会有一个机器码(即:MACH_TYPE),只有这两个机器码一致时才能引导内核。

可以查看下我的uboot机器码,如下

ZK2440 # bdinfo

arch_number = 0x000000C1(对应十进制193

boot_params = 0x30000100

DRAM bank   = 0x00000000

-> start    = 0x30000000

-> size     = 0x04000000

eth0name    = dm9000

ethaddr     = 0a:1b:2c:3d:4e:5f

current eth = dm9000

ip_addr     = 192.168.1.6

baudrate    = 115200 bps

TLB addr    = 0x33FF0000

relocaddr   = 0x33FB4000

reloc off   = 0x33FB4000

irq_sp      = 0x33D93F40

sp start    = 0x33D93F30

修改内核中的机器码,与uboot中的一致,打开arch/arm/tools/mach-types文件,修改第87行如下

s3c2440          ARCH_S3C2440        S3C2440         193

重新编译make uImage,然后下载到开发板中运行

 

 

ZK2440 # bootm 0x32000000

 

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

   Image Name:   Linux-2.6.32.67

   Created:      2015-07-17  17:16:30 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    1996676 Bytes = 1.9 MiB

   Load Address: 30008000

   Entry Point:  30008000

   Verifying Checksum ... OK

   Loading Kernel Image ... OK

 

Starting kernel ...

 

Uncompressing Linux............................................................................................................................... done, booting the kernel.

Linux version 2.6.32.67 (root@localhost.localdomain) (gcc version 4.4.4 (crosstool-NG-1.11.1) ) #2 Sat Jul 18 01:16:20 CST 2015

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, (c) 2004 Simtec Electronics

S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 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: root=/dev/hda1 ro init=/bin/bash console=ttySAC0

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: 60712KB available (3684K code, 321K data, 132K init, 0K highmem)

Hierarchical RCU implementation.

NR_IRQS:85

irq: clearing pending ext status 00080000

irq: clearing subpending status 00000003

irq: clearing subpending status 00000002

Console: colour dummy device 80x30

console [ttySAC0] enabled

Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

NET: Registered protocol family 16

S3C Power Management, Copyright 2004 Simtec Electronics

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics

DMA channel 0 at c4808000, irq 33

DMA channel 1 at c4808040, irq 34

DMA channel 2 at c4808080, irq 35

DMA channel 3 at c48080c0, irq 36

S3C244X: Clock Support, DVS off

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 97 KHz

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

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

NET: Registered protocol family 1

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

NetWinder Floating Point Emulator V0.97 (extended precision)

JFFS2 version 2.2. (NAND) (SUMMARY)  2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 118

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler deadline registered

io scheduler cfq registered

Console: switching to colour frame buffer device 30x40

fb0: s3c2410fb frame buffer device

lp: driver loaded but no devices found

ppdev: user-space parallel port driver

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

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

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

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

brd: module loaded

loop: module loaded

Uniform Multi-Platform E-IDE driver

ide-gd driver 1.18

ide-cd driver 5.00

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

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

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 1158 at 0x0000090c0000

Bad eraseblock 1590 at 0x00000c6c0000

Bad eraseblock 1975 at 0x00000f6e0000

Creating 8 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000004000 : "Boot Agent"

mtd: partition "Boot Agent" doesn't end on an erase block -- force read-only

0x000000000000-0x000000200000 : "S3C2410 flash partition 1"

0x000000400000-0x000000800000 : "S3C2410 flash partition 2"

0x000000800000-0x000000a00000 : "S3C2410 flash partition 3"

0x000000a00000-0x000000e00000 : "S3C2410 flash partition 4"

0x000000e00000-0x000001800000 : "S3C2410 flash partition 5"

0x000001800000-0x000003000000 : "S3C2410 flash partition 6"

0x000003000000-0x000004000000 : "S3C2410 flash partition 7"

dm9000 Ethernet Driver, V1.31

usbmon: debugfs is not available

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: configuration #1 chosen from 1 choice

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

usbcore: registered new interface driver libusual

usbcore: registered new interface driver usbserial

USB Serial support registered for generic

usbcore: registered new interface driver usbserial_generic

usbserial: USB Serial Driver core

USB Serial support registered for FTDI USB Serial Device

usbcore: registered new interface driver ftdi_sio

ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver

USB Serial support registered for pl2303

usbcore: registered new interface driver pl2303

pl2303: Prolific PL2303 USB to serial adaptor driver

mice: PS/2 mouse device common for all mice

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

Advanced Linux Sound Architecture Driver Version 1.0.21.

No device for DAI UDA134X

No device for DAI s3c24xx-i2s

ALSA device list:

  No soundcards found.

TCP cubic registered

NET: Registered protocol family 17

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

Root-NFS: No NFS server available, giving up.

VFS: Unable to mount root fs via NFS, trying floppy.

VFS: Cannot open root device "hda1" or unknown-block(2,0)

Please append a correct "root=" boot option; here are the available partitions:

1f00              16 mtdblock0 (driver?)

1f01            2048 mtdblock1 (driver?)

1f02            4096 mtdblock2 (driver?)

1f03            2048 mtdblock3 (driver?)

1f04            4096 mtdblock4 (driver?)

1f05           10240 mtdblock5 (driver?)

1f06           24576 mtdblock6 (driver?)

1f07           16384 mtdblock7 (driver?)

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

Backtrace:

[<c002daa8>] (dump_backtrace+0x0/0x114) from [<c02ec398>] (dump_stack+0x18/0x1c)

 r6:00008001 r5:c3884000 r4:c03e59e4

[<c02ec380>] (dump_stack+0x0/0x1c) from [<c02ec3e8>] (panic+0x4c/0x11c)

[<c02ec39c>] (panic+0x0/0x11c) from [<c00090fc>] (mount_block_root+0x1d8/0x218)

 r3:00000000 r2:00000000 r1:c381bf64 r0:c0367236

[<c0008f24>] (mount_block_root+0x0/0x218) from [<c0009200>] (mount_root+0xc4/0xfc)

[<c000913c>] (mount_root+0x0/0xfc) from [<c00093a4>] (prepare_namespace+0x16c/0x1c0)

 r5:c0025829 r4:c03e5314

[<c0009238>] (prepare_namespace+0x0/0x1c0) from [<c0008630>] (kernel_init+0xe8/0x120)

 r5:c00240cc r4:c03e50e0

[<c0008548>] (kernel_init+0x0/0x120) from [<c004cda8>] (do_exit+0x0/0x5dc)

 r5:00000000 r4:00000000

3.  修改MTD分区

修改/arch/arm/plat-s3c24xx/common-smdk.c文件中的smdk_default_nand_part结构即可。

static struct mtd_partition smdk_default_nand_part[] = {

[0] = {

     .name   = "kernel",

     .size   = SZ_4M,

     .offset = 0,

},

[1] = {

     .name   = "jffs2",

     .offset = MTDPART_OFS_APPEND,

     .size   = SZ_8M,

},

[2] = {

     .name   = "yaffs",

     .offset = MTDPART_OFS_APPEND,

     .size   = MTDPART_SIZ_FULL,

}

};

MTDPART_OFS_APPEND表示当前分区紧接着上一个分区,MTDPART_SIZ_FULL表示当前分区大小为剩余的flash空间。

[root@localhost linux-4.1.2]# cp arch/arm/boot/uImage /var/lib/tftpboot

然后打开开发板,从norflash启动:

输出结果如下:

…….

Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000400000 : "kernel"

0x000000400000-0x000000c00000 : "jffs2"

0x000000c00000-0x000010000000 : "yaffs"

dm9000 Ethernet Driver, V1.31

……

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0

由于没有写入文件系统镜像,所以内核启动还是会出现panic信息。

 

4.  支持YAFFS文件系统

 

首先需要获取源码:这里我从linux.linuxidc.com网站下载的,用户名字和密码都是linux.linuxidc.com,具体下载目录在http://linux.linuxidc.com/pub/2011/06/28/YAFFS2/

下载文件为yaffs2-2df51cd

下载之后放到内核的同一级目录下。然后解压:

cp /home/zkpingguo/桌面/linux2.6.39.2_yaffs2.tar.gz  /Mydir/

tar -xvf linux2.6.39.2_yaffs2.tar.gz

给内核打补丁:

进入yaffs2-2df51cd源码目录执行命令:

[root@localhost yaffs2-2df51cd]# ./patch-ker.sh c m /Mydir/linux-2.6.32.67

Updating /Mydir/linux-2.6.32.67/fs/Kconfig

Updating /Mydir/linux-2.6.32.67/fs/Makefile

这个时候可以在linux内核目录下fs目录中看到yaffs2目录

[root@localhost fs]# cd yaffs2/

[root@localhost yaffs2]# ls

Kconfig               yaffs_linux.h        yaffs_summary.c

Makefile              yaffs_mtdif1.c       yaffs_summary.h

yaffs_allocator.c     yaffs_mtdif1.h       yaffs_tagscompat.c

yaffs_allocator.h     yaffs_mtdif2.c       yaffs_tagscompat.h

yaffs_attribs.c       yaffs_mtdif2.h       yaffs_trace.h

yaffs_attribs.h       yaffs_mtdif.c        yaffs_verify.c

yaffs_bitmap.c        yaffs_mtdif.h        yaffs_verify.h

yaffs_bitmap.h        yaffs_nameval.c      yaffs_vfs.c

yaffs_checkptrw.c     yaffs_nameval.h      yaffs_yaffs1.c

yaffs_checkptrw.h     yaffs_nand.c         yaffs_yaffs1.h

yaffs_ecc.c           yaffs_nand.h         yaffs_yaffs2.c

yaffs_ecc.h           yaffs_packedtags1.c  yaffs_yaffs2.h

yaffs_getblockinfo.h  yaffs_packedtags1.h  yportenv.h

yaffs_guts.c          yaffs_packedtags2.c

yaffs_guts.h          yaffs_packedtags2.h

然后编译配置内核:

Make menuconfig进入配置界面:

File System à

     Miscellaneous filesystemsà

           <*>YAFFS file system support.

然后烧写内核:

ZK2440 # tftp 0x32000000 uImage

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

DM9000: running in 16 bit mode

MAC: 0a:1b:2c:3d:4e:5f

operating at 100M full duplex mode

Using dm9000 device

TFTP from server 192.168.1.8; our IP address is 192.168.1.6

Filename 'uImage'.

Load address: 0x32000000

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

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

         ##########

         175.8 KiB/s

done

Bytes transferred = 2042988 (1f2c6c hex)

ZK2440 # nand erase 0 0x400000

 

NAND erase: device 0 offset 0x0, size 0x400000

Erasing at 0x3e0000 -- 100% complete.

OK

ZK2440 # nand write.yaffs2 0x32000000 0 0x3e0000  

NAND write: device 0 offset 0x0, size 0x3e0000

Unknown nand command suffix '.yaffs2'.

ZK2440 # nand write.jffs2 0x32000000 0 0x3e0000

 

NAND write: device 0 offset 0x0, size 0x3e0000

 4063232 bytes written: OK

然后启动内核

ZK2440 # nboot 32000000 0 0

Loading from nand0, offset 0x0

  Image Name:   Linux-2.6.32.67

  Created:      2015-07-18   4:54:04 UTC

  Image Type:   ARM Linux Kernel Image (uncompressed)

  Data Size:    2042924 Bytes = 1.9 MiB

  Load Address: 30008000

  Entry Point:  30008000

ZK2440 # bootm 0x32000000

nboot 指令也是一条Nand Flash 读取指令,它是将Nand Flash 的 offset 偏移地址的内核映像读取到SDRAM的loadAddr位置。它会自动读取到内核映像(使用mkimage处理过的)的结束,所以不用给出读取大小。
格式:nboot  loadAddr  dev  offset

最终的输出结果如下:

K2440 # bootm 0x32000000

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

  Image Name:   Linux-2.6.32.67

  Created:      2015-07-18  14:08:17 UTC

  Image Type:   ARM Linux Kernel Image (uncompressed)

  Data Size:    2042924 Bytes = 1.9 MiB

  Load Address: 30008000

  Entry Point:  30008000

  Verifying Checksum ... OK

  Loading Kernel Image ... OK

 

Starting kernel ...

 

Uncompressing Linux.................................................................................................................................. done, booting the kernel.

Linux version 2.6.32.67 (root@localhost.localdomain) (gcc version 4.4.4 (crosstool-NG-1.11.1) ) #4 Sat Jul 18 12:53:52 CST 2015

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, (c) 2004 Simtec Electronics

S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 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: root=/dev/hda1 ro init=/bin/bash console=ttySAC0

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: 60620KB available (3772K code, 321K data, 132K init, 0K highmem)

Hierarchical RCU implementation.

NR_IRQS:85

irq: clearing pending ext status 00080000

irq: clearing subpending status 00000003

irq: clearing subpending status 00000002

Console: colour dummy device 80x30

console [ttySAC0] enabled

Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

NET: Registered protocol family 16

S3C Power Management, Copyright 2004 Simtec Electronics

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics

DMA channel 0 at c4808000, irq 33

DMA channel 1 at c4808040, irq 34

DMA channel 2 at c4808080, irq 35

DMA channel 3 at c48080c0, irq 36

S3C244X: Clock Support, DVS off

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 97 KHz

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

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

NET: Registered protocol family 1

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

NetWinder Floating Point Emulator V0.97 (extended precision)

JFFS2 version 2.2. (NAND) (SUMMARY)  2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 118

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler deadline registered

io scheduler cfq registered

Console: switching to colour frame buffer device 30x40

fb0: s3c2410fb frame buffer device

lp: driver loaded but no devices found

ppdev: user-space parallel port driver

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

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

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

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

brd: module loaded

loop: module loaded

Uniform Multi-Platform E-IDE driver

ide-gd driver 1.18

ide-cd driver 5.00

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

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

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 1158 at 0x0000090c0000

Bad eraseblock 1590 at 0x00000c6c0000

Bad eraseblock 1975 at 0x00000f6e0000

Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000400000 : "kernel"

0x000000400000-0x000000c00000 : "jffs2"

0x000000c00000-0x000010000000 : "yaffs"

dm9000 Ethernet Driver, V1.31

usbmon: debugfs is not available

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: configuration #1 chosen from 1 choice

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

usbcore: registered new interface driver libusual

usbcore: registered new interface driver usbserial

USB Serial support registered for generic

usbcore: registered new interface driver usbserial_generic

usbserial: USB Serial Driver core

USB Serial support registered for FTDI USB Serial Device

usbcore: registered new interface driver ftdi_sio

ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver

USB Serial support registered for pl2303

usbcore: registered new interface driver pl2303

pl2303: Prolific PL2303 USB to serial adaptor driver

mice: PS/2 mouse device common for all mice

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

Advanced Linux Sound Architecture Driver Version 1.0.21.

No device for DAI UDA134X

No device for DAI s3c24xx-i2s

ALSA device list:

 No soundcards found.

TCP cubic registered

NET: Registered protocol family 17

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

Root-NFS: No NFS server available, giving up.

VFS: Unable to mount root fs via NFS, trying floppy.

VFS: Cannot open root device "hda1" or unknown-block(2,0)

Please append a correct "root=" boot option; here are the available partitions:

1f00           4096 mtdblock0 (driver?)

1f01           8192 mtdblock1 (driver?)

1f02         249856 mtdblock2 (driver?)

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

Backtrace:

[<c002daa8>] (dump_backtrace+0x0/0x114) from [<c02fd6d8>] (dump_stack+0x18/0x1c)

 r6:00008001 r5:c3886000 r4:c03fba24

[<c02fd6c0>] (dump_stack+0x0/0x1c) from [<c02fd728>] (panic+0x4c/0x11c)

[<c02fd6dc>] (panic+0x0/0x11c) from [<c00090fc>] (mount_block_root+0x1d8/0x218)

 r3:00000000 r2:00000000 r1:c381bf64 r0:c0379e06

[<c0008f24>] (mount_block_root+0x0/0x218) from [<c0009200>] (mount_root+0xc4/0xfc)

[<c000913c>] (mount_root+0x0/0xfc) from [<c00093a4>] (prepare_namespace+0x16c/0x1c0)

 r5:c0025829 r4:c03fb354

[<c0009238>] (prepare_namespace+0x0/0x1c0) from [<c0008630>] (kernel_init+0xe8/0x120)

 r5:c00241e0 r4:c03fb120

[<c0008548>] (kernel_init+0x0/0x120) from [<c004cda8>] (do_exit+0x0/0x5dc)

 r5:00000000 r4:00000000

可以看到yaffs文件系统并没有成功挂载。提示不能打开hda1分区。

解决办法:make menuconfig

boot options里面的Default kernel command string一项中

更改如下:

root=/dev/mtdblock0 ro init=/bin/bash console=ttySAC0

然后保存,编译生成uImage,利用如下命令下载,编译

tftp 0x32000000 uImage;nand erase 0 0x400000; nand write.jffs2 0x32000000 0 0x3e0000

nboot 0x32000000 0 0;bootm 0x32000000

结果如下:

。。。。。。

yaffs: dev is 32505856 name is "mtdblock0" ro

yaffs: passed flags ""

VFS: Mounted root (yaffs filesystem) readonly on device 31:0.

Freeing init memory: 132K

Warning: unable to open an initial console.

Failed to execute /bin/bash. Attempting defaults...

Kernel panic - not syncing: No init found. Try passing init= option to kernel.

。。。。。。

查看init/main.c中的函数

static noinline int init_post(void)

__releases(kernel_lock)

{

/* need to finish all async __init code before freeing the memory */

async_synchronize_full();

free_initmem();

unlock_kernel();

mark_rodata_ro();

system_state = SYSTEM_RUNNING;

numa_default_policy();

 

if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)

       printk(KERN_WARNING "Warning: unable to open an initial console.\n");

 

(void) sys_dup(0);

(void) sys_dup(0);

 

current->signal->flags |= SIGNAL_UNKILLABLE;

 

if (ramdisk_execute_command) {

       run_init_process(ramdisk_execute_command);

       printk(KERN_WARNING "Failed to execute %s\n",

                     ramdisk_execute_command);

}

 

/*

 * We try each of these until one succeeds.

 *

 * The Bourne shell can be used instead of init if we are

 * trying to recover a really broken machine.

 */

if (execute_command) {

       run_init_process(execute_command);

       printk(KERN_WARNING "Failed to execute %s.  Attempting "

                            "defaults...\n", execute_command);

}

run_init_process("/sbin/init");

run_init_process("/etc/init");

run_init_process("/bin/init");

run_init_process("/bin/sh");

 

panic("No init found.  Try passing init= option to kernel.");

}

就是说,它会依次尝试执行/sbin/init/etc/init/bin/init/bin/sh这些文件,都失败后才打印出错信息"No init found.  Try passing init= option to kernel."

上述过程只是配置内核支持yaffs文件系统,实际是我们需要制作yaffs文件系统,然后烧录yaffs系统,才能消除错误。

 

5.  Yaffs文件系统制作

 

准备工作:

建立根文件系统,包含必要的目录。

[zkpingguo@localhost Mydir]$ mkdir root_2.6.32

[root@localhost root_2.6.32]# mkdir bin etc dev home lib mnt opt proc root sbin sys tmp usr var

编译busybox

获取busybox源码:http://www.busybox.net/downloads/,下载

busybox-1.16.2.tar.bz2,放到Mydir目录下,与root_2.6.32目录平级,然后解压

#tar xjvf busybox-1.16.2.tar.bz2

进入busybox源码目录,修改Makefile164行:

CROSS_COMPILE = arm-linux-

190行: ARCH ?= $(SUBARCH)改为

ARCH = arm

然后执行 make menuconfigbusybox进行配置

Busybox Setting --->

Build Options --->

[*]Build Busybox as a static binary(no shared libs)

[*]Build with Large File Support (for accessing files > 2GB)

Installation Options --->

(./_install) Busybox installation prefix<进入这个选项,输入busybox的安装路径,

如:../rootfs

Busybox Library Tuning --->

[*] vi-style line editing commands

[*] Fancy shell prompts<要选择这个选项:Fancy shell prompts,否则挂载文

件系统后,无法正常显示命令提示符:[\u@\h \W]#

配置完后,先执行make,然后执行#make install,然后就会在上一级目录下生成rootfs文件夹,里面包含几个文件夹/bin/sbin/usrlinuxrc。把这些文件全部复制到刚建好的root_2.6.32目录下。

[root@localhost rootfs]# cp -rf * ../root_2.6.32/

制作文件系统:

dev目录下,创建两个设备节点:

[root@localhost dev]# mknod console c 5 1

[root@localhost dev]# mknod null c 1 3

进入etc目录,添加文件:

1)拷贝Busybox-1.15.2/examples/bootfloopy/etc/*到当前目录下。

[root@localhost etc]# cp -r /Mydir/busybox-1.16.2/examples/bootfloppy/etc/* /Mydir/root_2.6.32/etc

包括的文件:fstabinit.dinittabprofile

2)拷贝/etc/passwd/etc/group/etc/shadow到当前目录下。

[root@localhost etc]# cp /etc/passwd  /Mydir/root_2.6.32/etc/

[root@localhost etc]# cp /etc/group  /Mydir/root_2.6.32/etc/

[root@localhost etc]# cp /etc/shadow  /Mydir/root_2.6.32/etc/

passwd文件中的第一行:root:x:0:0:root:/root:/bin/bash中的/bin/bash,改成/bin/ash,因为文件系统的bin目录下没有bash这个命令,而是用ash代替bash,所以在用用户名密码登录的时候(telnet),会出现“cannot run /bin/bash: No such fileor directory”的错误。

3)修改inittab文件:

内容如下:

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

ttyS0::respawn:-/bin/sh

s3c2410_serial0::askfirst:-/bin/sh

::once:/usr/sbin/telnetd -l /bin/login

::ctrlaltdel:/bin/umount -a –r

4)修改fstab文件,内容如下:

proc        /proc   proc    defaults    0   0

tmpfs           /tmp    tmpfs   defaults    0   0

sysfs           /sys    sysfs   defaults    0   0

tmpfs           /dev    tmpfs   defaults    0   0

var             /dev    tmpfs   defaults    0   0

5)修改init.d/rcS文件,内容如下:

#!/bin/sh

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

runlevel=S

prevlevel=N

umask 022

export PATH runlevel prevlevel

mount -a

mkdir /dev/pts

mount -t devpts devpts /dev/pts

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

mdev -s

mkdir -p /var/lock

/bin/hostname -F /etc/sysconfig/HOSTNAME

6)修改profile文件,内容如下:

# Ash profile

# vim: syntax=sh

# No core files by default

#ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"

LOGNAME=$USER

PS1='[\u@\h \W]# '

PATH=$PATH

HOSTNAME=`/bin/hostname`

echo "Processing /etc/profile... "

echo "Done"

export USER LOGNAME PS1 PATH

7)新建sysconfig文件夹(etc目录下),在里面新建HOSTNAME文件,内容为:ZK2440

 

 

8)拷贝库文件:

进入lib目录,拷贝交叉编译器的库文件到lib目录下,

cp –f –a /root/x-tools/arm-zk-linux-gnueabi/lib/* /Mydir/root_2.6.32/lib

9)到这里,文件系统框架已经做好,我们需要把文件系统制作成可以烧写进Nandflash中的yaffs2镜像文件。使用mkyaffs2image工具,制作yaffs2镜像,这个工具是在yaffs2源码包中utils目录下的mkyaffs2image.c文件编译得到的,如果使用的是大页NAND,需要修改源码。

这里,我从tq2440资料包中的linux平台资源中直接将mkyaffs2image文件拷贝到虚拟机中,然后复制到/usr/bin目录下:

[root@localhost Mydir]# cp mkyaffs2image /usr/bin

然后制作文件系统:

[root@localhost Mydir]# mkyaffs2image root_2.6.32 root_2.6.32.bin

结果报错:

bash: /usr/bin/mkyaffs2image: /lib/ld-linux.so.2: bad ELF interpreter:没有那个文件或目录

这个mkyaffs2image32位的,但是redhat sever64位的所以无法运行。

目前的解决方法有两个:

第一是下载yaffs2源码包,然后在utils目录下make一下,生成mkyaffs2image工具;

第二是安装32位的glibc工具。

这里先采用第二种方法试试:yum install glibc-2.12-1.47.el6.i686.rpm;这个时候报错:

Error: Package: glibc-2.12-1.47.el6.i686 (/glibc-2.12-1.47.el6.i686)

           Requires: libfreebl3.so(NSSRAWHASH_3.12.3)

Error: Package: glibc-2.12-1.47.el6.i686 (/glibc-2.12-1.47.el6.i686)

           Requires: libfreebl3.so

 

大致看了下,如果要解决依赖问题,需要手动安装几十个安装包,从网上找到一个办法,就是如下两个包一起安装即可

[root@localhost Packages]# rpm -ivh glibc-2.12-1.47.el6.i686.rpm nss-softokn-freebl-3.12.9-11.el6.i686.rpm

warning: glibc-2.12-1.47.el6.i686.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

Preparing...                ########################################### [100%]

   1:nss-softokn-freebl     ########################################### [ 50%]

   2:glibc                  ########################################### [100%]

问题得到解决。

 

然后在Mydir目录下键入命令:

[root@localhost Mydir]# mkyaffs2image root_2.6.32 root_2.6.32.bin

生成bin文件。然后改变root_2.6.32.bin文件的权限。

[root@localhost Mydir]# chmod 777 root_2.6.32.bin

最后,将root_2.6.32.bin放到var/lib/tftpboot目录下,打开开发板,从norflash启动,然后下载镜像文件。

ZK2440 # tftp 0x32000000 root_2.6.32.bin

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

DM9000: running in 16 bit mode

MAC: 0a:1b:2c:3d:4e:5f

operating at 100M full duplex mode

Using dm9000 device

TFTP from server 192.168.1.8; our IP address is 192.168.1.6

Filename 'root_2.6.32.bin'.

Load address: 0x32000000

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

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

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

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

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

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

         581.1 KiB/s

done

Bytes transferred = 5111040 (4dfd00 hex)

ZK2440 # nand erase 0xc00000 $filesize             

 

NAND erase: device 0 offset 0xc00000, size 0x1f00000

Erasing at 0x2ae0000 -- 100% complete.

OK

ZK2440 # nand write.jffs2 0x32000000 c00000 1f00000

NAND write: device 0 offset 0xc00000, size 0x1f00000

 32505856 bytes written: OK

ZK2440 #

然后可以修改命令行参数以MTD2分区作为根文件系统,在uboot控制界面下设置如下:

ZK2440 # set bootargs noinitrd console=ttySAC0 root=/dev/mtdblock2 rootfstype=yaffs

ZK2440 # saveenv

注意:以上设置的是uboot的启动参数。。。。。

Saving Environment to Flash...

Un-Protected 2 sectors

Erasing Flash...

.. done

Erased 2 sectors

Writing to Flash... 9....8....7....6....5....4....3....2....1....done

Protected 2 sectors

最后烧写linux内核:

ZK2440 # tftp 0x32000000 uImage;nand erase 0 400000

;nand write 0x32000000 0 0x3e0000

ZK2440 # nboot 0x32000000 0 0;bootm 0x32000000

这个时候出现错误:

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

yaffs: dev is 32505858 name is "mtdblock2" rw

yaffs: passed flags ""

VFS: Mounted root (yaffs filesystem) on device 31:2.

Freeing init memory: 160K

Warning: unable to open an initial console.

Kernel panic - not syncing: No init found.  Try passing init= option to kernel.

Backtrace:

原因:目前移植的uboot不支持yaffs文件的烧写,修改uboot使其支持yaffs文件的烧写(详见uboot2014的移植文档),nand write.jffs2 0x32000000 c00000 1f00000这句话有问题,当改成nand write.yaffs 0x32000000 c00000 1f00000后,重复上面烧写yaffs文件系统的步骤,又出现错误:

ZK2440 # nand write.yaffs 0x32000000 c00000 1f00000

NAND write: device 0 offset 0xc00000, size 0x1f00000

Attempt to write incomplete page in yaffs mode

 32505856 bytes written: ERROR

然后改成这样ZK2440 # nand write.yaffs 0x32000000 c00000 $filesize表示只烧写文件长度。

结果如下:

ZK2440 # nand write.yaffs 0x32000000 c00000 $filesize

NAND write: device 0 offset 0xc00000, size 0x4dfd00

 5111040 bytes written: OK
然后开始烧写内核,将命令贴出,与前面的命令有些区别:

ZK2440 # tftp 0x32000000 uImage;nand erase 0 400000

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

DM9000: running in 16 bit mode

MAC: 0a:1b:2c:3d:4e:5f

operating at 100M full duplex mode

Using dm9000 device

TFTP from server 192.168.1.8; our IP address is 192.168.1.6

Filename 'uImage'.

Load address: 0x32000000

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

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

         ##########

         323.2 KiB/s

done

Bytes transferred = 2044580 (1f32a4 hex)

 

NAND erase: device 0 offset 0x0, size 0x400000

Erasing at 0x3e0000 -- 100% complete.

OK

ZK2440 # nand write.jffs2 0x32000000 0 $filesize

 

NAND write: device 0 offset 0x0, size 0x1f32a4

 2044580 bytes written: OK

ZK2440 # nboot 0x32000000 0 0;bootm 0x32000000

 

Loading from nand0, offset 0x0

   Image Name:   Linux-2.6.32.67

   Created:      2015-07-26   7:50:17 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    2044516 Bytes = 1.9 MiB

   Load Address: 30008000

   Entry Point:  30008000

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

   Image Name:   Linux-2.6.32.67

   Created:      2015-07-26   7:50:17 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    2044516 Bytes = 1.9 MiB

   Load Address: 30008000

   Entry Point:  30008000

   Verifying Checksum ... OK

   Loading Kernel Image ... OK

 

Starting kernel ...

 

Uncompressing Linux.................................................................................................................................... done, booting the kernel.

Linux version 2.6.32.67 (root@localhost.localdomain) (gcc version 4.3.2 (crosstool-NG-1.9.3) ) #5 Sun Jul 26 15:50:07 CST 2015

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

CPU: VIVT data cache, VIVT instruction cache

Machine: SMDK2410

Memory policy: ECC disabled, Data cache writeback

CPU S3C2440A (id 0x32440001)

S3C24XX Clocks, (c) 2004 Simtec Electronics

S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 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 console=ttySAC0 root=/dev/mtdblock2 rootfstype=yaffs int=/init/bash

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: 60572KB available (3812K code, 338K data, 152K init, 0K highmem)

Hierarchical RCU implementation.

NR_IRQS:99

irq: clearing pending ext status 00080000

irq: clearing subpending status 00000003

irq: clearing subpending status 00000002

Console: colour dummy device 80x30

console [ttySAC0] enabled

Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

NET: Registered protocol family 16

S3C Power Management, Copyright 2004 Simtec Electronics

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics

DMA channel 0 at c4808000, irq 33

DMA channel 1 at c4808040, irq 34

DMA channel 2 at c4808080, irq 35

DMA channel 3 at c48080c0, irq 36

S3C244X: Clock Support, DVS off

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 97 KHz

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

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

NET: Registered protocol family 1

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

NetWinder Floating Point Emulator V0.97 (extended precision)

JFFS2 version 2.2. (NAND) (SUMMARY)  漏 2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 118

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler deadline registered

io scheduler cfq registered

s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach

s3c2410-lcd: probe of s3c2410-lcd failed with error -22

lp: driver loaded but no devices found

ppdev: user-space parallel port driver

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

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

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

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

brd: module loaded

loop: module loaded

Uniform Multi-Platform E-IDE driver

ide-gd driver 1.18

ide-cd driver 5.00

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

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

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 1158 at 0x0000090c0000

Bad eraseblock 1590 at 0x00000c6c0000

Bad eraseblock 1975 at 0x00000f6e0000

Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000400000 : "kernel"

0x000000400000-0x000000c00000 : "jffs2"

0x000000c00000-0x000010000000 : "yaffs"

dm9000 Ethernet Driver, V1.31

usbmon: debugfs is not available

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: configuration #1 chosen from 1 choice

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

usbcore: registered new interface driver libusual

usbcore: registered new interface driver usbserial

USB Serial support registered for generic

usbcore: registered new interface driver usbserial_generic

usbserial: USB Serial Driver core

USB Serial support registered for FTDI USB Serial Device

usbcore: registered new interface driver ftdi_sio

ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver

USB Serial support registered for pl2303

usbcore: registered new interface driver pl2303

pl2303: Prolific PL2303 USB to serial adaptor driver

mice: PS/2 mouse device common for all mice

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

Advanced Linux Sound Architecture Driver Version 1.0.21.

No device for DAI UDA134X

No device for DAI s3c24xx-i2s

ALSA device list:

  No soundcards found.

TCP cubic registered

NET: Registered protocol family 17

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

yaffs: dev is 32505858 name is "mtdblock2" rw

yaffs: passed flags ""

VFS: Mounted root (yaffs filesystem) on device 31:2.

Freeing init memory: 152K

Warning: unable to open an initial console.

Kernel panic - not syncing: No init found.  Try passing init= option to kernel.

Backtrace:

[<c0032980>] (dump_backtrace+0x0/0x10c) from [<c030a868>] (dump_stack+0x18/0x1c)

 r7:00000000 r6:00000000 r5:c0027a2c r4:c03eb994

[<c030a850>] (dump_stack+0x0/0x1c) from [<c030a8a8>] (panic+0x3c/0x128)

[<c030a86c>] (panic+0x0/0x128) from [<c002e61c>] (init_post+0x13c/0x174)

 r3:00000000 r2:00000002 r1:00000001 r0:c0387c43

[<c002e4e0>] (init_post+0x0/0x174) from [<c0008630>] (kernel_init+0xe8/0x11c)

 r4:c040f3f8

[<c0008548>] (kernel_init+0x0/0x11c) from [<c0055824>] (do_exit+0x0/0x5bc)

 r5:00000000 r4:00000000

同样的错误仍然无法消除。已经挂载上yaffs2 文件系统,因为yaffs 文件系统是好的,所以是u-boot 烧写yaffs 文件系统的问题。

YAFFS 中,文件是以固定大小的数据块进行存储的,块的大小可以是512 字节、1 024 字节或者2048字节。这种实现依赖于它能够将一个数据块头和每个数据块关联起来。每个文件(包括目录)都有一个数据块头与之相对应,数据块头中保存了ECC(Error Correction Code)和文件系统的组织信息,用于错误检测和坏块处理。TQ2440 开发板用的NAND FLASH 每页2k。

查看drivers/mtd/nand/nand_util.cnand_write_skip_bad()函数,修改如下:

if (!need_skip && !(flags & WITH_DROP_FFS)&& !(flags & WITH_YAFFS_OOB))

ops.mode = MTD_OOB_RAW;/*原来为AUTO,应该为原始*/

重新编译,烧写新的u-boot.bin,重新烧写yaffs文件系统。还是上述错误,说明问题的原因还是没有完全定位。

纠结了这么久,终于找到了问题的所在,现在是2015年7月31日零点50分,记录如下:

主要是两个问题:

1.制作yaffs根文件系统的编译器要与制作内核文件系统的编译器一致。

2.busybox的配置中忘记选上第一个了。

纠正上述两个错误后,重新制作根文件系统,然后重新烧写进入nandflash,最终内核的输出如下:

Loading from nand0, offset 0x0

   Image Name:   Linux-2.6.32.67

   Created:      2015-07-30  15:37:59 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    2141244 Bytes = 2 MiB

   Load Address: 30008000

   Entry Point:  30008000

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

   Image Name:   Linux-2.6.32.67

   Created:      2015-07-30  15:37:59 UTC

   Image Type:   ARM Linux Kernel Image (uncompressed)

   Data Size:    2141244 Bytes = 2 MiB

   Load Address: 30008000

   Entry Point:  30008000

   Verifying Checksum ... OK

   Loading Kernel Image ... OK

 

Starting kernel ...

 

Uncompressing Linux........................................................................................................................................ done, booting the kernel.

Linux version 2.6.32.67 (root@localhost.localdomain) (gcc version 4.3.2 (crosstool-NG-1.9.3) ) #15 Thu Jul 30 23:37:50 CST 2015

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

CPU: VIVT data cache, VIVT instruction cache

Machine: SMDK2410

Memory policy: ECC disabled, Data cache writeback

CPU S3C2440A (id 0x32440001)

S3C24XX Clocks, (c) 2004 Simtec Electronics

S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 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 console=ttySAC0 root=/dev/mtdblock2 rootfstype=yaffs init=/linuxrc

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: 60468KB available (3812K code, 338K data, 148K init, 0K highmem)

Hierarchical RCU implementation.

NR_IRQS:99

irq: clearing pending ext status 00080000

irq: clearing subpending status 00000003

irq: clearing subpending status 00000002

Console: colour dummy device 80x30

console [ttySAC0] enabled

Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)

Mount-cache hash table entries: 512

CPU: Testing write buffer coherency: ok

NET: Registered protocol family 16

S3C Power Management, Copyright 2004 Simtec Electronics

S3C2440: Initialising architecture

S3C2440: IRQ Support

S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics

DMA channel 0 at c4808000, irq 33

DMA channel 1 at c4808040, irq 34

DMA channel 2 at c4808080, irq 35

DMA channel 3 at c48080c0, irq 36

S3C244X: Clock Support, DVS off

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 97 KHz

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

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

NET: Registered protocol family 1

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

NetWinder Floating Point Emulator V0.97 (extended precision)

JFFS2 version 2.2. (NAND) (SUMMARY)  2001-2006 Red Hat, Inc.

ROMFS MTD (C) 2007 Red Hat, Inc.

msgmni has been set to 118

io scheduler noop registered

io scheduler anticipatory registered (default)

io scheduler deadline registered

io scheduler cfq registered

s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach

s3c2410-lcd: probe of s3c2410-lcd failed with error -22

lp: driver loaded but no devices found

ppdev: user-space parallel port driver

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

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

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

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

brd: module loaded

loop: module loaded

Uniform Multi-Platform E-IDE driver

ide-gd driver 1.18

ide-cd driver 5.00

S3C24XX NAND Driver, (c) 2004 Simtec Electronics

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

s3c24xx-nand s3c2440-nand: NAND hardware ECC

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

Scanning device for bad blocks

Bad eraseblock 1158 at 0x0000090c0000

Bad eraseblock 1590 at 0x00000c6c0000

Bad eraseblock 1975 at 0x00000f6e0000

Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":

0x000000000000-0x000000400000 : "kernel"

0x000000400000-0x000000c00000 : "jffs2"

0x000000c00000-0x000010000000 : "yaffs"

dm9000 Ethernet Driver, V1.31

usbmon: debugfs is not available

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: configuration #1 chosen from 1 choice

hub 1-0:1.0: USB hub found

hub 1-0:1.0: 2 ports detected

usbcore: registered new interface driver libusual

usbcore: registered new interface driver usbserial

USB Serial support registered for generic

usbcore: registered new interface driver usbserial_generic

usbserial: USB Serial Driver core

USB Serial support registered for FTDI USB Serial Device

usbcore: registered new interface driver ftdi_sio

ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver

USB Serial support registered for pl2303

usbcore: registered new interface driver pl2303

pl2303: Prolific PL2303 USB to serial adaptor driver

mice: PS/2 mouse device common for all mice

S3C24XX RTC, (c) 2004,2006 Simtec Electronics

S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

Advanced Linux Sound Architecture Driver Version 1.0.21.

No device for DAI UDA134X

No device for DAI s3c24xx-i2s

ALSA device list:

  No soundcards found.

TCP cubic registered

NET: Registered protocol family 17

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

yaffs: dev is 32505858 name is "mtdblock2" rw

yaffs: passed flags ""

VFS: Mounted root (yaffs filesystem) on device 31:2.

Freeing init memory: 148K

 

Please press Enter to activate this console.

Processing /etc/profile...

Done

[root@ZK2440 /]# ls

bin        home        lost+found  proc        sys         var

dev        lib         mnt         root        tmp

etc        linuxrc     opt         sbin        usr

内核成功启动。

接下来可以设置内核开机自动启动:

ZK2440 # set bootcmd 'nboot 0x32000000 0 0;bootm 0x32000000'

ZK2440 # saveenv