u-boot移植随笔(12):关于u-boot引导内核出现Error unrecognized/unsupported machine ID (r1 = 0x33f4fee8)的问题

这个问题同样经典,大意是说u-boot传递的machine id不正确。在网上看到的文章几乎如出一辙:有两种方法,一是修改内核的head.S(具体在./arch/arm/kernel目录下),二是修改u-boot代码。可惜,第二种方法中出现的源代码文件,在我移植的版本中没有发现。

我的提示信息是这样的:

1
2
3
4
5
6
7
8
9
Error: unrecognized/unsupported machine ID (r1 = 0x33f4fee8).

Available machine support:

ID (hex) NAME
000000c1 SMDK2410
000003f0 SMDK2440

Please check your kernel config and/or bootloader.

(注:这里使用的内核是许久以前我第二次移植linux时使用的。——不禁想起那段奋斗的日子。)
在u-boot代码(./board/samsung/smdk2440/smdk2440.c)中,赋值machine ID的代码如下:

1
gd->bd->bi_arch_number = MACH_TYPE_SMDK2440;

在linux内核(./arch/arm/mach-s3c2440/mach-smdk2440.c)中,代码是这样:

1
MACHINE_START(SMDK2440, "SMDK2440")

两者是一致的,都是1008(=0x3f0)。
而且,我在u-boot中打印板子信息也能看到这个machine id(第一行arch_number即是):

1
2
3
4
5
6
7
8
9
10
LATE2440 $ bd
arch_number = 0x000003F0
env_t = 0x00000000
boot_params = 0x30000100
DRAM bank = 0x00000000
-> start = 0x30000000
-> size = 0x04000000
ethaddr = 6c:61:74:65:6c:65
ip_addr = 192.168.1.200
baudrate = 115200 bps

按理说,既然大家都一致了,能正常引导才是啊。可惜还是不行。
于是修改了head.S文件,可以了。但是,这个应该是不推荐的方法。
后来我在cmd_bootm.c文件中的do_bootm_linux函数中添加一行debug信息:

1
2
3
4
5
6
7
8
/* new add for debug LL 2011-03-09 */
debug("## LL debug:machine id:%x, params:%x : %x\n", machid, bd->bi_boot_params, &(bd->bi_boot_params));
/* we assume that the kernel is in place */
printf ("\nStarting kernel ...\n\n");

cleanup_before_linux ();

theKernel (0, machid, bd->bi_boot_params);

在启动时显示如下:

1
2
3
4
5
6
7
8
9
10
## Transferring control to Linux (at address 30008000) ...
## LL debug:machine id:3f0, params:30000100 : 33f4ffd4

Starting kernel ...

Uncompressing

Linux.....................................................................................

....................................... done, booting the kernel.

注意,Starting kernel ...这行是u-boot打印的。 上面的信息证实了,在启动内核之前的那一刻,machine id还是0x3f0,是正常的。至于为什么就是不能引导,我也不清楚。 这个问题搞了很久,不过今天下午却能引导起来了。就是不修改head.S文件,不修改u-boot关键代码(加个Debug信息而已),就可以了。
下面是启动信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
LATE2440 $ bootm
* kernel: default image load address = 0x33000000
## Booting kernel from Legacy Image at 33000000 ...
Image Name: linux-2.6.30.2
Created: 2011-03-09 6:33:57 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1979832 Bytes = 1.9 MiB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
kernel data at 0x33000040, len = 0x001e35b8 (1979832)
Loading Kernel Image ... OK
OK
kernel loaded at 0x30008000, end = 0x301eb5b8
## Transferring control to Linux (at address 30008000) ...
## LL debug:machine id:3f0, params:30000100 : 33f4ffd4

Starting kernel ...

Uncompressing Linux............................................................................................................................ done, booting the kernel.
Linux version 2.6.30.2 (latelee@FightNow) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #50 Wed Mar 9 14:27:24 CST 2011

这个诡异的问题到底是怎么回事,山人也不明白。