内核(2.6.14) + 根文件系统 + Qt4 移植 for S3C2410
/*********************************************************/
LarryChan 阿牛哥(亮)
chenliang_43@sina.com http://blog.sina.com.cn/mimimomoll
2008.5.7. 桂林电子科技大学 正平科技馆机器人中心
衷心感谢所有对本文有所帮助的人。本文仅供交流,无意侵权
/*********************************************************/
TARGET
CPU: S3C2410X
SDRAM:
HY57V561620(32MB) ×
2
FLASH:
K9F1208(64MB)
NET: CS8900
HOST
Linux Realse
Version: Fecora Core 6
CrossCompiler:
gcc-4.1.1/arm-linux-gcc-3.4.1
一、内核移植(2.6.14)
1 修改linux2.6.14下面的makefile文件
找到ARCH和CROSS_COMPILE,修改
ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/3.4.1/bin/arm-linux-
(此处为你交叉编译的路径)
2 设置flash分区
在arch/arm/machs3c2410/devs.c文件中添加头文件
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
#include <asm/arch/nand.h>
然后建立分区表
/* 一个Nand Flash总共64MB, 按如下大小进行分区 分区大小自己看着办*/
static struct mtd_partition partition_info[]
={
{ /* 1MB */
name: "bootloader",
size: 0x00100000,
offset: 0x0,
},{ /* 3MB */
name: "kernel",
size: 0x00300000,
offset: 0x00100000,
}, { /* 40MB */
name: "root",
size: 0x02800000,
offset: 0x00400000,
}, { /* 20MB */
name: "user",
size: 0x00f00000,
offset: 0x02d00000,
}
};
/*加入Nand Flash分区*/
struct s3c2410_nand_set
nandset ={
nr_partitions: 4, /*指明partition_info中定义的分区数目*/
partitions: partition_info, /* partition
table分区信息表*/
};
/*建立Nand Flash芯片支持*/
struct s3c2410_platform_nand
superlpplatform={
tacls:0,
twrph0:30,
twrph1:0,
sets: &nandset,
nr_sets: 1,
};
tacls, twrph0, twrph1的意思见S3C2410手册的63,
这3个值最后会被设置到NFCONF中,见S3C2410手册66.
sets: 支持的分区集 nr_set:分区集的个数
/*加入Nand Flash芯片支持到Nand Flash驱动
另外,还要修改此文件中的s3c_device_nand结构体变量,添加对dev成员的赋值*/
struct platform_device s3c_device_nand = {
.name = "s3c2410-nand",
/* Device name */
.id = -1,
/* Device ID */
.num_resources = ARRAY_SIZE(s3c_nand_resource),
.resource = s3c_nand_resource, /* Nand Flash Controller Registers
*/
/* Add the Nand Flash device */
.dev = {
.platform_data = &superlpplatform
}
};
指定启动时初始化
arch/arm/machs-3c2410/mach-smdk2410.c文件
找到platform_device
*smdk2410_devices[] __initdata函数,在该函数体最后加上一条语句:
&s3c_device_nand,
禁用禁止Flash ECC校验(有不同说法)
修改drivers/mtd/nand/s3c2410.c
找到chip->eccmode =
NAND_ECC_SOFT;
改为chip->eccmode =
NAND_ECC_NONE;
支持启动挂载devfs
修改fs/Kconfig文件
找到menu "Pseudo
filesystems" 添加
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
3 Yaffs2文件系统支持
下载yaffs2.tar.gz源码包,解压源码,并进入目录执行
#./patch-ker.sh c /linux-2.6.14.1/
注:假定内核源码在/linux-2.6.14.1/
4 编译配置内核,首先先load一个默认的内核/linux-2.6.14/arch/arm/configs/smdk2410_defconfig,在这个配置文件上改
Loadable module support >
[*] Enable loadable module support
[*] Automatic kernel module loading
System Type >
[*] S3C2410 DMA support
Boot options >
Default kernel command string:
noinitrd root=/dev/mtdblock2
init=/linuxrc console=ttySAC0,115200
Floating point emulation >
[*] NWFPE math emulation
Device Drivers >
Memory Technology Devices (MTD) >
[*] MTD partitioning support
#支持MTD分区,这样我们在前面设置的分区才有意义
[*] Command line partition table
parsing
#支持从命令行设置flash分区信息,灵活
RAM/ROM/Flash chip drivers >
<*> Detect flash chips by
Common Flash Interface (CFI) probe
<*> Detect nonCFI
AMD/JEDECcompatible flash chips
<*> Support for
Intel/Sharp flash chips
<*> Support for
AMD/Fujitsu flash chips
<*> Support for ROM chips
in bus mapping
NAND Flash Device Drivers >
<*> NAND Device Support
<*> NAND Flash support for
S3C2410/S3C2440 SoC
Character devices >
[*] Nonstandard serial port support
[*] S3C2410 RTC Driver
File systems >
<> Second extended fs support #去除对ext2的支持
Pseudo filesystems >
[*] /proc file system support
[*] Virtual memory file system
support (former shm fs)
[*] /dev file system support
(OBSOLETE)
[*] Automatically mount at boot
(NEW)
#这里会看到我们前先修改fs/Kconfig的成果,devfs已经被支持上了
Miscellaneous filesystems >
<*> Compressed ROM file system
support (cramfs) #支持cramfs
<*> YAFFS2 file system support #支持yaffs2
Network File Systems >
<*> NFS file system support
二、CS8900网卡驱动的移植
1 cs8900.c和cs8900.h放到/drivers/net/arm/
2 在cs8900.c中的cs8900_probe()函数中,memset
(&priv,0,sizeof (cs8900_t));函数之后添加如下两条语句:
__raw_writel(0x2211d110,S3C2410_BWSCON);
__raw_writel(0x1f7c,S3C2410_BANKCON3);
添加头文件#include
<asm/arch/regs-mem.h>
3 修改drivers/net/arm/目录下的Kconfig文件,在最后添加如下内容:
config
ARM_CS8900
tristate "CS8900 support"
depends on NET_ETHERNET && ARM
&& ARCH_SMDK2410
help
4 修改drivers/net/arm/目录下的Makefile文件,在最后添加如下内容:
obj-$(CONFIG_ARM_CS8900) += cs8900.o
5 在/arch/arm/mach-s3c2410/mach-smdk2410.c文件中,找到smdk2410_iodesc[]结构数组,添加如下如下内容:{vSMDK2410_ETH_IO, 0x19000000, SZ_1M, MT_DEVICE}
添加头文件#inlcude
<asm/arch/smdk2410.h>
其实这个就是下面的那个头文件的链接/include/asm-arm/arch-s3c2410/smdk2410.h
6 在include/asm-arm/arch-s3c2410/目录下创建smdk2410.h文件,其内容为:
#ifndef
_INCLUDE_SMDK2410_H_
#define
_INCLUDE_SMDK2410_H_
#include <linux/config.h>
#define
pSMDK2410_ETH_IO 0x19000000
#define
vSMDK2410_ETH_IO 0xE0000000
#define
SMDK2410_ETH_IRQ IRQ_EINT9
#endif //
_INCLUDE_SMDK2410_H_
7 编译内核,选中所装驱动
#make
menuconfig
Device Drivers >
Network
device support --->
Ethernet
(10 or 100Mbit) --->
[*]Ethernet
(10 or 100Mbit)
<*>CS8900
support
三、LCD驱动移植
1 在arch/arm/mach-s3c2410/mach-smdk2410.c中添加
//lcd
#include <asm/arch/regs-lcd.h>
#include <asm/arch-s3c2410/fb.h>
//-------------------------------------------lcd
static struct s3c2410fb_mach_info s3c2410_lcd_info __initdata = {
.fixed_syncs = 0,
.regs = {
//对于寄存器的设置是关键,可参考S3C2410X的手册
//和LCD技术手册中对于LCD技术指标的描述来进行设置。
//其中,寄存器值的宏定义在regs-lcd.h文件中。
/*
.lcdcon1 = S3C2410_LCDCON1_TFT16BPP
| S3C2410_LCDCON1_TFT
| S3C2410_LCDCON1_CLKVAL(1),
.lcdcon2 = S3C2410_LCDCON2_VBPD(32)
| S3C2410_LCDCON2_VFPD(9)
| S3C2410_LCDCON2_VSPW(1),
.lcdcon3 = S3C2410_LCDCON3_HBPD(47)
| S3C2410_LCDCON3_HFPD(15),
.lcdcon4 = S3C2410_LCDCON4_MVAL(13)
| S3C2410_LCDCON4_HSPW(95),
.lcdcon5 = S3C2410_LCDCON5_FRM565
| S3C2410_LCDCON5_INVVLINE
| S3C2410_LCDCON5_HWSWP
| S3C2410_LCDCON5_PWREN
| S3C2410_LCDCON5_INVVFRAME,
*/
.lcdcon1
= S3C2410_LCDCON1_TFT16BPP
| S3C2410_LCDCON1_TFT | S3C2410_LCDCON1_CLKVAL(1),
.lcdcon2
= S3C2410_LCDCON2_VBPD(1)
| S3C2410_LCDCON2_VFPD(2) | S3C2410_LCDCON2_VSPW(1),
.lcdcon3
= S3C2410_LCDCON3_HBPD(6)
| S3C2410_LCDCON3_HFPD(2),
.lcdcon4
= S3C2410_LCDCON4_MVAL(13)
| S3C2410_LCDCON4_HSPW(4),
.lcdcon5
= S3C2410_LCDCON5_FRM565
| S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_HWSWP
| S3C2410_LCDCON5_PWREN | S3C2410_LCDCON5_INVVFRAME,
},
.lpcsel = 0x0,
.gpccon = 0xaaaaaaaa,
.gpccon_mask = 0xffffffff,
.gpcup = 0xffffffff,
.gpcup_mask = 0xffffffff,
.gpdcon = 0xaaaaaaaa,
.gpdcon_mask = 0x0,
.gpdup = 0xffffffff,
.gpdup_mask = 0xffffffff,
.width = 640,
.height = 480,
.xres = {640,640,640},
.yres = {480,480,480},
.bpp = {16,16,16},
};
static void __init smdk2410_lcd_init(void)
{
set_s3c2410fb_info(&s3c2410_lcd_info);
}
3 在文件最后MACHINE_END之前添加
.init_machine =
smdk2410_lcd_init,
4 编译内核,选中所装驱动
#make menuconfig
Device Drivers >
Graphics
support --->
<*>
support for frame buffer devices
<*>
S3C2410 LCD framebuffer support
Logo
configuration ---> //开机画面的选择,可据个人需要更改
[*]Bootup
logo
[*]Standard
224-color linux logo
5 开机画面的选择
首先把要开机Logo图片(png格式)放在linux2.6.14文件中的 drivers/video/logo中,终端选择进入drivers/video/logo目录,进行以下操作:
(假设开机图片名为linux.png)
# pngtopnm linux.png > linuxlogo.pnm
# pnmquant 224
linuxlogo.pnm > linuxlogo224.pnm
#
pnmtoplainpnm linuxlogo224.pnm >
linuxlogo224.ppm
# mv linuxlogo224.ppm logo_linux_clut224.ppm //替换原来的启动文件
四、USB驱动移植
1 在arch/arm/mach-s3c2410/mach-smdk2410.c中紧接着LCD的部分添加
//usb
#include <asm/arch/usb-control.h>
#include <asm/arch/regs-clock.h>
#include <linux/device.h>
#include <linux/delay.h>
//-------------------------------------------------usb
struct s3c2410_hcd_info
usb_s3c2410_info =
{
.port[0] = {
.flags = S3C_HCDFLG_USED
}
};
int smdk2410_usb_init(void) /* USB */
{
unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03);
printk("USB Control, (c) 2006 s3c2410/n");
s3c_device_usb.dev.platform_data = &usb_s3c2410_info;
while(upllvalue!=__raw_readl(S3C2410_UPLLCON))
{
__raw_writel(upllvalue,S3C2410_UPLLCON);
mdelay(1);
}
return 0;
}
2 在smdk2410_map_io函数最后添加
smdk2410_usb_init();
3 编译内核,选中所装驱动,配置USB鼠标键盘
#make menuconfig
Device Drivers >
USB
support --->