移植linux2.6.29内核及根文件系统到UP-CPU-2410(2)

二、移植linux内核
所需文件:
内核:Linux-2.6.29.1.tar.bz2
yaffs2代码:cvs-root.tar.gz
解压在工作目录下,分别是:
linux-2.6.29.1
cvs


1.修改内核源码
修改内核根目录的makefile,第193行:
ARCH  ?=arm
CROSS_COMPILE  ?=arm-linux-


修改MTD分区:
$vim  arch/arm/plat-s3c24xx/common-smdk.c

 

static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "vivi",
.size = 0x00020000,
.offset = 0,
},
[1] = {
.name = "param",
.offset = 0x00020000,
.size = 0x00010000,
},
[2] = {
.name = "kernel-2.6.29",
.offset = 0x00030000,
.size = 0x00200000,
},
[3] = {
.name = "root",
.offset = 0x00230000,
.size = 0x00800000,
},
[4] = {
.name = "yaffs",
.offset = 0x00a30000,
.size = 0x035cc000,
}
}

修改ECC校验:
$vim driver/mtd/nand/s3c2410.c
找到s3c2410_nand_init_chip()函数,将其中的
chip->ecc.mode=NAND_ECC_SOFT;
改成
chip->ecc.mode=NAND_ECC_NONE;

2.为内核打yaffs文件系统补丁
$cd cvs/yaffs2
$./patch-ker.sh c ../../linux-2.6.29.1/

3.移植DM9000网卡驱动
访问基址是0x10000000(BANK2):Index地址是0x10000000,Data地址是0x10000002.
地址线是ADD1,链接DM9000的CMD引脚,
总线位宽16位,
中断引脚为EINT2


添加DM9000平台设备:
$vim arch/arm/plat-s3c24xx/common-smdk.c
/*添加要包含的头文件*/
#if defined(CONFIG_DM9000)||defined(CONFIG_DM9000_MODULE)
#include <linux/dm9000.h>
#endif
/*添加DM9000的平台设备结构*/
#if defined(CONFIG_DM9000)|| defined(CONFIG_DM9000_MODULE)
static struct resource s3c_dm9k_resource[] = {
   [0] = {
  .start = S3C2410_CS2,   //ADD1=0时使用的地址
  .end = S3C2410_CS2 + 1,
  .flags = IORESOURCE_MEM,
   },

   [1] = {
  .start = S3C2410_CS2 + 2,  //ADD1=1时使用的地址
  .end = S3C2410_CS2 + 2 + 1,
  .flags = IORESOURCE_MEM,
   },
   [2] = {
  .start = IRQ_EINT2,      //中断号
  .end = IRQ_EINT2,
  .flags = IORESOURCE_IRQ,
   }
};

static struct dm9000_plat_data s3c_dm9k_platdata = {
   .flags = DM9000_PLATF_16BITONLY,  //数据总线宽度为16位
};

static struct platform_device s3c_device_dm9k = {
   .name = "dm9000",
   .id = 0,
   .num_resources = ARRAY_SIZE(s3c_dm9k_resource),
   .resource = s3c_dm9k_resource,
   .dev = {
  .platform_data = &s3c_dm9k_platdata,
   }
};
#endif

/*加入内核设备列表*/
static struct platform_device __initdata *smdk_devs[] = {
/*DM9000*/
#if defined(CONFIG_DM9000) || efined(CONFIG_DM9000_MODULE)
&s3c_device_dm9k,
#endif
...
...
};

修改DM9000驱动程序:
$vim drivers/net/dm9000.c
/*添加要包含的头文件*/
#if defined (CONFIG_ARCH_S3C2410)
#include <mach/regs-mem.h>
#endif

/*设置存储控制器使BANK2可用,设置默认MAC地址*/
/*添加的代码被宏CONFIG_ARCH_S3C2410包含起来*/
dm9000_probe(struct platform_device *pdev)
{
......
    int i;
u32 id_val;
/*DM9000 device*/
#if defined(CONFIG_ARCH_S3C2410)
unsigned int oldval_bwscon;
unsigned int oldval_bankcon2;
#endif

......

SET_NETDEV_DEV(ndev, &pdev->dev);
dev_dbg(&pdev->dev, "dm9000_probe()/n");

/*DM9000 device*/
#if defined(CONFIG_ARCH_S3C2410)
oldval_bwscon = *((volatile unsigned int *)S3C2410_BWSCON);
*((volatile unsigned int *)S3C2410_BWSCON) = (oldval_bwscon & ~(3<<8)) | S3C2410_BWSCON_DW2_16 | S3C2410_BWSCON_WS2 | S3C2410_BWSCON_ST2;

oldval_bankcon2 = *((volatile unsigned int *)S3C2410_BANKCON2);
*((volatile unsigned int *)S3C2410_BANKCON2) = 0x1f7c;
#endif
......

if (!is_valid_ether_addr(ndev->dev_addr)) {
dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
 "set using ifconfig/n", ndev->name);

/*DM9000 device*/
#if defined(CONFIG_ARCH_S3C2410)
printk("NOW use the default MAC address: 08:90:90:90:90:90/n");
ndev->dev_addr[0] = 0x08;
ndev->dev_addr[1] = 0x90;
ndev->dev_addr[2] = 0x90;
ndev->dev_addr[3] = 0x90;
ndev->dev_addr[4] = 0x90;
ndev->dev_addr[5] = 0x90;
#endif
}
......

out:
dev_err(db->dev, "not found (%d)./n", ret);

#if defined(cONFIG_ARCH_S3C2410)
*((volatile unsigned int *)S3C2410_BWSCON) = oldval_bwscon;
*((volatile unsigned int *)S3C2410_BANKCON2) = oldval_bankcon2;
#endif
......
}

/*注册中断,指定触发方式*/
dm9000_open(struct net_device *dev)
{
......
irqflags |= IRQF_SHARED;

#if defined(CONFIG_ARCH_S3C2410)
if (request_irq(dev->irq, &dm9000_interrupt, IRQF_SHARED|IRQF_TRIGGER_RISING, dev->name, dev))
#else
if (request_irq(dev->irq, &dm9000_interrupt, IRQF_SHARED, dev->name, dev))
#endif
   return -EAGAIN;
......
}

4.配置内核
$make s3c2410_defconfig
$make menuconfig
[*] Enable loadable module support  --->
    [*] Forced module loading
    [*] Module unloading 

System Type  ---> 
    S3C2410 Machines  --->  
   [*] SMDK2410/A9M2410
    其余Machines都不选(包括2400,2440等)

Kernel Features  --->
    [*] Use the ARM EABI to compile the kernel
Boot options  --->
    noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0

Userspace binary formats  --->   
    [*] Kernel support for ELF binaries

Device Drivers  ---> 
    [*] Network device support  --->
        [*] Ethernet (10 or 100Mbit)  --->
            <*> DM9000 support

File systems  ---> 
    [*] Miscellaneous filesystems  --->
        <*> YAFFS2 file system support
  [*]    Lets Yaffs do its own ECC 
    -*- Native language support  --->
        <*>Codepage 437 (United States, Canada)
        <*>Simplified Chinese charset (CP936, GB2312)
        <*>Traditional Chinese charset (Big5)
        <*>ASCII (United States)
        <*>NLS ISO 8859-1  (Latin 1; Western European Languages)
        <*>NLS UTF-8 

$make zImage


将/arch/arm/boot目录下生成的zImage下载到kernel分区。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值