移植内核经常会出现
Uncompressing Linux................................................................ done, booting the kernel.
后无启动信息的状况,此时有下面调试方法:
一. 使用low level debug
1.
内核编译时要打开:kernel hacking->kernel debuging->low level
debug(这时要确认下arch/arm/kernel/debug.S(2.6),或debug-armv.S(2.4)里是否有相应MCU的
UART实现,没有就移植别的,主要是正确设置UART发送寄存器地址)
示例代码:
-
#if defined(CONFIG_ARCH_MX2ADS)
-
#warning CONFIG_ARCH_IMX21 defined
-
.macro addruart,rx
-
mrc p15, 0, \rx, c1, c0
-
tst \rx, #1 @ MMU enabled?
-
moveq \rx, #0x10000000 @ Physical
-
movne \rx, #0xe4000000 @ Virtual
-
orr \rx, \rx, #0xa000
-
orr \rx, \rx, #0x40
-
.endm
-
.macro senduart,rd,rx
-
str \rd, [\rx] @ TXDATA
-
.endm
-
.macro waituart,rd,rx
-
.endm
-
.macro busyuart,rd,rx
-
1002: ldrb \rd, [\rx, #0x54]
-
@ Check TRDY in USR1_1 (phys=0x1000a094)
-
and \rd, \rd, #0x2000
-
cmp \rd, #0x2000
-
bne 1002b
-
.endm
-
#endif
然后在要调试的地方加上printascii("XXX")进行调试。
二。使用printk buffer
当内核刚启动时,printk还不能将信息输出到串口或LCD,只是将它们记录到log buffer,启始地址为__log_buf(可从System.map得到),然后重启进到uboot,使用md查看buf里的信息。
例如:
System.map
-
c0363bac b printk_time
-
c0363bb0 b __log_buf
-
c0373bb0 b console_cmdline
-
u-boot # md 0xc0363bb0
-
c0363bb0: 4c3a353c 78756e69 72657620 6e6f6973 <5:Linux version
-
c0363bc0: 362e3220 2e35332e 620d3231 682d3174 2.6.35.12.bt1-h
-
c0363bd0: 30353369 30317635 72282030 40746f6f i3505v100 (root@
-
c0363be0: 61636f68 736f686c 6f6c2e74 646c6163 hocalhost.locald
-
c0363bf0: 69614d6f 2820296e 20636167 73726576 oMain) (gac vers
-
c0363c00: 206e6969 2e352e34 53282032 58694e4f iin 4.5.2 (SONiX
-
c0363c10: 43434520 352e342d 5220122e 61656c65 ECC-4.5.. Relea
-
c0363c20: 12206573 2d313130 300d1231 29202936 se .011-1..06) )
-
c0363c30: 32312320 64655720 63654420 20383220 #12 Wed Dec 28
-
c0363c40: 352a3930 38353a33 54520320 31303220 09*53:58 .RT 201
-
c0363c50: 343c0a31 5550433e 5241203a 3632394d 1.<4>CPU: ARM926
-
c0363c60: 532d4a45 31345b20 32393630 205d3536 EJ-S [41069265]
-
c0363c70: 68766572 6e6f6973 28203520 764d5241 revhsion 5 (ARMv
-
c0363c80: 4a415435 63202c29 30303d72 31333530 5TAJ), cr=000531
-
c0363c90: 3c0a3737 50433e34 56003a55 20545649 77.<4>CPU:.VIVT
-
c0363ca0: 61746164 63616320 202c6168 54564956 data cacha, VIVT
阅读(1070) | 评论(0) | 转发(0) |