今日写总结再来剖析一下s3c2410_nand_calc_rate函数,总算知道问题在哪了,之前的打印内容如下:
plat->tacls:0
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 da
VFS: Mounted root (cramfs filesystem) readonly.
Freeing init memory: 92K
Warning: unable to open an initial console.
Reading da
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_da
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是可执行的二进制文件,体系发动时被执行