ARM MACHINE_TYPE_XXXX問題
參考:http://www.arm.linux.org.uk/developer/machines/
本文引用地址:http://m.butianyuan.cn/article/201611/317206.htm193(0xC1) smdk2410
362(0x16A) S3C2440
2928 WM8505
3472WonderMedia WM8650 Reference Board
-------------------------------------------------------------------------------------------------------
The ArcNumber parameter references a particular mach-type/machine from the kernelsArm machine table, telling the kernel which specific piece of hardware its on.
Its presumed that the bundled kernel is hardcoded and doesnt need this parameter, but if you are building your own kernel, you need to set this parameter in uBoot , so the kernel knows what to boot. Leaving it set appears to be perfectly OK for botting the bundled kernels.
========================================================================================
The machine type number is obtained via the ARM Linux websiteMachine Registry. A machine type should be obtained as early in a
projects life as possible, it has a number of ramifications for the kernel port itself (machine definitions etc.) and changing definitions
afterwards may lead to a number of undesirable issues. These values are represented by a list of defines within the kernel source
(linux/arch/arm/tools/mach-types).
2. 作者遇到的問題
在<<移植linux 2.6.31到OK2440V3開發(fā)板(1)---bootm手動引導(dǎo)>>一文中,執(zhí)行完第6步的操作后,啟動u-boot后,用bootm 命令來引導(dǎo)內(nèi)核(執(zhí)行bootm 0x30008000),但是執(zhí)行后,卡住了,無法啟動內(nèi)核,現(xiàn)象如下:
Starting kernel ...
Uncompressing Linux.............................................................
Error: unrecognized/unsupported machine ID (r1 = 0x000000c1).
Available machine support:
ID (hex) NAME
000000a8 SMDK2440
從這里的提示信息可知,是u-boot的Machine Type和linux的不相同造成的,u-boot是0x000000c1(193),內(nèi)核是 0x0000016A(362)。
網(wǎng)上大多數(shù)都是修改linux內(nèi)核的機(jī)器碼,在arch/arm/tools/mach-types.h中,讓它們一致,具體修改哪一方,我覺得要看情況而定。
我們先看u-boot的機(jī)器碼和linux的機(jī)器碼是在什么地方?jīng)Q定的。
u-boot的機(jī)器碼是在u-boot的board/samsung/ok2440v3/ok2440v3.c文件里決定的:
/* arch number of SMDK2410-Board */
gd->bd->bi_arch_number = MACH_TYPE_SMDK2410;
查看u-boot/include/asm-arm/mach-types.h文件,有:
#define MACH_TYPE_SMDK2410 193
#define MACH_TYPE_S3C2440 362
這就是我們上面看到r1 = 0x000000c1(193)的原因。
linux的機(jī)器碼是由arch/arm/mach-s3c2440/mach-smdk2440.c下面的MACHINE_START(S3C2440, "SMDK2440")中的第一個參數(shù)S3C2440(關(guān)鍵字)決定的:
MACHINE_START(S3C2440, "SMDK2440")
/* Maintainer: Ben Dooks
.phys_io = S3C2410_PA_UART,
.io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
.boot_params = S3C2410_SDRAM_PA + 0x100,
.init_irq = s3c24xx_init_irq,
.map_io = smdk2440_map_io,
.init_machine = smdk2440_machine_init,
.timer = &s3c24xx_timer,
MACHINE_END
查看內(nèi)核目錄下的arch/arm/tools/mach-types.h文件,有:
smdk2410 ARCH_SMDK2410 SMDK2410 193
s3c2440 ARCH_S3C2440 S3C2440 362
smdk2440 MACH_SMDK2440 SMDK2440 1008
關(guān)鍵字是s3c2440,所以我們上面看到的是0x000000a8(362)。
所以,我們這里不去修改內(nèi)核,而是直接修改u-boot 的 board/samsung/ok2440v3/ok2440v3.c文件,如下:
/* arch number of SMDK2410-Board */
gd->bd->bi_arch_number = MACH_TYPE_S3C2440;
重新編譯u-boot后,下載到nand中,完成<<移植linux 2.6.31到OK2440V3開發(fā)板(1)---bootm手動引導(dǎo)>>一文中的第8步后,就可以手動成功引導(dǎo)內(nèi)核了。
評論