码迷,mamicode.com
首页 > 系统相关 > 详细

FL2440移植Linux2.6.33.7内核

时间:2014-05-09 11:38:14      阅读:560      评论:0      收藏:0      [点我收藏+]

标签:des   class   tar   ext   int   c   

kernel version:2.6.33.7

/linux-2.6.33.7

OS:CentOS 6.4

cross-compilation chain:arm-linux-4.3.2

/usr/local/arm/4.3.2/bin

第一步:修改配置

(1)选择合适的内核代码,作为硬件参考目标平台

arch/arm/mach-s3c2440

内核版本支持s3c2440,所以不需要作修改。

(2)修改顶层Makefile

设置体系架构:line193:ARCH?=$(SUBARCH)改为ARCH=arm
设置编译工具:line194:CROSS_COMPILE?=改为CROSS_COMPILE=arm-linux-

(3)修改输入时钟

修改arch/arm/mach-s3c2440/mach-smdk2440.c中line163:s3c24xx_init_clocks(12000000)


第二步:给内核打支持yaffs2文件系统的补丁

(1)下载:git clone git://www.aleph1.co.uk/yaffs2
(2)解压到/root,执行./patch-ker.sh c m /linux-2.6.33.7


第三步:配置内核

(1)选择参考配置文件

选择arch/arm/configs/s3c2440_defconfig作为配置参考。复制s3c2440_defconfig到顶层目录,更名.config

(2)清除临时文件、中间文件和配置文件

make clean    移除生成文件,保留配置文件
make mrproper   移除生成文件和配置文件
make distclean    移除所有文件

(3)配置内核

make config    文本模式配置
make menuconfig    文本菜单配置
make ddconfig    使用已有.config,但询问新增的配置选项
make xconfig    图形菜单配置


***********************************************  内核选项  ***********************************************

-------------------------------------------------------------------------------------------------------------

配置Yaffs2文件支持

修改配置如下:

File systems  ---> 
    [*] Miscellaneous filesystems  --->
        <*>   YAFFS2 file system support 
            -*-     512 byte / page devices
            -*-     2048 byte (or larger) / page devices 
                [*]       Autoselect yaffs2 format 
                [*]     Cache short names in RAM

-------------------------------------------------------------------------------------------------------------

配置cpu相关选项
修改配置如下:

System Type  ---> 
    S3C2440 Machines  ---> 
        [*] SMDK2440
        [*] SMDK2440 with S3C2440 CPU module

-------------------------------------------------------------------------------------------------------------

移植USB host驱动,仅仅需要修改配置即可
Device Drivers  ---> 
    [*] USB support  --->
        {*}   Support for Host-side USB 
        [*]     USB device filesystem (DEPRECATED) 
        [*]     USB device class-devices (DEPRECATED)
        <*>     OHCI HCD support 
        <*>   USB Mass Storage support

    [*] HID Devices  ---> 
        {*}   Generic HID support
        [*]     /dev/hidraw raw HID device support

    SCSI device support  --->
        <*> SCSI device support
        [*] legacy /proc/scsi/ support
        <*> SCSI disk support 
        <*> SCSI tape support

-------------------------------------------------------------------------------------------------------------

移植RTC驱动
Device Drivers  --->
    <*> Real Time Clock  --->
        [*]   Set system time from RTC on startup and resume
        (rtc0)  RTC used to set the system time
        [ ]   RTC debug support 
              *** RTC interfaces *** 
        [*]   /sys/class/rtc/rtcN (sysfs)
        [*]   /proc/driver/rtc (procfs for rtc0)
        [*]   /dev/rtcN (character devices)
        <*>   Samsung S3C series SoC RTC
添加对设备的支持:
# vi arch/arm/mach-s3c2440/mach-smdk2440.c
将smdk2440_devices增加一行&s3c_device_rtc,。
static struct platform_device *smdk2440_devices[] __initdata = {
        &s3c_device_usb,
        &s3c_device_lcd,
        &s3c_device_wdt,
        &s3c_device_i2c0,
        &s3c_device_iis,
        &s3c_device_rtc,//新增的一行
};

-------------------------------------------------------------------------------------------------------------

