现在的位置: 首页 > 综合 > 正文

2440机器码

2018年04月17日 ⁄ 综合 ⁄ 共 2737字 ⁄ 字号 评论关闭

一、uboot 启动linux 内核时,无法识别机器码
           shuai2440# tftp 0x32000000 192.168.220.3:uImage.img
           dm9000 i/o: 0x20000300, id: 0x90000a46
           DM9000: running in 16 bit mode
           MAC: 08:00:3e:26:0a:5b
           operating at unknown: 0 mode
           Using dm9000 device
           TFTP from server 192.168.220.3; our IP address is 192.168.220.10
           Filename 'uImage.img'.
           Load address: 0x32000000
           Loading:
           #########################################

           #########################################
           done
           Bytes transferred = 1950540 (1dc34c hex)
           shuai2440# go 0x32000000
           ## Starting application at 0x32000000 ...
           Uncompressing Linux... done, booting the kernel.
           Error: unrecognized/unsupported machine ID (r1 = 0x32fbdeec).
(1)uboot 只能用于启动uImage,不能启动zImage.
(2)出错原因是go 启动内核时,uboot 不会传machiine ID 给内核,因为go 只是执行普通的应用程序,不考虑到传递参数给内核的问题.为了使命令go 能够启动内核,需要修改下面两方面:
            1.修改u-boot 的common/cmd_boot.c 的do_go()函数.
               /*#if defined(CONFIG_I386)*/ <==注释掉
               DECLARE_GLOBAL_DATA_PTR;
               /*#endif*/ <==注释掉
               ....
               #if !defined(CONFIG_NIOS)
               /**************add here*********************/
               if(argc==2)
               rc = ((ulong (*)(int, char *[]))addr) (0, gd->bd->bi_arch_number);
               else
              /*****************add end ********************/
               rc = ((ulong (*)(int, char *[]))addr) (--argc, &argv[1]);
            2.修改内核的arch/arm/kernel/head.S,直接将s3c2410 的参数赋给内核.
               __INIT
               .type stext, %function
               ENTRY(stext)
               /****************add here*****************/
               mov r0, #0
               mov r1, #0xc1
               ldr r2, =0x30000100
               /***************end add******************/
               msr cpsr_c, #PSR_F_BIT | PSR_I_BIT | MODE_SVC @ ensure svc mode
               @ and irqs disabled
(3)也可以直接使用bootm 命令启动内核,该命令可以将uboot 的machine ID传递给内核,正常启动.不过需要用uboot 的mkimage 工具生成uImage 镜像.

二、2440 机器码
     使用uboot 启动linux 内核时,必须使uboot 与kernel 中机器码一致,这样才能正确启动kernel.
(1)uboot 中机器码的设置
     在文件include/asm/mach-types.h 有两处关于2440 机器码的设定.
          #define MACH_TYPE_S3C2440 362
          #define MACH_TYPE_SMDK2440 1008
(2)uboot 中机器码的使用
     在文件board/samsung/lss2440/lss2440.c 中使用了2440 机器码.
           gd->bd->bi_arch_number = MACH_TYPE_S3C2440;
      可以看出,uboot 中使用的机器码为362,因此在kernel 中机器码也必须为362.
(3)kernel 中机器码的使用
      在文件arch/arm/mach-s3c2440 中MACHINE_START 使用了2440 的机器码.
           MACHINE_START(S3C2440, "SMDK2440")
      第一个参数S3C2440 决定了kernel 使用哪个机器码,可以看出kernel使用了S3C2440 的机器码.
(4)kernel 中机器码的设置
      在文件arch/arm/tools 中有两处设置2440 的机器码.
            s3c2440 ARCH_S3C2440 S3C2440 362
            smdk2440 MACH_SMDK2440 SMDK2440 1008
      由于在文件arch/arm/mach-s3c2440 中使用的机器码是"S3C2440",因此可以看出kernel 使用的机器码为362,而不是1008.
【attention】
      在实际移植过程中,或改变uboot 中机器码的设置,或改变kernel 中机器码的设置,但必须使两者保持一致.

抱歉!评论已关闭.