新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > TE2410移植linux-2.6.14及调试过程总结(2)

TE2410移植linux-2.6.14及调试过程总结(2)

作者:时间:2016-11-10来源:网络收藏
今天写总结再来分析一下s3c2410_nand_calc_rate函数,终于知道问题在哪了,之前的打印内容如下:

plat->tacls:0

本文引用地址:http://www.eepw.com.cn/article/201611/317263.htm

plat->twrph0:3

plat->twrph1:0

tacls:1

twrph0:1

twrph1:1

clkrate:100000000/*注意是8个0,实际就是是HCLK=100MHz*/

#define NS_IN_KHZ 10000000/*注意是7个0*/

static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)

{

int result;

result = (wanted * NS_IN_KHZ) / clk;

result++;

pr_debug("result %d from %ld, %d\n", result, clk, wanted);

if (result > max) {

printk("%d ns is too big for current clock rate %ld\n",

wanted, clk);

return -1;

}

if (result < 1)

result = 1;

return result;

}

s3c2410_nand_calc_rate(plat->twrph0, clkrate, 8)

即s3c2410_nand_calc_rate(3, 100000000, 8)

则wanted=3, clk=100000000,max=8

result = (wanted * NS_IN_KHZ) / clk

result =(3 * 10000000)/100000000显然结果为0,result++;后返回值为1

按照这个函数的本意应该是要返回4的,如果要修改的话,将它的值NS_IN_KHZ改为与HCLK相同的值,就可以了,我本来想改为100000000,想想如果uboot的FCLK改成202.8MHz,那么HCLK值为101.4MHz,则clkrate为101400000

result = (wanted * NS_IN_KHZ) / clk=(3 * 100000000)/101400000=0

还是不行啊,真该死,终于找到原因了,原来linux源码是没有问题的,在

linux-2.6.14\linux-2.6.14\arch\arm\mach-s3c2410\devs.c中

struct s3c2410_platform_nandsuperlpplatform={

tacls:0,

twrph0:30,/*原来写的是3*/

twrph1:0,

sets:&nandset,

nr_sets:1,

};

串口打印出来内容如下:

plat->tacls:0

plat->twrph0:30

plat->twrph1:0

tacls:1

twrph0:3

twrph1:1

clkrate:101400000

s3c2410-nand: timing: Tacls 10ns, Twrph0 30ns, Twrph1 10ns

5.Reading data from NAND FLASH without ECC is not recommended

VFS: Mounted root (cramfs filesystem) readonly.

Freeing init memory: 92K

Warning: unable to open an initial console.

Reading data from NAND FLASH without ECC is not recommended

sd_mod: version magic 2.6.8.1-ptx1 ARMv4 gcc-3.3 should be 2.6.14 ARMv4 gcc-3.4

usb_storage: version magic 2.6.8.1-ptx1 ARMv4 gcc-3.3 should be 2.6.14 ARMv4 gcc-3.4

usbvideo: version magic 2.6.8.1-ptx1 ARMv4 gcc-3.3 should be 2.6.14 ARMv4 gcc-3.4

ov511: version magic 2.6.8.1-ptx1 ARMv4 gcc-3.3 should be 2.6.14 ARMv4 gcc-3.4

说明一下:之前并没有碰到这个问题,写总结时故意去掉对devfs的支持,出现这样的错误

Warning: unable to open an initial console.

原因是文件系统的dev目录下没有console节点,解决办法有2个,

(1)制作文件系统时在dev目录下建立console节点

(2)make menuconfig时加上对devfs的支持,就可以正常启动

加上对devfs的支持,系统会根据需要自动创建所需节点

用ramdisk作根文件系统:

(1)make menuconfig时要选择支持ext2文件系统,因为ramdisk大多用ext2;

(2)make menuconfig时要选择RAM disk support

(3)make menuconfig时还要选择初始化ramdisk(initrd)

DeviceDrivers ->

Block Device->

<*>RAM disk support

[*]Initial RAM disk(initrd)support

(4)make menuconfig时还要设置好RAM disk的大小

DeviceDrivers ->

Block Device->

<*>RAM disk support

(16)Default number of RAM disks

(4096)Default RAM disk size(kbytes)

加载ramdisk时出现如下问题:

RAMDISK driver initialized:16RAM disks of4096Ksize 1024 blocksize

RAMDISK: Compressed image found at block 0

RAMDISK: incomplete write (-28 != 32768) 4194304

fs_names=ext2

root_mount_data=

VFS: Mounted root (ext2 filesystem).

Mounted devfs on /dev

Freeing init memory: 92K

attempt to access beyond end of device

ram0: rw=0, want=16518, limit=8192

EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=1944, block=8258

Failed to execute /linuxrc.Attempting defaults...

attempt to access beyond end of device

ram0: rw=0, want=16514, limit=8192

EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=1922, block=8256

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

解决办法:修改内核关于Ramdisk的设置

make menuconfig

DeviceDrivers ->

Block Device->

<*>RAM disk support

(16)Default number of RAM disks16改为8

(4096)Default RAM disk size(kbytes)4096改为8192

板子的SDRAM是64M,16*4096kB = 8*8192kB = 64M

问题依然:

RAMDISK driver initialized:8RAM disks of8192K size 1024 blocksize

Mounted devfs on /dev

Freeing init memory: 92K

attempt to access beyond end of device

ram0: rw=0, want=16518, limit=16384

EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=1944, block=8258

Failed to execute /linuxrc.Attempting defaults...

attempt to access beyond end of device

ram0: rw=0, want=16514, limit=16384

EXT2-fs error (device ram0): ext2_get_inode: unable to read inode block - inode=1922, block=8256

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

修改

Default number of RAM disks值改为4

Default RAM disk size(kbytes)值改为16384

问题解决

为什么是16384呢?16384kb=16M,我制作的ramdisk镜像大小为15M,这里的15M是未用gzip压缩前的大小.

另外关于commandline的值:initrd=0x30800040,0x400000 root=/dev/ram init=/linuxrc console=ttySAC0

initrd=0x30800040是ramdisk在SDRAM中的地址,我用mkimage将ramdisk加了64(0x40)字节头信息,制作成uboot可以识别的uRamdisk,然后下载到0x30800000,所以ramdisk的正真地址为0x30800040

0x400000(4M)为ramdisk的大小,要大于压缩后的大小,我制作好的ramdisk大小为15M,压缩后1.2M

root=/dev/ram也可以是root=/dev/ram0

我在nand flash的第四个分区下载了cramfs文件系统,可以通过mount命令挂载该分区到tmp目录下

# cd dev

# ls

consolekmemmmcptmxrdttyvcc

fbkmsgmtdblockptsrooturandomzero

fullmemnullptyshmusb

inputmiscportrandomttsvc

#mount /dev/mtdblock/3/tmp

另一种方法可以在系统启动时就挂载该分区

修改/etc/init.d/rcS文件

内容如下(蓝色字体为添加的内容):

#!/bin/sh

echo "mount cramfs from mtdblock/3"

/bin/mount /dev/mtdblock/3/tmp

echo "mount all"

/bin/mount –a

说明:/etc/init.d/rcS是可执行的二进制文件,系统启动时被执行



评论


相关推荐

技术专区

关闭