此篇主要对http://blog.csdn.net/dos5gw/archive/2010/08/11/5804587.aspx中的错误做修正和分析,
(1)
s3c2440平台关于nand flash部分的代码,
" 在你弄清楚移植代码的每一个步骤是为什么之前,不要去做所谓的移植,那是毫无意义的"
*****/arch/arm/plat-s3c24xx/common-smdk.c*****
- static struct mtd_partition smdk_default_nand_part[] = {
- [0] = {
- .name = "supervivi",
- .size = 0x00040000,
- .offset = 0,
- },
- [1] = {
- .name = "param",
- .offset = 0x00040000,
- .size = 0x00020000,
- },
- [2] = {
- .name = "Kernel",
- .offset = 0x00060000,
- .size = 0x00500000,
- },
- [3] = {
- .name = "root",
- .offset = 0x00560000,
- .size = 1024 * 1024 * 1024,
- },
- [4] = {
- .name = "nand",
- .offset = 0x00000000,
- .size = 1024 * 1024 * 1024,
- }
- }; //changed
- static struct s3c2410_nand_set smdk_nand_sets[] = {
- [0] = {
- .name = "NAND",
- .nr_chips = 1,
- .nr_partitions = ARRAY_SIZE(smdk_default_nand_part),//note
- .partitions = smdk_default_nand_part,
- },
- };//not changed
- static struct s3c2410_platform_nand smdk_nand_info = {
- .tacls = 20,
- .twrph0 = 60,
- .twrph1 = 20,
- .nr_sets = ARRAY_SIZE(smdk_nand_sets),//note
- .sets = smdk_nand_sets,
- };//not changed
- static struct platform_device __initdata *smdk_devs[] = {
- &s3c_device_nand, //
- &smdk_led4,
- &smdk_led5,
- &smdk_led6,
- &smdk_led7,
- };//not changed
- void __init smdk_machine_init(void)
- {
- /* Configure the LEDs (even if we have no LED support)*/
- s3c2410_gpio_cfgpin(S3C2410_GPF(4), S3C2410_GPIO_OUTPUT);
- s3c2410_gpio_cfgpin(S3C2410_GPF(5), S3C2410_GPIO_OUTPUT);
- s3c2410_gpio_cfgpin(S3C2410_GPF(6), S3C2410_GPIO_OUTPUT);
- s3c2410_gpio_cfgpin(S3C2410_GPF(7), S3C2410_GPIO_OUTPUT);
- s3c2410_gpio_setpin(S3C2410_GPF(4), 1);
- s3c2410_gpio_setpin(S3C2410_GPF(5), 1);
- s3c2410_gpio_setpin(S3C2410_GPF(6), 1);
- s3c2410_gpio_setpin(S3C2410_GPF(7), 1);
- if (machine_is_smdk2443())
- smdk_nand_info.twrph0 = 50;
- s3c_device_nand.dev.platform_data = &smdk_nand_info; //note
- /*s3c_device_nand的类型是platform_device ,
- 这里是platform_device::dev
- s3c_device_nand这个变量是在哪个文件定义的?
- -有的版本的内核代码, 在devs.c中定义s3c_device_nand
- -common-smdk.c中引用了此变量,故这个s3c_device_nand一定不是static.
- */
- platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));
- s3c_pm_init();
- }//not changed
把上面涉及nand flash的代码单独摘出来, 看的清楚些,
(2)
内核mane zImage, 烧写~ 开机
Uncompressing Linux...................................................................... done, booting the kernel.
Error: unrecognized/unsupported machine ID (r1 = 0x0000016a).
因为mini2440的开发板的bootloader是友善自己的supervivi, 开机后bl向内核传递一个机器码,
如果与内核中的机器码不匹配, 则出现上面的错误, 错误中提示的是0x000007cf, 换成10进制就是1999,
这个应该就是MINI2440的机器码,
BL传递的机器码是0x7cf, 但是内核是按照SMDK2440的配置编译的, 故内核的机器码为0x362,
方法有三, 前两个都麻烦, 要么改内核的机器码, 要么改vivi, 第三种比较简单:
方法就是进viviv,
选[s] Set the boot parameters,
再选[s] Set parameter,
Enter the parameter's name, 此处输入 mach_type
Enter the parameter's value, 此处输入 362
再选[w] Write the parameter table to flash memeory,
再选[q] Quit
再选[b] Boot the system
(3)
经过上面的修改, 机器码验证ok, 但是有新错误
sysfs: duplicate filename 's3c2440-nand' can not be created
原因是, 在原来的代码中, arch/arm/plat-s3c24xx/common-smdk.c, 已经存在下面的代码:
static struct platform_device __initdata *smdk_devs[] = {
&s3c_device_nand, //注意这里
&smdk_led4,
&smdk_led5,
&smdk_led6,
&smdk_led7,
};
&s3c_device_nand, //注意这里
&smdk_led4,
&smdk_led5,
&smdk_led6,
&smdk_led7,
};
但是我照着别的移植帖子做, 完全照抄修改, 改动了arch/arm/mach-s3c2440/mach-smdk2440.c的代码:
static struct platform_device *smdk2440_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_nand, //这里如果加上这行, 就出现错误,重复注册了s3c_device_nand这个设备
};
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
&s3c_device_iis,
&s3c_device_nand, //这里如果加上这行, 就出现错误,重复注册了s3c_device_nand这个设备
};
(4)
出现错误:
Kernel panic - not syncing: Attempted to kill init!
进入Kernel Configure
Kernel Features --->
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTA)
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTA)
这个EABI支持居然忘了选,,,,,
-------------------------
vi arch/arm/tools/mach-types
s3c2410 ARCH_S3C2410 S3C2410 182
s3c2440 ARCH_S3C2440 S3C2440 362
smdk2440 MACH_SMDK2440 SMDK2440 1008
mini2440 MACH_MINI2440 MINI2440 1999
改为:---------------------------->
smdk2440 MACH_SMDK2440 SMDK2440 1999
mini2440 MACH_MINI2440 MINI2440 1008
偷梁换柱,,, 因为我的板子的Kernel Configure的system type -> S3C2440 Machines,选择的是SMDK2440,
所以编译出的内核的机器码是1008, 但是vivi传递的机器码是1999,
在不改变vivi的情况下, 通过这个方法修改内核的机器码~, 实验~ ok
但是但是但是! 为什么串口中断打印的是: Error: unrecognized/unsupported machine ID (r1 = 0x0000016a). ??
0x16a = 362 !
转自:http://blog.csdn.net/dos5gw/archive/2010/08/13/5808566.aspx