移植UDA1341驱动
# vi arch/arm/mach-s3c2440/mach-smdk2440.c
添加头文件:
#include <sound/s3c24xx_uda134x.h>
#include <mach/gpio-fns.h>
增加:
static struct s3c24xx_uda134x_platform_data s3c24xx_uda134x_data = {
        .l3_clk = S3C2410_GPB(4),
        .l3_data = S3C2410_GPB(3),
        .l3_mode = S3C2410_GPB(2),
        .model = UDA134X_UDA1341,
};

static struct platform_device s3c24xx_uda134x = {
        .name = "s3c24xx_uda134x",
        .dev = {
                .platform_data    = &s3c24xx_uda134x_data,
        }
};
添加:
static struct platform_device *smdk2440_devices[] __initdata = {
        &s3c_device_usb,
        &s3c_device_lcd,
        &s3c_device_wdt,
        &s3c_device_i2c0,
        &s3c_device_iis,
        &s3c_device_rtc,
        &s3c24xx_uda134x,//增加
};
配置内核
Device Drivers  --->
    <*> Sound card support  --->
        <*>   Advanced Linux Sound Architecture  --->
            <*>   OSS Mixer API
            <*>   OSS PCM (digital audio) API
                [*]     OSS PCM (digital audio) API - Include plugin system
                [*]   Support old ALSA API
                [*]   Verbose procfs contents
                [*]   Verbose printk
                [*]   Generic sound devices  --->
                <*>   ALSA for SoC audio support  --->
                    <*>   SoC Audio for the Samsung S3C24XX chips
                    <*>   SoC I2S Audio support UDA134X wired to a S3C24XX

-------------------------------------------------------------------------------------------------------------

移植DM9000驱动

修改 drivers/net/dm9000.c 文件
# vi drivers/net/dm9000.c
#include <mach/regs-gpio.h> 
#include <mach/irqs.h>
#include <mach/hardware.h>
在dm9000_probe 函数开始增加:
unsigned char ne_def_eth_mac_addr[]={0x00,0x12,0x34,0x56,0x80,0x49};
    static void *bwscon;
    static void *gpfcon;
    static void *extint0;
    static void *intmsk;
    #define BWSCON           (0x48000000)
    #define GPFCON           (0x56000050)
    #define EXTINT0           (0x56000088)
    #define INTMSK           (0x4A000008)      
        bwscon=ioremap_nocache(BWSCON,0x0000004);
        gpfcon=ioremap_nocache(GPFCON,0x0000004);
        extint0=ioremap_nocache(EXTINT0,0x0000004);
        intmsk=ioremap_nocache(INTMSK,0x0000004);                      
        writel(readl(bwscon)|0xc0000,bwscon);
        writel( (readl(gpfcon) & ~(0x3 << 14)) | (0x2 << 14), gpfcon); 
        writel( readl(gpfcon) | (0x1 << 7), gpfcon); // Disable pull-up
        writel( (readl(extint0) & ~(0xf << 28)) | (0x4 << 28), extint0); //rising edge
        writel( (readl(intmsk))  & ~0x80, intmsk);    
函数最后修改:
if (!is_valid_ether_addr(ndev->dev_addr)) {
                /* try reading from mac */
                mac_src = "chip";
                for (i = 0; i < 6; i++)
                        //ndev->dev_addr[i] = ior(db, i+DM9000_PAR); 
                        ndev->dev_addr[i] = ne_def_eth_mac_addr[i];//修改这里
        }
修改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_rtc,
        &s3c24xx_uda134x,
        &s3c_device_dm9000,//添加
};
修改文件arch/arm/plat-s3c24xx/devs.c
# vi arch/arm/plat-s3c24xx/devs.c
添加:
#include <linux/dm9000.h>
static struct resource s3c_dm9000_resource[] = { 
        [0] = { 
        .start = S3C24XX_PA_DM9000, 
        .end   = S3C24XX_PA_DM9000+ 0x3, 
        .flags = IORESOURCE_MEM 
        }, 
        [1]={ 
        .start = S3C24XX_PA_DM9000 + 0x4, //CMD pin is A2 
        .end = S3C24XX_PA_DM9000 + 0x4 + 0x7c, 
        .flags = IORESOURCE_MEM 
        }, 
        [2] = { 
        .start = IRQ_EINT7, 
        .end   = IRQ_EINT7, 
        .flags = IORESOURCE_IRQ 
        }, 
        };

        static struct dm9000_plat_data s3c_device_dm9000_platdata = { 
        .flags= DM9000_PLATF_16BITONLY, 
        };

        struct platform_device s3c_device_dm9000 = { 
        .name= "dm9000", 
        .id= 0, 
        .num_resources= ARRAY_SIZE(s3c_dm9000_resource), 
        .resource= s3c_dm9000_resource, 
          .dev= { 
        .platform_data = &s3c_device_dm9000_platdata, 
          } 
}; 
EXPORT_SYMBOL(s3c_device_dm9000);
修改arch/arm/plat-s3c/include/plat/devs.h   
# vi arch/arm/plat-s3c/include/plat/devs.h

