嵌入式linux学习笔记(一)

来源:互联网 发布:淘宝手机怎么删除差评 编辑:程序博客网 时间:2024/05/22 23:10
 

        最近开始学习linux驱动编写,目前直接使用jz2440已移植好的系统配合视频开始学习驱动编写,但是总是出现这样那样的问题。于是决定重头开始,先自己移植内核,在开始驱动学习。

        今天参照《嵌入式linux完全应用手册》进行驱动移植。

        cross_compile:4.9.3(下载地址:https://launchpad.net/gcc-arm-embedded/+download)。

        kernel:2.6.22.6

        1、先修改顶层目录下的Makefile文件:

         ARCH = arm

         CROSS_COMPILE = arm-none-eabi-

        2、输入make s3c2410_defconfig进行编译,在编译的过程中发生错误。

       

  CC      fs/binfmt_aout.oIn file included from include/linux/spinlock.h:53:0,                 from include/linux/module.h:9,                 from fs/binfmt_aout.c:7:fs/binfmt_aout.c: In function 'load_aout_binary':include/linux/a.out.h:141:38: error: 'SEGMENT_SIZE' undeclared (first use in this function) #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)                                      ^include/linux/kernel.h:36:37: note: in definition of macro '__ALIGN_MASK' #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))                                     ^include/linux/a.out.h:141:29: note: in expansion of macro 'ALIGN' #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)                             ^include/linux/a.out.h:148:9: note: in expansion of macro '_N_SEGMENT_ROUND'      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))         ^fs/binfmt_aout.c:320:30: note: in expansion of macro 'N_DATADDR'   (current->mm->start_data = N_DATADDR(ex));                              ^include/linux/a.out.h:141:38: note: each undeclared identifier is reported only once for each function it appears in #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)                                      ^include/linux/kernel.h:36:37: note: in definition of macro '__ALIGN_MASK' #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask))                                     ^include/linux/a.out.h:141:29: note: in expansion of macro 'ALIGN' #define _N_SEGMENT_ROUND(x) ALIGN(x, SEGMENT_SIZE)                             ^include/linux/a.out.h:148:9: note: in expansion of macro '_N_SEGMENT_ROUND'      : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))         ^fs/binfmt_aout.c:320:30: note: in expansion of macro 'N_DATADDR'   (current->mm->start_data = N_DATADDR(ex));make[1]: *** [fs/binfmt_aout.o] Error 1make: *** [fs] Error 2

        SEGMENT_SIZE’ undeclared

        解决方法:

        修改为:

        510: NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) -Dlinux


        3、修改arch/arm/mach-s3c2440/mach-s3c2440.c中的时钟初始化参数:

        修改为:180 :s3c24xx_init_clocks(12000000);

        4、修改mtd分区:

        /* NAND parititon from 2.4.18-swl5 */

static struct mtd_partition smdk_default_nand_part[] = {
        [0] = {
                .name   = "Boot Agent",
                .size   = SZ_16K,
                .offset = 0,
        },
        [1] = {
                .name   = "S3C2410 flash partition 1",
                .offset = 0,
                .size   = SZ_2M,
        },
        [2] = {
                .name   = "S3C2410 flash partition 2",
                .offset = SZ_4M,
                .size   = SZ_4M,
        },
        [3] = {
                .name   = "S3C2410 flash partition 3",
                .offset = SZ_8M,
                .size   = SZ_2M,
        },
        [4] = {
                .name   = "S3C2410 flash partition 4",
                .offset = SZ_1M * 10,
                .size   = SZ_4M,
        },
        [5] = {
                .name   = "S3C2410 flash partition 5",
                .offset = SZ_1M * 14,
                .size   = SZ_1M * 10,
        },
        [6] = {
                .name   = "S3C2410 flash partition 6",
                .offset = SZ_1M * 24,
                .size   = SZ_1M * 24,
        },
        [7] = {
                .name   = "S3C2410 flash partition 7",
                .offset = SZ_1M * 48,
                .size   = SZ_16M,
        }
};

        由于我是用的jz2440自带的u-boot其mtd分区如下:

device nand0 <nandflash0>, # parts = 4
 #: name                        size            offset          mask_flags
 0: bootloader          0x00040000      0x00000000      0
 1: params              0x00020000      0x00040000      0
 2: kernel              0x00200000      0x00060000      0
 3: root                0x0fda0000      0x00260000      0
         所以,修改为:

         static struct mtd_partition smdk_default_nand_part[] = {
        [0] = {
                .name   = "bootloader",
                .size   = 0x00040000,

               .offset = 0,
        },
        [1] = {
                .name   = "params",
                .offset = 0x00040000,
                .size   = 0x00020000,
        },
        [2] = {
                .name   = "kernel",
                .offset = 0x00060000,
                .size   = 0x00200000,
        },
        [3] = {
                .name   = "root",
                .offset =0x00260000,
                .size   = 0x0fda0000,
        },
};


       

0 0
原创粉丝点击