linux-2.6.33移植到FL2440
宿主机:ubuntu10.04
目标机:fl2440
交叉编译器:arm-linux-gcc-3.4.1
交叉编译器路径:/usr/local/arm/3.4.1
要移植的内核版本:linux-2.6.33.19
<1>移植yaffs2驱动
yaffs下载地址:http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi
tar zxvf yaffs2.tar.gz
cd yaffs2
./patch-ker.sh c /linux-2.6.33.19
<2>修改机器码
- s3c2410 ARCH_S3C2410 S3C2410 193 删掉
- s3c2440 ARCH_S3C2440 S3C2440 362
修改为
- s3c2440 ARCH_S3C2440 S3C2440 193
<3> 指定编译器
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
<4>增加devfs文件器支持
找到 menu "Pseudo filesystems"
大概在105行
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
default y
config DEVFS_MOUNT
bool "Automatically mount at boot"
default y
depends on DEVFS_FS
<5>修改晶振频率
arch/arm/mach-s3c2440/mach-smdk2440.c
s3c24xx_init_clocks(12000000);
<6>修改MTD分区
arch/arm/plat-s3c24xx/common-smdk.c
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "boot",
.size = 0x00020000,
.offset = 0
},
[1] = {
.name = "bootParam",
.size = 0x00060000,
.offset = 0x00020000,
},
[2] = {
.name = "Kernel",
.size = 0x00300000,
.offset = 0x00500000,
},
[3] = {
.name = "fs_yaffs",
.size = 0x03c00000,
.offset = 0x00800000,
},
[4] = {
.name = "eboot",
.size = 0x00080000,
.offset = 0x04400000,
},
[5] = {
.name = "WINCE",
.size = 0x03b80000,
.offset = 0x04480000,
}
};
<7>关闭ECC校验
drivers/mtd/nand/s3c2410.c
chip->ecc.mode = NAND_ECC_NONE;
<8>修改nandflash驱动,支持K9F1G08的nandflash
修改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
};
<9>开始配置内核
make s3c2410_defconfig
去掉S3C2400 Machines、S3C2410 Machines、S3C2412 Machines、S3C2442 Machines的所有选项,否则会报错。如果现在编译内核,下载到开发板中,内核就可以正常启动了。呵呵,有了雏形,咱们继续移植设备驱动
<10>支持RTC
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,
};
<11>移植UDA1341
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,
};
<12>移植DM9000
修改 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)) {
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];
}
2. 修改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,
};
3. 修改 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);
4. 修改 arch/arm/plat-s3c/include/plat/devs.h 45行附近,添加
extern struct platform_device s3c_device_dm9000;
5.修改arch/arm/mach-s3c2410/include/mach/map.h 文件
#define S3C24XX_PA_DM9000 0x20000300
#define S3C24XX_VA_DM9000 0xE0000000
一. 修改arch/arm/plat-s3c24xx/devs.c
找到 ------------------------------>224行左右
将其下面的代码改为:
static struct resource s3c_ts_resource[] = {
[0] = {
.start = S3C24XX_PA_ADC,
.end = S3C24XX_PA_ADC + S3C24XX_SZ_ADC - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_TC,
.end = IRQ_TC,
.flags = IORESOURCE_IRQ,
},
};
struct platform_device s3c_device_ts = {
.name = "s3c2410-ts",
.id = -1,
.dev.parent = &s3c_device_adc.dev,
.num_resources = ARRAY_SIZE(s3c_ts_resource),
.resource = s3c_ts_resource,
};
EXPORT_SYMBOL(s3c_device_ts);
static struct s3c2410_ts_mach_info s3c2410ts_info;
void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info)
{
memcpy(&s3c2410ts_info, hard_s3c2410ts_info, sizeof(struct s3c2410_ts_mach_info));
s3c_device_ts.dev.platform_data = &s3c2410ts_info;
}
EXPORT_SYMBOL(s3c24xx_ts_set_platdata);
二. 修改arch/arm/mach-s3c2440/mach-smdk2440.c文件。
添加头文件#include <mach/ts.h>
并在static struct platform_device *smdk2440_devices[] __initdata 结构体数组内添加
&s3c_device_adc,(触摸屏需要ADC的支持)
&s3c_device_ts, //最好将adc添加到ts前面,否则触摸屏初始化时可能会出错//
并在上面结构体后面添加:
static struct s3c2410_ts_mach_info smdk2410_ts_cfg __initdata = {
.delay = 10000,
.presc = 49,
.oversampling_shift = 2,
};
最后在static void __init smdk2440_machine_init(void)函数中增加下列代码:
s3c24xx_ts_set_platdata(&smdk2410_ts_cfg);
三. 重新配置内核:
make menuconfig
在配置菜单中添加如下项:
Device Drivers --->
<*>Input device support --->
<*>Touchscreens --->
<*> Samsung S3C2410 touchscreen input driver
还有在编译的时候记得把这项也选上:
Device Drivers --->
<*>Input device support --->
<*> Event interface
四. 重新编译内核
make zImage
把生成怕镜像文件烧到板上运行,结果如下截图:
说明触摸屏驱动已加载进内核随系统启动起来了,但是在启动最后出现
在开发板终端执行 ls /dev 看见里面有个event0,这个就是触摸屏的设备文件。但是内核加载触摸屏用的设备名是/dev/ts0. 因此可以用以下方法解决:
mknod /dev/ts0 c 13 64(c代表字符型设备 13代表主设备号 64代表从设备号------可以查看内核源码,打开Documentation/devices.txt文件即可查看到具体的主从设备号)
另外的一种方法是在/dev/event0 和/dev/ts0之间做一个链接:
执行ln –s /dev/event0 /dev/ts0
然后再终端执行 cat /dev/ts0 然后触摸触摸屏 看终端是否有打印信息(我的是一些乱码的打印信息)。但是要让触摸屏能正常使用,还需要移植一个支持触摸屏校准的tslib.
接下来的工作就是移植tslib.
转自: