我在将内核从旧 SH4 移植到新 SH4 时遇到问题。请让我展示它们之间的区别。
【老SH4】
引导加载程序:redboot v2.0
内核版本:2.4
【新SH4】
引导加载程序:u-boot v2009.03
内核版本:2.6
在旧的 SH4 中,很多源代码都是基于内核 2.4 开发的,因此将内核 2.4 移植到新的 SH4 看起来比在内核 2.6 中重新编译源代码更容易。所以我将 mkimage 应用于为旧 SH4 开发的 zImage,如下所示。
mkimage -A sh -O linux -T kernel -C none -a 0x8c210000 -e 0x8c210000 -n 'Old kernel' -d zImage uImage
该图像加载到新的 SH4 上,如下所示。
tftpboot 8c800000 uImage
cp.b $(fileaddr) a0100000 $(filesize)
bootm a0100000
但是,在“Uncompressing Linux... Ok, booting the kernel”之后启动停止并挂起。我发现无限循环发生在 kernel/head.S 的下面几行,但我想这些行没有问题,因为 kernel/head.S 没有定制,它适用于旧 SH4。
! Clear BSS area
mov.l 3f, r1 ! __bss_start
add #4, r1
mov.l 4f, r2 ! _end
mov #0, r0
9: cmp/hs r2, r1
bf/s 9b ! while (r1 < r2)
mov.l r0,@-r2
因此,我猜这个问题来自新旧 SH4 之间的环境差异。在旧 SH4 中,我执行 fconfig 命令并设置变量,如下所示。
Load Linux Kernel & File System: true
Linux Kernel Destination address: 0x8c210000
Linux Kernel Source address: 0x80140000
Linux Kernel Size: 0x100000
RAM disk Destination address: 0x8c360000
RAM disk Source address: 0x80140000
RAM disk Size: 0x400000
Modify Linux Kernel Parameter: true
Linux Kernel base address: 0x8c001000
Linux Kernel ENTRY address: 0x8c210000
Linux Kernel INITRD size: 0xc00000
Linux Kernel INITRD start address: 0x360000
Linux Kernel loader type: 1
Linux Kernel mount root read only: 1
Linux Kernel original root device: 0x100
Linux Kernel RAM disk flags: 0
Linux Kernel Enable Virtual Terminal Console: false
我想我可以在新的 SH4 上设置这些参数,尽管 u-boot 没有 fconfig 命令。但是我找不到如何设置参数 Linux Kernel Source address 和 Linux kernel base address。这与挂起问题有关吗?或者任何关于我接下来应该检查什么的建议都会有所帮助,因为我是 Linux 嵌入式系统的新手。
谢谢你的帮助。
[已编辑]
添加以下信息以在 u-boot 上显示 printenv 结果。
bootcmd=icache on
bootm a0100000
bootdelay=2
波特率=115200
netmask=255.255.255.0
ipaddr=192.168.1.2
serverip=192.168.1.1
gatewayip=0.0.0.0
bootargs=console=ttySC1,115200,N,8 mem=32M ether=8, 0x1300,0,0,eth0 video=e1356fb:system:ms104sh4,display:crt,bpp:8,800x600@60
stdin=serial
stdout=serial
stderr=serial