TE2410移植linux-2.6.14及調(diào)試過程總結(jié)(2)
plat->tacls:0
本文引用地址:http://butianyuan.cn/article/201611/317263.htmplat->twrph0:3
plat->twrph1:0
tacls:1
twrph0:1
twrph1:1
clkrate:100000000/*注意是8個0,實(shí)際就是是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, %dn", result, clk, wanted);
if (result > max) {
printk("%d ns is too big for current clock rate %ldn",
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顯然結(jié)果為0,result++;后返回值為1
按照這個函數(shù)的本意應(yīng)該是要返回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.14linux-2.6.14archarmmach-s3c2410devs.c中
struct s3c2410_platform_nandsuperlpplatform={
tacls:0,
twrph0:30,/*原來寫的是3*/
twrph1:0,
sets:&nandset,
nr_sets:1,
};
串口打印出來內(nèi)容如下:
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
說明一下:之前并沒有碰到這個問題,寫總結(jié)時故意去掉對devfs的支持,出現(xiàn)這樣的錯誤
Warning: unable to open an initial console.
原因是文件系統(tǒng)的dev目錄下沒有console節(jié)點(diǎn),解決辦法有2個,
(1)制作文件系統(tǒng)時在dev目錄下建立console節(jié)點(diǎn)
(2)make menuconfig時加上對devfs的支持,就可以正常啟動
加上對devfs的支持,系統(tǒng)會根據(jù)需要自動創(chuàng)建所需節(jié)點(diǎn)
用ramdisk作根文件系統(tǒng):
(1)make menuconfig時要選擇支持ext2文件系統(tǒng),因?yàn)閞amdisk大多用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時還要設(shè)置好RAM disk的大小
DeviceDrivers ->
Block Device->
<*>RAM disk support
(16)Default number of RAM disks
(4096)Default RAM disk size(kbytes)
加載ramdisk時出現(xiàn)如下問題:
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.
解決辦法:修改內(nèi)核關(guān)于Ramdisk的設(shè)置
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壓縮前的大小.
另外關(guān)于commandline的值:initrd=0x30800040,0x400000 root=/dev/ram init=/linuxrc console=ttySAC0
initrd=0x30800040是ramdisk在SDRAM中的地址,我用mkimage將ramdisk加了64(0x40)字節(jié)頭信息,制作成uboot可以識別的uRamdisk,然后下載到0x30800000,所以ramdisk的正真地址為0x30800040
0x400000(4M)為ramdisk的大小,要大于壓縮后的大小,我制作好的ramdisk大小為15M,壓縮后1.2M
root=/dev/ram也可以是root=/dev/ram0
我在nand flash的第四個分區(qū)下載了cramfs文件系統(tǒng),可以通過mount命令掛載該分區(qū)到tmp目錄下
# cd dev
# ls
consolekmemmmcptmxrdttyvcc
fbkmsgmtdblockptsrooturandomzero
fullmemnullptyshmusb
inputmiscportrandomttsvc
#mount /dev/mtdblock/3/tmp
另一種方法可以在系統(tǒng)啟動時就掛載該分區(qū)
修改/etc/init.d/rcS文件
內(nèi)容如下(藍(lán)色字體為添加的內(nèi)容):
#!/bin/sh
echo "mount cramfs from mtdblock/3"
/bin/mount /dev/mtdblock/3/tmp
echo "mount all"
/bin/mount –a
說明:/etc/init.d/rcS是可執(zhí)行的二進(jìn)制文件,系統(tǒng)啟動時被執(zhí)行
評論