我用的是W90N745,原来的SDRAM是8M的,现在扩展为16M,目前内核可以正常启动,可是加载romfs时却出现下面的错误:
VFS: Mounted root (romfs filesystem) readonly.
boot_options:1
Mounted devfs on /dev
Freeing init memory: 48K
zflat:crc error
Unable to read code+data+bss, errno 12
zflat:crc error
Unable to read code+data+bss, errno 12
然后按一下回车,就出现下面这一句:
Kernel panic: Attempted to kill init!
原来8M的SDRAM时,汇编启动代码是这样的:
.section .text
.code 32
.global _start
.global boot_linux
.global service
.extern start_c
.extern _end
.extern service_tab
.extern direct_sdram_size
_start:
msr cpsr_c, #0xd1
ldr r13, =0x00800000 @8M bytes space
msr cpsr_c, #0xd2
ldr r13, =0x007fff00 @8M bytes space
msr cpsr_c, #0xd7
ldr r13, =0x007ffe00 @8M bytes space
msr cpsr_c, #0xdb
ldr r13, =0x007ffd00 @8M bytes space
msr cpsr_c, #0xdf
ldr r13, =0x007ffc00 @8M bytes space
msr cpsr_c, #0xd3
ldr r13, =0x007ffa00 @8M bytes space
ldr r10, =0xfff02000 @ 关CACHE
mov r11, #0
str r11, [r10]
str r11, [r10, #4]
ldr r10, =0xfff82124 @ 关中断
ldr r11, =0xffffffff
str r11, [r10]
ldr r10, =0xfff01000
ldr r11, =0x000500c1
str r11, [r10] @ EBI设置
ldr r8, =0x15B
str r8, [r10, #0x10] @ SDRAM的设置
@ bl direct_sdram_size
ldr r10, =0xfff00000
ldr r9, =0x2f01
str r9, [r10, #8]
ldr r11, =0x0101E5F8
ldr r12, =0x18fa0000
ldr r9, [r10, #0xc]
and r9, r9, r12
orr r9, r9, r11
str r9, [r10, #0xc] @ 外部设备的CLK
bl init_serial
@ ldr r0, =str1
@ bl puts
ldr r10, =0xfff01004
ldr r11, [r10]
cmp r11, #0x10000000
bhi ram_goto
ldr r12, =0x200028c3 @ SDRAM 控制寄存器
ldr r11, =0x00010FF0 @ BOOT-ROM 控制寄存器
ldr r10, =0x000500C1 @ 外部总线控制寄存器
ldr r1, =0xfff01008
stmda r1!, {r10-R12}
ldr r1, =0x00000000
ldr r2, =_end
ldr r3, =0x10000000 @ 拷贝代码到SDRAM
cpy_to_ram:
cmp r1, r2
ldrlo r0, [r1], #4
strlo r0, [r3], #4
blo cpy_to_ram
ldr r1, =0xfff01008
ldr r10,=0xFE040FF0
ldr r11,=0x000028c3 @ BOOT-ROM和SDRAM的地址交换
stmda r1!,{r10,r11}
ram_goto:
ldr r0, =start_c
mov r14, pc
bx r0
b .
boot_linux:
@ mov r0, #0
@ mov r1, #0
@ mov r2, #0
mov r3, #0
mov r4, #0
mov r5, #0
mov r6, #0
mov r7, #0
mov r8, #0
mov r9, #0
mov r10, #0
mov r11, #0
mov r12, #0
mov r13, #0
mov r14, #0
b 0x8000
service:
.word service_tab
str1:
.byte 't','e','s','t',' ','b','t',' ','f','l','a','s','h',' ','o','k','!',0
.end
换成16M的SDRAM后,我是这样改的:
.section .text
.code 32
.global _start
.global boot_linux
.global service
.extern start_c
.extern _end
.extern service_tab
.extern direct_sdram_size
_start:
msr cpsr_c, #0xd1
ldr r13, =0x00f00000 @16M bytes space
msr cpsr_c, #0xd2
ldr r13, =0x007fff00
msr cpsr_c, #0xd7
ldr r13, =0x007ffe00
msr cpsr_c, #0xdb
ldr r13, =0x007ffd00
msr cpsr_c, #0xdf
ldr r13, =0x007ffc00
msr cpsr_c, #0xd3
ldr r13, =0x007ffa00
ldr r10, =0xfff02000 @ 关CACHE
mov r11, #0
str r11, [r10]
str r11, [r10, #4]
ldr r10, =0xfff82124 @ 关中断
ldr r11, =0xffffffff
str r11, [r10]
ldr r10, =0xfff01000
ldr r11, =0x000500c1
str r11, [r10] @ EBI设置
ldr r8, =0x15B
str r8, [r10, #0x10] @ SDRAM的设置
@ bl direct_sdram_size
ldr r10, =0xfff00000
ldr r9, =0x2f01
str r9, [r10, #8]
ldr r11, =0x0101E5F8
ldr r12, =0x18fa0000
ldr r9, [r10, #0xc]
and r9, r9, r12
orr r9, r9, r11
str r9, [r10, #0xc] @ 外部设备的CLK
bl init_serial @ 让串口可以打印启动信息
@ ldr r0, =str1
@ bl puts
ldr r10, =0xfff01004
ldr r11, [r10]
cmp r11, #0x10000000
bhi ram_goto
ldr r12, =0x2000b0cc @ SDRAM16MB 控制寄存器
ldr r11, =0x00010FF0 @ BOOT-ROM 控制寄存器
ldr r10, =0x000500C1 @ 外部总线控制寄存器
ldr r1, =0xfff01008
stmda r1!, {r10-R12}
ldr r1, =0x00000000
ldr r2, =_end
ldr r3, =0x10000000 @ 拷贝代码到SDRAM
cpy_to_ram:
cmp r1, r2
ldrlo r0, [r1], #4
strlo r0, [r3], #4
blo cpy_to_ram
ldr r1, =0xfff01008
ldr r10,=0xFE040FF0
ldr r11,=0x0000b0cc @ BOOT-ROM和16MB SDRAM的地址交换
stmda r1!,{r10,r11}
ram_goto:
ldr r0, =start_c
mov r14, pc
bx r0
b .
boot_linux:
@ mov r0, #0
@ mov r1, #0
@ mov r2, #0
mov r3, #0
mov r4, #0
mov r5, #0
mov r6, #0
mov r7, #0
mov r8, #0
mov r9, #0
mov r10, #0
mov r11, #0
mov r12, #0
mov r13, #0
mov r14, #0
b 0x8000
service:
.word service_tab
str1:
.byte 't','e','s','t',' ','b','t',' ','f','l','a','s','h',' ','o','k','!',0
.end
还有内核里面是这样改的:
1)make menuconfig那里的system type是这样配置的:
(Winbond) ARM system type
[ ] Generate big endian code
Set flash/sdram size and base addr
(00000000) (S)DRAM Base Address
(00F00000) (S)DRAM Size
(FF000000) FLASH Base Address
(00080000) FLASH Size
(ff004000) ROMFS Base Address
(ROM) Kernel executes from
(WINBOND-W90N745) Board Implementation
2)然后修改内核里面的两个地方:
uClinux-dist/linux-2.4.x/drivers/block/blkmem.c
#ifndef ROMFS_BASE
#define FIXED_ROMARRAY (char *)0xF00000 //Tome:2010-06-01
#else
#define FIXED_ROMARRAY (char *)ROMFS_BASE
uClinux-dist/linux-2.4.x/arch/armnommu/kernel/setup.c
#ifndef MEM_SIZE
#ifndef DRAM_SIZE
#define MEM_SIZE (15*1024*1024) //Tome:2010-06-01
#else
#define MEM_SIZE DRAM_SIZE
#endif
我按照上面的步骤修改了之后,还是无法加载fomfs,请问大侠们,我的问题出在哪里呢? |