Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2604588
  • 博文数量: 877
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 5920
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-05 12:25
个人简介

技术的乐趣在于分享,欢迎多多交流,多多沟通。

文章分类

全部博文(877)

文章存档

2021年(2)

2016年(20)

2015年(471)

2014年(358)

2013年(26)

分类: LINUX

2014-03-24 14:22:27


http://www.cnblogs.com/hnrainll/archive/2011/05/21/2052980.html

此篇主要对http://blog.csdn.net/dos5gw/archive/2010/08/11/5804587.aspx中的错误做修正和分析,

(1)

s3c2440平台关于nand flash部分的代码,

在你弄清楚移植代码的每一个步骤是为什么之前,不要去做所谓的移植,那是毫无意义的"

*****/arch/arm/plat-s3c24xx/common-smdk.c*****

  1. static struct mtd_partition smdk_default_nand_part[] = {  
  2.         [0] = {  
  3.                 .name   = "supervivi",  
  4.                 .size   = 0x00040000,  
  5.                 .offset = 0,  
  6.         },  
  7.         [1] = {  
  8.                 .name   = "param",  
  9.                 .offset = 0x00040000,  
  10.                 .size   = 0x00020000,  
  11.         },  
  12.         [2] = {  
  13.                 .name   = "Kernel",  
  14.                 .offset = 0x00060000,  
  15.                 .size   = 0x00500000,  
  16.         },  
  17.         [3] = {  
  18.                 .name   = "root",  
  19.                 .offset = 0x00560000,  
  20.                 .size   = 1024 * 1024 * 1024,   
  21.         },  
  22.         [4] = {  
  23.                 .name   = "nand",  
  24.                 .offset = 0x00000000,  
  25.                 .size   = 1024 * 1024 * 1024,   
  26.         }  
  27. }; //changed  
  28. static struct s3c2410_nand_set smdk_nand_sets[] = {  
  29.         [0] = {  
  30.                 .name           = "NAND",  
  31.                 .nr_chips       = 1,  
  32.                 .nr_partitions  = ARRAY_SIZE(smdk_default_nand_part),//note  
  33.                 .partitions     = smdk_default_nand_part,  
  34.         },  
  35. };//not changed  
  36. static struct s3c2410_platform_nand smdk_nand_info = {  
  37.         .tacls          = 20,  
  38.         .twrph0         = 60,  
  39.         .twrph1         = 20,  
  40.         .nr_sets        = ARRAY_SIZE(smdk_nand_sets),//note  
  41.         .sets           = smdk_nand_sets,  
  42. };//not changed  
  43. static struct platform_device __initdata *smdk_devs[] = {  
  44.         &s3c_device_nand, //  
  45.         &smdk_led4,  
  46.         &smdk_led5,  
  47.         &smdk_led6,  
  48.         &smdk_led7,  
  49. };//not changed  
  50. void __init smdk_machine_init(void)  
  51. {  
  52.         /* Configure the LEDs (even if we have no LED support)*/  
  53.         s3c2410_gpio_cfgpin(S3C2410_GPF(4), S3C2410_GPIO_OUTPUT);  
  54.         s3c2410_gpio_cfgpin(S3C2410_GPF(5), S3C2410_GPIO_OUTPUT);  
  55.         s3c2410_gpio_cfgpin(S3C2410_GPF(6), S3C2410_GPIO_OUTPUT);  
  56.         s3c2410_gpio_cfgpin(S3C2410_GPF(7), S3C2410_GPIO_OUTPUT);  
  57.         s3c2410_gpio_setpin(S3C2410_GPF(4), 1);  
  58.         s3c2410_gpio_setpin(S3C2410_GPF(5), 1);  
  59.         s3c2410_gpio_setpin(S3C2410_GPF(6), 1);  
  60.         s3c2410_gpio_setpin(S3C2410_GPF(7), 1);  
  61.         if (machine_is_smdk2443())  
  62.                 smdk_nand_info.twrph0 = 50;  
  63.         s3c_device_nand.dev.platform_data = &smdk_nand_info; //note  
  64.         /*s3c_device_nand的类型是platform_device ,  
  65.           这里是platform_device::dev 
  66.           s3c_device_nand这个变量是在哪个文件定义的? 
  67.           -有的版本的内核代码, 在devs.c中定义s3c_device_nand 
  68.           -common-smdk.c中引用了此变量,故这个s3c_device_nand一定不是static. 
  69.         */  
  70.           
  71.         platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));  
  72.         s3c_pm_init();  
  73. }//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,
};
但是我照着别的移植帖子做, 完全照抄修改, 改动了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这个设备
};
 
(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)
这个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
作者:Leo Chin
本博客文章,大多系网络中收集,转载请注明出处
相关标签:、、

分类: ARM9

阅读(608) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~