添加:
extern struct platform_device s3c_device_dm9000;
修改arch/arm/mach-s3c2410/include/mach/map.h
# vi arch/arm/mach-s3c2410/include/mach/map.h
新增
/* DM9000 */ 
#define   S3C24XX_PA_DM9000 0x20000300 
#define   S3C24XX_VA_DM9000 0xE0000000

如果无法发现网卡,修改arch/arm/mach-s3c2410/mach-smdk2410.c在smdk2410_devices

增加以下行
&s3c_device_dm9000,
另外在static struct map_desc smdk2410_iodesc[] __initdata增加以下内容
[0] = { 
.virtual   = (unsigned long)S3C24XX_VA_DM9000, 
.pfn       = __phys_to_pfn(S3C24XX_PA_DM9000), 
.length     = SZ_1M, 
.type     = MT_DEVICE, 
},

-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------

*************************************************************************************************************


第四步:修改硬件配置

(1)修改机器码

机器码的作用是让bootloader(比如u-boot)识别内核的。此机器码必须与bootloader中的机器码一致,否则不能启动。
飞凌开发板的bootloader 默认的机器码是193,所以我们在使用FL2440 机器的时候,需要修改机器码。
修改arch/arm/tools/mach-types。将 
  s3c2440                ARCH_S3C2440                        S3C2440                                  362 
修改为193。 
  删除
          s3c2410...一项

(2)修改MTD分区

修改MTD分区(linux已有Nand Flash驱动,只需要对MTD分区进行修改,要与bootloader中对nand flash分区一致)    
文件:  arch/arm/plat-s3c24xx/common-smdk.c
结构体:static struct mtd_partition smdk_default_nand_part[]

static struct mtd_partition smdk_default_nand_part[] = { 
                [0] = { 
                                .name                = "Boot", 
                                .size                = 0x00100000, 
                                .offset = 0 
       }, 
                [1] = { 
                                .name                = "MyApp", 
                                .size                = 0x003c0000, 
                                .offset = 0x00140000, 
                }, 
                [2] = { 
                                .name                = "Kernel", 
                                .size                = 0x00300000, 
                                .offset = 0x00500000, 
                }, 
                [3] = { 
                                .name                = "fs_yaffs",

                                .size                = 0x03c00000,                  //30M 
                                .offset = 0x00800000, 
                },                 
               // [4] = { 
               //               .name                = "WINCE", 
               //               .size                = 0x03c00000, 
               //               .offset = 0x04400000, 
               // } 
            };

(3)移植Nand Flash驱动

关闭ECC校验:

   文件:drivers/mtd/nand/s3c2410.c 
            函数:s3c2410_nand_init_chip 
/*chip->ecc.mode = NAND_ECC_SOFT; */    chip->ecc.mode = NAND_ECC_NONE;

修改Nand Flash驱动

   文件:drivers/mtd/nand/nand_bbt.c 
static struct nand_bbt_descr largepage_memorybased = {
                                   .options = 0, 
                                    .offs = 0, 
                                    .len = 1,   //  原数值为2,支持2K 每页的flash 修改为1。K9F1G08,K9F2G08是2k 每页的flash 
                                    .pattern = scan_ff_pattern 
                        }; 
                static struct nand_bbt_descr largepage_flashbased = { 
                                    .options = NAND_BBT_SCAN2NDPAGE, 
                                    .offs = 0, 
                                    .len = 1,      //原数值为2,支持2K 每页的flash 修改为1。K9F1G08,K9F2G08是2k 每页的flash 
                                    .pattern = scan_ff_pattern 
                    };

第五步:编译内核

顶层目录编译,生成zImage

make zImage
在文件夹arch/arm/boot中

FL2440移植Linux2.6.33.7内核,布布扣,bubuko.com

FL2440移植Linux2.6.33.7内核

标签:des   class   tar   ext   int   c   

原文地址:http://www.cnblogs.com/lucas-hsueh/p/3709071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!